IBM ILOG Solver User's Manual > More on Modeling > Using the Distribute Constraint: Car Sequencing > Suggested answers > Exercise 3 |
Exercise 3 |
INDEX
![]() |
Modify the car sequencing problem. Assume that you have 20 cars to paint in 4 available colors: green, yellow, blue, and white. Due to technical limitations on the assembly line, no more than 6 cars can be painted green, exactly 5 cars must be painted yellow, no more than 7 cars can be painted blue, and no less than 5 cars and no more than 12 cars can be painted white. The first car off the assembly line cannot be painted green.
The code that has changed from carseq_basic.cpp
follows. You can view the complete program online in the file YourSolverHome/examples/src/carseq_basic_ex3.cpp
.
Add the fourth color to the array Names
:
const char* Names[] = {"green", "yellow", "blue", "white"}; |
The following code changes the number of cars and colors:
const IloInt nbCars = 20; const IloInt nbColors = 4; |
You modify the distribute constraint:
You should get the following results, though the information displayed by IloSolver::printInformation
will vary depending on platform, machine, configuration, and so on.
Feasible Solution Car 1 color: yellow Car 2 color: green Car 3 color: green Car 4 color: green Car 5 color: green Car 6 color: green Car 7 color: green Car 8 color: yellow Car 9 color: yellow Car 10 color: yellow Car 11 color: yellow Car 12 color: blue Car 13 color: blue Car 14 color: blue Car 15 color: blue Car 16 color: white Car 17 color: white Car 18 color: white Car 19 color: white Car 20 color: white Number of fails : 0 Number of choice points : 15 Number of variables : 25 Number of constraints : 2 Reversible stack (bytes) : 4044 Solver heap (bytes) : 12084 Solver global heap (bytes) : 4044 And stack (bytes) : 4044 Or stack (bytes) : 4044 Search Stack (bytes) : 4044 Constraint queue (bytes) : 11152 Total memory used (bytes) : 43456 Elapsed time since creation : 0.16
© Copyright IBM Corp. 1987, 2009. Legal terms. | PREVIOUS NEXT |