Overview | Group | Tree | Graph | Index | Concepts |
These functions create and return a new set variable that represents 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 Constrained Variables
You may add these constrained variables 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 IlcUnion
functions 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 that are connected to the cards in the rack.
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(m, 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 = IlcUnion(rackCards, sensorAccess);
Here is how we add these constrained variables inside a constraint:
//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:
IlcUnion(IlcUnion(rackCards, sensorAccess), processAccess);
See Also:
IlcAnySetVar, IlcEqUnion, IlcIntSetVar, IloEqUnion
These functions create and return a new set variable that represents 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
(IlcIntSetVar
, IlcAnySetVar
). These IlcUnion
functions
can be useful to express constraints on the values of a constrained set attribute of a computed
set of objects.
Adding These Constrained Variables
You may add these constrained variables 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
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 that are connected to the cards in the rack.
class Sensor { public: const char* _name; Sensor(IloSolver s, const char* name); }; class Card { public: IlcAnySetVar _sensors; Card(IloSolver s, IlcAnyArray sensors) :_sensors(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 = IlcUnion(rackCards, sensorAccess);
Here is how we add these constrained variables inside a constraint:
//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:
IlcUnion(IlcUnion(rackCards, sensorAccess), processAccess);
See Also:
IloEqUnion, IlcAnySetVar, IlcEqUnion, IlcIntSetVar
These functions create and return a new set variable that represents the union of the values returned
by the function F
when applied to the elements of the constrained set variable set
.
These functions can be useful to get and constrain the values of an attribute of a computed set of objects.
Adding These Constrained Variables
You may add these constrained variables 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.
Example
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 IlcUnion
expression,
it is possible to post constraints on the set of languages that must be spoken for the flight, like this:
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 = IlcUnion(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, IlcEqUnion, IlcIntSetVar
These functions:
var1
and
var2
. The parameters
var1
and
var2
must be built on the same initial array.
vars
. All the variables in
vars
must be built on the same initial array.Adding These Constrained Variables
You may add these constrained variables 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, IlcCard, IlcEqUnion, IlcIntSetVar, IlcIntSetVarArray