IBM ILOG Solver User's Manual > More on Modeling > Using Set Variables: Crew Scheduling > Suggested answers > Exercise 4

Using the original crews example as a starting point, extend the example by adding five more flights with the crew requirements as shown in Table 7.3.

Suggested Answer

The code that has changed from crews.cpp follows. You can view the complete program online in the file YourSolverHome/examples/src/crews_ex4.cpp.

You change the number of crews:

    const IloInt nCrews = 15;

You specify the crew size of the additional flights:

    IloNumArray crewSize(env, nCrews, 4, 5, 5, 6, 7, 4, 5, 6,
                                      6, 7, 4, 4, 7, 4, 5);

You specify specific crew requirements for the additional flights:

      crewRequirements[12][SeniorSet] = 2;
      crewRequirements[12][JuniorSet] = 3;
      crewRequirements[12][FrenchSet] = 2;
      crewRequirements[12][GermanSet] = 2;
      crewRequirements[12][SpanishSet] = 2;
      crewRequirements[14][SeniorSet] = 2;
      crewRequirements[14][FrenchSet] = 2;
      crewRequirements[14][SpanishSet] = 2;

You should get the following results, though the information displayed by IloSolver::printInformation will vary depending on platform, machine, configuration, and so on.

Solution
Crew #1: Bill Bob Carol Cathy
Crew #2: Carolyn David Ed Fred Juliet
Crew #3: Heather Inez Janet Jeremy Joe
Crew #4: Bill Bob Carol Cathy Jean Marilyn
Crew #5: Carolyn David Ed Fred Juliet Mario Ron
Crew #6: Heather Inez Janet Jeremy
Crew #7: Bill Bob Carol Cathy Jean
Crew #8: Carolyn David Ed Fred Joe Juliet
Crew #9: Heather Inez Janet Jeremy Marilyn Mario
Crew #10: Bill Bob Carol Cathy Jean Ron Tom
Crew #11: Carolyn David Fred Juliet
Crew #12: Ed Heather Inez Jeremy
Crew #13: Bill Bob Carol Cathy Jean Joe Mario
Crew #14: Carolyn David Fred Juliet
Crew #15: Ed Inez Jeremy Marilyn Ron
Number of fails               : 21
Number of choice points       : 89
Number of variables           : 190
Number of constraints         : 347
Reversible stack (bytes)      : 28164
Solver heap (bytes)           : 164844
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)     : 220336
Elapsed time since creation   : 0.08