public class VariableFactory extends Object
Note that, for the sack of readability, the Java naming convention is not respected for methods arguments.
Modifier and Type | Field and Description |
---|---|
static int |
MAX_INT_BOUND
Provide a minimum value for integer variable lower bound.
|
static int |
MIN_INT_BOUND
Provide a minimum value for integer variable lower bound.
|
Modifier and Type | Method and Description |
---|---|
static IntVar |
abs(IntVar VAR)
Create a view over VAR such that: |VAR|.
|
static BoolVar |
bool(String NAME,
Solver SOLVER)
Build a boolean variable, ie domain is [0,1]
|
static BoolVar[] |
boolArray(String NAME,
int SIZE,
Solver SOLVER)
Build a boolean variable array, ie each variable's domain is [0,1]
|
static BoolVar[][] |
boolMatrix(String NAME,
int DIM1,
int DIM2,
Solver SOLVER)
Build a DIM1*DIM2-sized boolean variable matrix
|
static IntVar |
bounded(String NAME,
int MIN,
int MAX,
Solver SOLVER)
Build an integer variable whose domain representation is abstracted by two integers:
a lower bound and an upper bound.
|
static IntVar[] |
boundedArray(String NAME,
int SIZE,
int MIN,
int MAX,
Solver SOLVER)
Build and array of bounded variables
(each variable domain is represented by two integers)
|
static IntVar[][] |
boundedMatrix(String NAME,
int DIM1,
int DIM2,
int MIN,
int MAX,
Solver SOLVER)
Build a DIM1*DIM2-sized matrix of bounded variables
(each variable domain is represented by two integers)
|
static IntVar[] |
castToIntVar(Variable... VARIABLES)
Casts VARIABLES into an integer variable array
|
static IntVar |
enumerated(String NAME,
int[] VALUES,
Solver SOLVER)
Build an integer variable whose domain is explicitly represented with a BitSet.
|
static IntVar |
enumerated(String NAME,
int MIN,
int MAX,
Solver SOLVER)
Build an integer variable whose domain is explicitly represented with a BitSet.
|
static IntVar[] |
enumeratedArray(String NAME,
int SIZE,
int[] VALUES,
Solver SOLVER)
Build an integer variable array with enumerated domains.
|
static IntVar[] |
enumeratedArray(String NAME,
int SIZE,
int MIN,
int MAX,
Solver SOLVER)
Build an array of integer variables whose domains are explicitly represented
|
static IntVar[][] |
enumeratedMatrix(String NAME,
int DIM1,
int DIM2,
int[] VALUES,
Solver SOLVER)
Build a DIM1*DIM2-sized matrix of integer variables with enumerated domains.
|
static IntVar[][] |
enumeratedMatrix(String NAME,
int DIM1,
int DIM2,
int MIN,
int MAX,
Solver SOLVER)
Build a DIM1*DIM2-sized matrix of integer variables whose domains are explicitly represented
|
static BoolVar |
eq(BoolVar VAR)
Create a kind of clone of VAR such that, the resulting view is defined on VAR.
|
static IntVar |
eq(IntVar VAR)
Create a kind of clone of VAR (an offset view with CSTE= 0), such that, the resulting view is defined on VAR.
|
static IntVar |
fixed(boolean VALUE,
Solver SOLVER)
get a specific boolean variable, whom domain is reduced to the singleton {VALUE}.
|
static IntVar |
fixed(int VALUE,
Solver SOLVER)
Create a specific integer variable whom domain is reduced to the singleton {VALUE}.
|
static SetVar |
fixed(String NAME,
int[] VALUE,
Solver SOLVER)
Create a specific set variable, named NAME whom domain is reduced to the singleton {VALUE}.
|
static IntVar |
fixed(String NAME,
int VALUE,
Solver SOLVER)
Create a specific integer variable, named NAME whom domain is reduced to the singleton {VALUE}.
|
static IntVar |
integer(String NAME,
int MIN,
int MAX,
Solver SOLVER)
Build an integer variable whose domain representation is abstracted by two integers:
a lower bound and an upper bound.
|
static IntVar[] |
integerArray(String NAME,
int SIZE,
int MIN,
int MAX,
Solver SOLVER)
Build and array of bounded variables
(each variable domain is represented by two integers)
|
static IntVar[][] |
integerMatrix(String NAME,
int DIM1,
int DIM2,
int MIN,
int MAX,
Solver SOLVER)
Build a DIM1*DIM2-sized matrix of bounded variables
(each variable domain is represented by two integers)
|
static IntVar |
minus(IntVar VAR)
Create a view over VAR holding : −VAR.
|
static BoolVar |
not(BoolVar BOOL)
Create a view over BOOL holding the logical negation of BOOL (ie, ¬BOOL).
|
static IntVar |
offset(IntVar VAR,
int CSTE)
Create an offset view based on VAR, such that, the resulting view is defined on VAR + CSTE.
|
static BoolVar |
one(Solver SOLVER)
Retrieve the specific one/true boolvar.
|
static RealVar[] |
real(IntVar[] VARS,
double PRECISION)
Create an array of real variables based on an array of integer variables VAR.
|
static RealVar |
real(IntVar VAR,
double PRECISION)
Create a real variable based on an integer variable VAR.
|
static RealVar |
real(String NAME,
double MIN,
double MAX,
double PRECISION,
Solver SOLVER)
Build a real variable with a bounded domain initialized to [MIN,MAX]
|
static RealVar[] |
realArray(String NAME,
int SIZE,
double MIN,
double MAX,
double PRECISION,
Solver SOLVER)
Build a SIZE-sized array of real variables.
|
static RealVar[][] |
realMatrix(String NAME,
int DIM1,
int DIM2,
double MIN,
double MAX,
double PRECISION,
Solver SOLVER)
Build a DIM1*DIM2-sized matrix of real variables.
|
static IntVar |
scale(IntVar VAR,
int CSTE)
Create a view over VAR such that: VAR×CSTE (CSTE>-2).
|
static SetVar |
set(String NAME,
int[] ENVELOPE,
int[] KERNEL,
Solver SOLVER)
Builds a set variable with an initial domain given by ENVELOP and KERNEL.
|
static SetVar |
set(String NAME,
int[] ENVELOPE,
SetType ENV_TYPE,
int[] KERNEL,
SetType KER_TYPE,
Solver SOLVER)
Builds a set variable with an initial domain given by ENVELOP and KERNEL.
|
static SetVar |
set(String NAME,
int[] ENVELOPE,
Solver SOLVER)
Builds a set variable with an initial domain given by ENVELOP and KERNEL.
|
static SetVar |
set(String NAME,
int MIN_ELEMENT,
int MAX_ELEMENT,
Solver SOLVER)
Builds a set variable with an initial domain given by
ENVELOP = [MIN_ELEMENT,MAX_ELEMENT] and an empty KERNEL.
|
static Task |
task(IntVar START,
IntVar DURATION,
IntVar END)
Build a Task software component (not a variable) which ensures that START + DURATION = END
|
static IntVar[][] |
toMatrix(IntVar[] VARS,
int DIM1,
int DIM2)
Inserts VARS into a new DIM1*DIM2-size matrix:
put variable of VARS[i*DIM2+j] into mat[i][j]
|
static BoolVar |
zero(Solver SOLVER)
Retrieve the specific zero/false boolvar.
|
public static final int MIN_INT_BOUND
public static final int MAX_INT_BOUND
public static BoolVar bool(String NAME, Solver SOLVER)
NAME
- name of the variableSOLVER
- solver involving the variablepublic static BoolVar[] boolArray(String NAME, int SIZE, Solver SOLVER)
NAME
- name of the variablesSIZE
- number of variablesSOLVER
- solver involving the variablepublic static BoolVar[][] boolMatrix(String NAME, int DIM1, int DIM2, Solver SOLVER)
NAME
- name of the variablesDIM1
- number of rowsDIM2
- number of columnsSOLVER
- solver involving the variablepublic static IntVar integer(String NAME, int MIN, int MAX, Solver SOLVER)
This API automatically selects the way the domain is represented by checking its size and by comparing
it to Settings.getMaxDomSizeForEnumerated()
:
a domain size below this value calls VariableFactory.enumerated
, VariableFactory.bounded
otherwise.
NAME
- name of the variableMIN
- initial lower boundMAX
- initial upper boundSOLVER
- solver involving the variablebounded(String, int, int, org.chocosolver.solver.Solver)
,
enumerated(String, int, int, org.chocosolver.solver.Solver)
public static IntVar[] integerArray(String NAME, int SIZE, int MIN, int MAX, Solver SOLVER)
NAME
- name of the variablesSIZE
- number of variablesMIN
- initial lower boundMAX
- initial upper boundSOLVER
- solver involving the variableinteger(String, int, int, org.chocosolver.solver.Solver)
,
bounded(String, int, int, org.chocosolver.solver.Solver)
,
enumerated(String, int, int, org.chocosolver.solver.Solver)
public static IntVar[][] integerMatrix(String NAME, int DIM1, int DIM2, int MIN, int MAX, Solver SOLVER)
NAME
- name of the variablesDIM1
- number of rowsDIM2
- number of columnsMIN
- initial lower boundMAX
- initial upper boundSOLVER
- solver involving the variableinteger(String, int, int, org.chocosolver.solver.Solver)
,
bounded(String, int, int, org.chocosolver.solver.Solver)
,
enumerated(String, int, int, org.chocosolver.solver.Solver)
public static IntVar bounded(String NAME, int MIN, int MAX, Solver SOLVER)
NAME
- name of the variableMIN
- initial lower boundMAX
- initial upper boundSOLVER
- solver involving the variablepublic static IntVar[] boundedArray(String NAME, int SIZE, int MIN, int MAX, Solver SOLVER)
NAME
- name of the variablesSIZE
- number of variablesMIN
- initial lower boundMAX
- initial upper boundSOLVER
- solver involving the variablepublic static IntVar[][] boundedMatrix(String NAME, int DIM1, int DIM2, int MIN, int MAX, Solver SOLVER)
NAME
- name of the variablesDIM1
- number of rowsDIM2
- number of columnsMIN
- initial lower boundMAX
- initial upper boundSOLVER
- solver involving the variablepublic static IntVar enumerated(String NAME, int MIN, int MAX, Solver SOLVER)
NAME
- name of the variableMIN
- initial lower boundMAX
- initial upper boundSOLVER
- solver involving the variablepublic static IntVar[] enumeratedArray(String NAME, int SIZE, int MIN, int MAX, Solver SOLVER)
NAME
- name of the variablesSIZE
- number of variablesMIN
- initial lower boundMAX
- initial upper boundSOLVER
- solver involving the variablepublic static IntVar[][] enumeratedMatrix(String NAME, int DIM1, int DIM2, int MIN, int MAX, Solver SOLVER)
NAME
- name of the variablesDIM1
- number of rowsDIM2
- number of columnsMIN
- initial lower boundMAX
- initial upper boundSOLVER
- solver involving the variablepublic static IntVar enumerated(String NAME, int[] VALUES, Solver SOLVER)
NAME
- name of the variableVALUES
- initial domainSOLVER
- solver involving the variablepublic static IntVar[] enumeratedArray(String NAME, int SIZE, int[] VALUES, Solver SOLVER)
NAME
- name of the variablesSIZE
- number of variablesVALUES
- initial domainSOLVER
- solver involving the variablepublic static IntVar[][] enumeratedMatrix(String NAME, int DIM1, int DIM2, int[] VALUES, Solver SOLVER)
NAME
- name of the variablesDIM1
- number of rowsDIM2
- number of columnsVALUES
- initial domainSOLVER
- solver involving the variablepublic static RealVar real(String NAME, double MIN, double MAX, double PRECISION, Solver SOLVER)
NAME
- name of the variableMIN
- initial lower boundMAX
- initial upper boundPRECISION
- double precision (e.g., 0.00001d)SOLVER
- solver involving the variablepublic static RealVar[] realArray(String NAME, int SIZE, double MIN, double MAX, double PRECISION, Solver SOLVER)
NAME
- name of the variablesSIZE
- number of variablesMIN
- initial lower boundMAX
- initial upper boundPRECISION
- double precision (e.g., 0.00001d)SOLVER
- solver involving the variablepublic static RealVar[][] realMatrix(String NAME, int DIM1, int DIM2, double MIN, double MAX, double PRECISION, Solver SOLVER)
NAME
- name of the variablesDIM1
- number of rowsDIM2
- number of columnsMIN
- initial lower boundMAX
- initial upper boundPRECISION
- double precision (e.g., 0.00001d)SOLVER
- solver involving the variablepublic static SetVar set(String NAME, int[] ENVELOPE, SetType ENV_TYPE, int[] KERNEL, SetType KER_TYPE, Solver SOLVER)
NAME
- name of the variableENVELOPE
- elements potentially in the setENV_TYPE
- type of data structure for storing the envelopeKERNEL
- elements that must belong to the final setKER_TYPE
- type of data structure for storing the kernelSOLVER
- solver involving the variablepublic static SetVar set(String NAME, int[] ENVELOPE, int[] KERNEL, Solver SOLVER)
NAME
- name of the variableENVELOPE
- elements potentially in the setKERNEL
- elements that must belong to the final setSOLVER
- solver involving the variablepublic static SetVar set(String NAME, int[] ENVELOPE, Solver SOLVER)
NAME
- name of the variableENVELOPE
- elements potentially in the setSOLVER
- solver involving the variablepublic static SetVar set(String NAME, int MIN_ELEMENT, int MAX_ELEMENT, Solver SOLVER)
NAME
- name of the variableMIN_ELEMENT
- lower boundMAX_ELEMENT
- upper boundSOLVER
- solver involving the variablepublic static Task task(IntVar START, IntVar DURATION, IntVar END)
START
- IntVar representing the start of the taskDURATION
- IntVar representing the duration of the taskEND
- IntVar representing the end of the taskpublic static IntVar[] castToIntVar(Variable... VARIABLES)
VARIABLES
- variablespublic static IntVar[][] toMatrix(IntVar[] VARS, int DIM1, int DIM2)
VARS
- variablesDIM1
- number of rowsDIM2
- number of columns
Note that DIM1*DIM2 is supposed to be equal to VARS.lengthpublic static IntVar fixed(int VALUE, Solver SOLVER)
This API does not require any name, a default one will be assigned to the variable. Furthermore, the object created will be cached, if not already, to avoid creating multiple occurrence of the same "constant" variable.
If one want to avoid the caching process, the following API should be used: VariableFactory#fixed(String NAME, int VALUE, Solver SOLVER)
VALUE
- the valueSOLVER
- the solver to build the integer variable in.public static BoolVar zero(Solver SOLVER)
SOLVER
- the solver to build the integer variable in.public static BoolVar one(Solver SOLVER)
SOLVER
- the solver to build the integer variable in.public static IntVar fixed(String NAME, int VALUE, Solver SOLVER)
Beware: if the name start with "cste -- ", the resulting variable will be cached.
NAME
- name of the constantVALUE
- its valueSOLVER
- the solver to build the integer variable in.public static IntVar fixed(boolean VALUE, Solver SOLVER)
VALUE
- its valueSOLVER
- the solver to build the integer variable in.public static SetVar fixed(String NAME, int[] VALUE, Solver SOLVER)
NAME
- name of the constantVALUE
- its value, a set of integers (duplicates will be removed)SOLVER
- the solver to build the integer variable in.public static IntVar offset(IntVar VAR, int CSTE)
The resulting IntVar does not have explicit domain: it relies on the domain of VAR for reading and writing operations. Any operations on this will transformed to operations on VAR following the offset rules.
VAR
- an integer variableCSTE
- a constantpublic static IntVar eq(IntVar VAR)
The resulting IntVar does not have explicit domain: it relies on the domain of VAR for reading and writing operations. Any operations on this will transformed to operations on VAR following the offset rules.
VAR
- an integer variablepublic static BoolVar eq(BoolVar VAR)
The resulting BoolVar does not have explicit domain: it relies on the domain of VAR for reading and writing operations. Any operations on this will transformed to operations on VAR.
VAR
- an integer variablepublic static BoolVar not(BoolVar BOOL)
The resulting BoolVar does not have explicit domain: it relies on the domain of BOOL for reading and writing operations. Any operations on this will transformed to operations on VAR following the "not" rules.
BOOL
- a boolean variable.public static IntVar minus(IntVar VAR)
The resulting IntVar does not have explicit domain: it relies on the domain of VAR for reading and writing operations. Any operations on this will transformed to operations on VAR following the "minus" rules.
VAR
- an integer variablepublic static IntVar scale(IntVar VAR, int CSTE)
- 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;
The resulting IntVar does not have explicit domain: it relies on the domain of VAR for reading and writing operations. Any operations on this will transformed to operations on VAR following the "scale" rules.
VAR
- an integer variableCSTE
- a constant.public static IntVar abs(IntVar 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;
The resulting IntVar does not have explicit domain: it relies on the domain of VAR for reading and writing operations. Any operations on this will transformed to operations on VAR following the "absolute" rules.
VAR
- an integer variable.public static RealVar real(IntVar VAR, double PRECISION)
VAR
- an integer variablePRECISION
- used to evaluate the instantiation of the view.public static RealVar[] real(IntVar[] VARS, double PRECISION)
VARS
- array of integer variablesPRECISION
- used to evaluate the instantiation of each view.Copyright © 2015. All rights reserved.