MCPcopy Create free account
hub / github.com/Gecode/gecode / Crew

Method Crew

examples/crew.cpp:96–129  ·  view source on GitHub ↗

The actual model

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

SET_VAR_NONEFunction · 0.85
SET_VAL_MIN_INCFunction · 0.85
relFunction · 0.50
cardinalityFunction · 0.50
branchFunction · 0.50
updateMethod · 0.45

Tested by

no test coverage detected