Overview | Group | Tree | Graph | Index | Concepts |
These functions create and return a constraint that forces the variable unionset
to be equal to the union of the values returned by the function F
when applied to the
elements of the constrained set variable set
.
Adding These Constraints
You may add these constraints only during a Solver search; that is, inside a goal (an instance of
IlcGoal
) or inside a constraint (an instance of
IlcConstraint
). If you are looking for similar functionality
in a constraint to add to a model, see IloEqUnion
.
Example
It can be useful to constrain the values of an attribute of a computed set of objects.
For example, if we have to assign crew members to a flight, and if each crew member has an
attribute that describes the language he or she speaks, with this IlcEqUnion
constraint, it is possible to post constraints on the set of languages that must be spoken
during a flight.
enum Language {English, French, German}; class CrewMember { public: const char* _name; IlcInt _language; CrewMember(IloSolver s, const char* name, Language lang); }; //Access to the language spoken by a crew member IlcAnyToIntFunction languages; //Possible crew members IlcAnyArray c(s, 3); c[0]= new (s.getHeap()) CrewMember(s, "John", English); c[1]= new (s.getHeap()) CrewMember(s, "Kai", German); c[2]= new (s.getHeap()) CrewMember(s, "Julie", French); //The flight IlcAnySetVar crew(s, c, "NewYork-Paris"); //The languages spoken on this flight IlcIntSetVar langs(s, IlcIntArray(s, 3, English, French, German));
Now that we have defined the classes and constraints, we add them during a Solver search, for example, inside a goal or constraint.
s.add(IlcEqUnion(langs, crew, languages)); //At least 2 different languages spoken s.add(IlcCard(langs) >= 2); //French must be spoken s.add(IlcMember(French, langs));
See Also:
IlcAnySetVar, IlcIntSetVar, IlcUnion, IloEqUnion
These functions create and return a constraint that forces the variable unionset
to be equal to the union of the values returned by the function F
when applied to the
elements of the constrained set variable set
. The values returned by F
are
constrained expressions or variables (that is, instances of IlcIntExp
, IlcIntVar
,
IlcAnyExp
, or IlcAnyVar
).
Adding These Constraints
You may add these constraints only during a Solver search; that is, inside a goal (an instance of
IlcGoal
) or inside a constraint (an instance of
IlcConstraint
). If you are looking for similar functionality in a
constraint to add to a model, see IloEqUnion
.
Example
These IlcEqUnion
constraints can be useful to express constraints on the values
of a constrained attribute of a computed set of objects. For example, if we have to connect cards
to a rack, and if for each card we also have to connect one sensor, it is possible to express
constraints on the set of sensors connected to the cards in the rack. To do so, we define the following classes.
class Sensor { public: const char* _name; Sensor(IloSolver s, const char* name); }; class Card { public: IlcAnyVar _sensor; Card(IloSolver s, IlcAnyArray sensors) :_sensor(s, sensors) {} }; //Access to the sensor connected to a card IlcAnyToAnyExpFunction sensorsAccess; //The possible sensors IlcAnyArray sensors(s, 4); sensors[0] = new (s.getHeap()) Sensor(s, "Sensor#0"); sensors[1] = new (s.getHeap()) Sensor(s, "Sensor#1"); sensors[2] = new (s.getHeap()) Sensor(s, "Sensor#2"); sensors[3] = new (s.getHeap()) Sensor(s, "Sensor#3"); //The possible cards IlcAnyArray cards(s, 3); cards[0] = new (s.getHeap()) Card(s, sensors); cards[1] = new (s.getHeap()) Card(s, sensors); cards[2] = new (s.getHeap()) Card(s, sensors); //The cards connected to the rack IlcAnySetVar rackCards(s, cards, "Rack#1"); //The sensors connected to the rack IlcAnySetVar rackSensors(s, sensors);
Now that we have defined the classes and constraints, we add them during a Solver search, for example, inside a goal or constraint.
s.add(IlcEqUnion(rackSensors, rackCards, sensorAccess)); //At most 10 sensors in the rack s.add(IlcCard(rackSensors) <= 10); //sensor#1 in a card of the rack s.add(IlcMember(sensors[1], rackSensors));
Of course it is possible to compose several levels of indirection. For example, we can post constraints on the processes assigned to the sensors which are connected to the cards that are plugged into a rack:
s.add(IlcEqUnion(rackSensors, rackCards, sensorAccess)); s.add(IlcEqUnion(rackProcesses, rackSensors, processAccess));
See Also:
IlcAnySetVar, IlcIntSetVar, IlcUnion, IloEqUnion
These functions create and return a constraint that forces the value of unionset
to be equal to the union of its other parameters (that is, the union of the set variables
var1
and var2
or the union of the set variables in the array
vars
). The variable unionset
and all the variables in vars
must be built from the same initial array.
When you pass this function the optional parameter intersection
, you enable Solver
to propagate at a stronger filter level. It takes into account the fact that the cardinality of
the unionset
is equal to the cardinality of var1
plus the cardinality
of var2
minus the cardinality of their intersection
.
When you pass this function the optional parameter level
, it computes the intersection
of var1
and var2
internally and uses that information to extend the filter
level during propagation. See the enumeration IlcFilterLevel
for more
details about its use.
Adding These Constraints
You may add these constraints only during a Solver search; that is, inside a goal (an instance of
IlcGoal
) or inside a constraint (an instance of
IlcConstraint
). If you are looking for similar functionality in a
constraint to add to a model, see IloEqUnion
documented in the IBM ILOG
Concert Technology Reference Manual.
See Also:
IlcAnySetVar, IlcAnySetVarArray, IlcConstraint, IlcFilterLevel, IlcIntSetVar, IlcIntSetVarArray, IlcUnion
These functions create and return a constraint that forces the variable unionset
to be
equal to the union of the values returned by the function F
when applied to the elements
of the constrained set variable set
. The values returned by F
are constrained
set variables (that is, instances of IlcInt
SetVar or IlcAny
SetVar).
Adding These Constraints
You may add these constraints only during a Solver search; that is, inside a goal (an instance of
IlcGoal
) or inside a constraint (an instance of
IlcConstraint
). If you are looking for similar functionality in a
constraint to add to a model, see IloEqUnion
.
Example
These IlcEqUnion
constraints can be useful to express constraints on the values of a
constrained set attribute of a computed set of objects. For example, if we have to connect cards to a
rack, and if for each card we also have to connect a set of sensors, it is possible to express constraints
on the set of sensors connected to the cards in the rack.
class Sensor { public: const char* _name; Sensor(IloSolver s, const char* name); }; class Card { public: IlcAnySetVar _sensor; Card(IloSolver s, IlcAnyArray sensors) :_sensor(s, sensors) {} }; //Access to the sensor connected to a card IlcAnyToAnySetVarFunction sensorsAccess; //The possible sensors IlcAnyArray sensors(s, 4); sensors[0] = new (s.getHeap()) Sensor(s, "Sensor#0"); sensors[1] = new (s.getHeap()) Sensor(s, "Sensor#1"); sensors[2] = new (s.getHeap()) Sensor(s, "Sensor#2"); sensors[3] = new (s.getHeap()) Sensor(s, "Sensor#3"); //The possible cards IlcAnyArray cards(s, 3); cards[0] = new (s.getHeap()) Card(s, sensors); cards[1] = new (s.getHeap()) Card(s, sensors); cards[2] = new (s.getHeap()) Card(s, sensors); //The cards connected to the rack IlcAnySetVar rackCards(s, cards, "Rack#1"); //The sensors connected to the rack IlcAnySetVar rackSensors(s, sensors);
Now that we have defined these classes and constraints, we add them during a Solver search, for example, inside a goal or constraint.
s.add(IlcEqUnion(rackSensors, rackCards, sensorAccess)); //At most 10 sensors in the rack s.add(IlcCard(rackSensors) <= 10); //sensor#1 in a card of the rack s.add(IlcMember(sensors[1], rackSensors));
Of course it is possible to compose several levels of indirection. For example, we can access the processes assigned to the sensors which are connected to the cards that are plugged into a rack:
s.add(IlcEqUnion(rackSensors, rackCards, sensorAccess)); s.add(IlcEqUnion(rackProcesses, rackSensors, processAccess));
See Also:
IlcAnySetVar, IlcIntSetVar, IlcUnion, IloEqUnion