50 Tom, David, Jeremy, Ron,
54 Marilyn, Carolyn, Cathy,
55 Inez, Jean, Heather, Juliet
57 const int noOfEmployees = Juliet+1;
69 const char* employeeToName(
Employee e);
70 extern const int stewards[];
71 extern const int noOfStewards;
72 extern const int hostesses[];
73 extern const int noOfHostesses;
74 extern const int spanishSpeaking[];
75 extern const int noOfSpanishSpeaking;
76 extern const int frenchSpeaking[];
77 extern const int noOfFrenchSpeaking;
78 extern const int germanSpeaking[];
79 extern const int noOfGermanSpeaking;
80 extern const Flight requiredCrew[];
81 extern const int noOfFlights;
101 flight(*this,noOfFlights,
IntSet::empty,0,noOfEmployees-1)
103 IntSet stewardsDS(stewards,noOfStewards);
104 IntSet hostessesDS(hostesses,noOfHostesses);
105 IntSet spanishDS(spanishSpeaking, noOfSpanishSpeaking);
106 IntSet frenchDS(frenchSpeaking, noOfFrenchSpeaking);
107 IntSet germanDS(germanSpeaking, noOfGermanSpeaking);
109 for (
int i=0;
i<noOfFlights;
i++) {
115 requiredCrew[i].stewards);
117 requiredCrew[i].hostesses);
119 requiredCrew[i].spanish);
121 requiredCrew[i].french);
123 requiredCrew[i].german);
127 for (
int i=0;
i<noOfFlights-2;
i++) {
128 rel(*
this, flight[
i] || flight[
i+1]);
129 rel(*
this, flight[
i] || flight[
i+2]);
131 rel(*
this, flight[noOfFlights-2] || flight[noOfFlights-1]);
139 for (
int i=0;
i<noOfFlights;
i++) {
140 os <<
"\tFlight " <<
i+1 <<
":" << std::endl;
141 os <<
"\t\tCrew\tStew.\tHost.\tFrench\tSpanish\tGerman"
142 << std::endl <<
"\t";
143 os <<
"\t" << requiredCrew[
i].staff <<
"\t" << requiredCrew[
i].stewards
144 <<
"\t" << requiredCrew[
i].hostesses <<
"\t"
145 << requiredCrew[
i].spanish
146 <<
"\t" << requiredCrew[
i].french <<
"\t" << requiredCrew[
i].german
149 os <<
"\t\tSchedule:" << std::endl <<
"\t\t";
152 os << employeeToName(static_cast<Employee>(
d.val())) <<
" ";
155 os <<
"\tRequired: ";
157 os << employeeToName(static_cast<Employee>(
d.val())) <<
" ";
159 os << std::endl <<
"\t\t\tPossible: ";
161 os << employeeToName(static_cast<Employee>(
d.val())) <<
" ";
164 os << std::endl << std::endl;
176 return new Crew(share,*
this);
189 Script::run<Crew,DFS,Options>(o);
199 case Tom :
return "Tom";
200 case David :
return "David";
201 case Jeremy:
return "Jeremy";
202 case Ron:
return "Ron";
203 case Joe:
return "Joe";
204 case Bill:
return "Bill";
205 case Fred:
return "Fred";
206 case Bob:
return "Bob";
207 case Mario:
return "Mario";
208 case Ed:
return "Ed";
209 case Carol:
return "Carol";
210 case Janet:
return "Janet";
211 case Tracy:
return "Tracy";
212 case Marilyn:
return "Marilyn";
213 case Carolyn:
return "Carolyn";
214 case Cathy:
return "Cathy";
215 case Inez:
return "Inez";
216 case Jean:
return "Jean";
217 case Heather:
return "Heather";
218 case Juliet:
return "Juliet";
225 const int stewards[] =
226 {Tom, David, Jeremy, Ron, Joe, Bill, Fred, Bob, Mario, Ed};
228 const int noOfStewards =
sizeof(stewards) /
sizeof(
int);
230 const int hostesses[] =
231 { Carol, Janet, Tracy, Marilyn, Carolyn, Cathy, Inez,
232 Jean, Heather, Juliet };
234 const int noOfHostesses =
sizeof(hostesses) /
sizeof(
int);
236 const int frenchSpeaking[] =
237 { Bill, Inez, Jean, Juliet };
239 const int noOfFrenchSpeaking =
sizeof(frenchSpeaking) /
sizeof(
int);
241 const int germanSpeaking[] =
242 { Tom, Jeremy, Mario, Cathy, Juliet };
244 const int noOfGermanSpeaking =
sizeof(germanSpeaking) /
sizeof(
int);
246 const int spanishSpeaking[] =
247 { Joe, Bill, Fred, Mario, Marilyn, Inez, Heather };
249 const int noOfSpanishSpeaking =
sizeof(spanishSpeaking) /
sizeof(
int);
252 const Flight requiredCrew[] =
265 const int noOfFlights =
sizeof(requiredCrew) /
sizeof(Flight);
virtual Space * copy(bool share)
Copy during cloning.
SetVarBranch SET_VAR_NONE(void)
Select first unassigned variable.
SetVarArray flight
The crew for each flight.
virtual void print(std::ostream &os) const
Print solution.
SetValBranch SET_VAL_MIN_INC(void)
Include smallest element.
Example: Airline crew allocation
Parametric base-class for scripts.
void iterations(unsigned int i)
Set default number of iterations.
Employee
The airline employees.
int main(int argc, char *argv[])
Main-function.
Iterator for the values in the unknown set of a set variable.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
Gecode::IntArgs i(4, 1, 2, 3, 4)
LinIntExpr cardinality(const SetExpr &e)
Cardinality of set expression.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
bool assigned(View x, int v)
Whether x is assigned to value v.
Iterator for the values in the greatest lower bound of a set variable.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Crew(bool share, Crew &s)
Constructor for cloning s.
Gecode toplevel namespace
BrancherHandle branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf, FloatVarValPrint vvp)
Branch over x with variable selection vars and value selection vals.
Crew(const Options &)
The actual model.
#define GECODE_NEVER
Assert that this command is never executed.