The actual model
| 94 | |
| 95 | /// The actual model |
| 96 | Crew(const Options& opt) |
| 97 | : Script(opt), flight(*this,noOfFlights,IntSet::empty,0,noOfEmployees-1) { |
| 98 | IntSet stewardsDS(stewards,noOfStewards); |
| 99 | IntSet hostessesDS(hostesses,noOfHostesses); |
| 100 | IntSet spanishDS(spanishSpeaking, noOfSpanishSpeaking); |
| 101 | IntSet frenchDS(frenchSpeaking, noOfFrenchSpeaking); |
| 102 | IntSet germanDS(germanSpeaking, noOfGermanSpeaking); |
| 103 | |
| 104 | for (int i=0; i<noOfFlights; i++) { |
| 105 | // The flight has staff as required by the specification |
| 106 | rel(*this, cardinality(flight[i]) == requiredCrew[i].staff); |
| 107 | |
| 108 | // Enough members of different categories are on board |
| 109 | rel(*this, cardinality(flight[i] & stewardsDS) >= |
| 110 | requiredCrew[i].stewards); |
| 111 | rel(*this, cardinality(flight[i] & hostessesDS) >= |
| 112 | requiredCrew[i].hostesses); |
| 113 | rel(*this, cardinality(flight[i] & spanishDS) >= |
| 114 | requiredCrew[i].spanish); |
| 115 | rel(*this, cardinality(flight[i] & frenchDS) >= |
| 116 | requiredCrew[i].french); |
| 117 | rel(*this, cardinality(flight[i] & germanDS) >= |
| 118 | requiredCrew[i].german); |
| 119 | } |
| 120 | |
| 121 | // No crew member of flight i works on flights i+1 and i+2 |
| 122 | for (int i=0; i<noOfFlights-2; i++) { |
| 123 | rel(*this, flight[i] || flight[i+1]); |
| 124 | rel(*this, flight[i] || flight[i+2]); |
| 125 | } |
| 126 | rel(*this, flight[noOfFlights-2] || flight[noOfFlights-1]); |
| 127 | |
| 128 | branch(*this, flight, SET_VAR_NONE(), SET_VAL_MIN_INC()); |
| 129 | } |
| 130 | |
| 131 | /// Print solution |
| 132 | virtual void |
nothing calls this directly
no test coverage detected