org.chocosolver.solver.variables.RealVar Maven / Gradle / Ivy
/*
* This file is part of choco-solver, http://choco-solver.org/
*
* Copyright (c) 2022, IMT Atlantique. All rights reserved.
*
* Licensed under the BSD 4-clause license.
*
* See LICENSE file in the project root for full license information.
*/
package org.chocosolver.solver.variables;
import org.chocosolver.solver.ICause;
import org.chocosolver.solver.exception.ContradictionException;
import org.chocosolver.solver.expression.continuous.arithmetic.CArExpression;
import org.chocosolver.util.objects.RealInterval;
/**
* An interface to declare variable for continuous constraints (solved using IBEX).
*
*
* @author Charles Prud'homme
* @since 18/07/12
*/
public interface RealVar extends Variable, CArExpression {
/**
* Updates the lower bound of the domain of this
to value
.
* The instruction comes from propagator
.
*
* - If
value
is smaller than the lower bound of the domain, nothing is done and the return value is false
,
* - if updating the lower bound to
value
leads to a dead-end (domain wipe-out),
* a ContradictionException
is thrown,
* - otherwise, if updating the lower bound to
value
can be done safely,
* the event type is created (the original event can be promoted) and observers are notified
* and the return value is true
*
*
* @param value new lower bound (included)
* @param cause updating releaser
* @return true if the lower bound has been updated, false otherwise
* @throws ContradictionException if the domain become empty due to this action
*/
boolean updateLowerBound(double value, ICause cause) throws ContradictionException;
/**
* Updates the upper bound of the domain of this
to value
.
* The instruction comes from propagator
.
*
* - If
value
is greater than the upper bound of the domain, nothing is done and the return value is false
,
* - if updating the upper bound to
value
leads to a dead-end (domain wipe-out),
* a ContradictionException
is thrown,
* - otherwise, if updating the upper bound to
value
can be done safely,
* the event type is created (the original event can be promoted) and observers are notified
* and the return value is true
*
*
* @param value new upper bound (included)
* @param cause update releaser
* @return true if the upper bound has been updated, false otherwise
* @throws org.chocosolver.solver.exception.ContradictionException
* if the domain become empty due to this action
*/
boolean updateUpperBound(double value, ICause cause) throws ContradictionException;
/**
* Updates the bounds of the domain of this
to value
.
* The instruction comes from propagator
.
*
* - If the interval defined by [
lowerbound
,upperbound
] includes the domain of this, nothing is done and the return value is false
,
* - if updating the domain leads to a dead-end (domain wipe-out),
* a
ContradictionException
is thrown,
* - otherwise, if updating the domain be done safely,
* the event type is created (the original event can be promoted) and observers are notified
* and the return value is
true
*
*
* @param lowerbound new lower bound (included)
* @param upperbound new upper bound (included)
* @param cause update releaser
* @return true if the upper bound has been updated, false otherwise
* @throws org.chocosolver.solver.exception.ContradictionException
* if the domain become empty due to this action
*/
boolean updateBounds(double lowerbound, double upperbound, ICause cause) throws ContradictionException;
double getPrecision();
@Override
default int getDomainSize() {
throw new UnsupportedOperationException("No domain size for RealVar");
}
@Override
default RealVar realVar(double p){
return this;
}
void silentlyAssign(RealInterval bounds);
void silentlyAssign(double lb, double ub);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy