IBM ILOG Solver User's Manual > More on Modeling > Using Set Variables: Crew Scheduling > Suggested answers > Exercise 3 |
Exercise 3 |
INDEX
![]() |
Using the crews example as a starting point, extend the example to deal with a new crew requirement. Each flight crew must have at least one Italian speaker, except for Flight #4, which must have at least two Italian speakers. The following flight attendants speak Italian: Bob, Carol, Janet, Marilyn, and Tracy.
The code that has changed from crews.cpp
follows. You can view the complete program online in the file YourSolverHome/examples/src/crews_ex3.cpp
.
You change the number of attributes:
const IloInt nAttributes = 6; |
You create an array of Italian speakers:
IloNumArray ItalianArray(env, 5, Bob, Carol, Janet, Marilyn, Tracy); |
You add an element to dataArrays
:
dataArrays[5] = ItalianArray; |
You create an Italian
set of variables:
IloNumSetVar Italian(env, ItalianArray, ItalianArray); |
You add this set of variables to the array of sets of variables and add the requirement that a default flight has one Italian speaker:
You add the requirements that Flight #4 have two Italian speakers:
crewRequirements[3][ItalianSet] = 2; |
You should get the following results, though the information displayed by IloSolver::printInformation
will vary depending on platform, machine, configuration, and so on.
© Copyright IBM Corp. 1987, 2009. Legal terms. | PREVIOUS NEXT |