Package org.chocosolver.solver.variables
Interface IViewFactory
-
- All Known Subinterfaces:
IModel
- All Known Implementing Classes:
Model
public interface IViewFactory extends ISelf<Model>
Interface to make views (BoolVar, IntVar, RealVar and SetVar) A kind of factory relying on interface default implementation to allow (multiple) inheritance- Author:
- Jean-Guillaume FAGES
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default BoolVarboolNotView(BoolVar bool)Creates a view over bool holding the logical negation of bool (ie, ¬BOOL).default IntVarintAbsView(IntVar var)Creates a view over var such that: |var|.default IntVarintAffineView(int a, IntVar x, int b)Creates an affine view over x such that: a.x + b.default IntVarintMinusView(IntVar var)Creates a view over var equal to -var.default IntVarintOffsetView(IntVar var, int cste)Creates a view based on var, equal to var+cste.default IntVarintScaleView(IntVar var, int cste)Creates a view over var equal to var*cste.default RealVarrealIntView(IntVar var, double precision)Creates a real view of var, i.e. a RealVar of domain equal to the domain of var.default RealVar[]realIntViewArray(IntVar[] ints, double precision)Creates an array of real views for a set of integer variables This should be used to include an integer variable in an expression/constraint requiring RealVardefault RealVar[][]realIntViewMatrix(IntVar[][] ints, double precision)Creates a matrix of real views for a matrix of integer variables This should be used to include an integer variable in an expression/constraint requiring RealVar
-
-
-
Method Detail
-
boolNotView
default BoolVar boolNotView(BoolVar bool)
Creates a view over bool holding the logical negation of bool (ie, ¬BOOL).- Parameters:
bool- a boolean variable.- Returns:
- a BoolVar equal to not(bool) (or 1-bool)
-
intOffsetView
default IntVar intOffsetView(IntVar var, int cste)
Creates a view based on var, equal to var+cste.- Parameters:
var- an integer variablecste- a constant (can be either negative or positive)- Returns:
- an IntVar equal to var+cste
-
intMinusView
default IntVar intMinusView(IntVar var)
Creates a view over var equal to -var. That is if var = [a,b], then this = [-b,-a].- Parameters:
var- an integer variable- Returns:
- an IntVar equal to -var
-
intScaleView
default IntVar intScaleView(IntVar var, int cste)
Creates a view over var equal to var*cste. Requires cste > -2
- if cste < -1, throws an exception;
- if cste = -1, returns a minus view;
- if cste = 0, returns a fixed variable;
- if cste = 1, returns var;
- otherwise, returns a scale view;- Parameters:
var- an integer variablecste- a constant.- Returns:
- an IntVar equal to var*cste
-
intAbsView
default IntVar intAbsView(IntVar var)
Creates a view over var such that: |var|.
- if var is already instantiated, returns a fixed variable;
- if the lower bound of var is greater or equal to 0, returns var;
- if the upper bound of var is less or equal to 0, return a minus view;
- otherwise, returns an absolute view;- Parameters:
var- an integer variable.- Returns:
- an IntVar equal to the absolute value of var
-
intAffineView
default IntVar intAffineView(int a, IntVar x, int b)
Creates an affine view over x such that: a.x + b.- Parameters:
a- a coefficientx- an integer variable.b- a constant- Returns:
- an IntVar equal to the absolute value of var
-
realIntView
default RealVar realIntView(IntVar var, double precision)
Creates a real view of var, i.e. a RealVar of domain equal to the domain of var. This should be used to include an integer variable in an expression/constraint requiring RealVar- Parameters:
var- the integer variable to be viewed as a RealVarprecision- double precision (e.g., 0.00001d)- Returns:
- a RealVar of domain equal to the domain of var
-
realIntViewArray
default RealVar[] realIntViewArray(IntVar[] ints, double precision)
Creates an array of real views for a set of integer variables This should be used to include an integer variable in an expression/constraint requiring RealVar- Parameters:
ints- the array of integer variables to be viewed as real variablesprecision- double precision (e.g., 0.00001d)- Returns:
- a real view of ints
-
realIntViewMatrix
default RealVar[][] realIntViewMatrix(IntVar[][] ints, double precision)
Creates a matrix of real views for a matrix of integer variables This should be used to include an integer variable in an expression/constraint requiring RealVar- Parameters:
ints- the matrix of integer variables to be viewed as real variablesprecision- double precision (e.g., 0.00001d)- Returns:
- a real view of ints
-
-