38 using namespace Gecode;
99 template<
class Script>
118 element(*
this, open, supplier[s], 1);
175 os <<
"\tSupplier: " << supplier << std::endl
176 <<
"\tOpen warehouses: " << open << std::endl
177 <<
"\tStore cost: " << c_store << std::endl
178 <<
"\tTotal cost: " << c_total << std::endl
196 c_open =
expr(*
this,
sum(open));
197 c_stores =
expr(*
this,
sum(c_store));
201 return {c_open, c_stores};
216 os <<
"\tSupplier: " << supplier << std::endl
217 <<
"\tOpen warehouses: " << open << std::endl
218 <<
"\tOpen cost: " << c_open << std::endl
219 <<
"\tStores cost: " << c_stores << std::endl
238 IntMinimizeScript::run<SumCostWarehouses,BAB,Options>(
opt);
241 IntLexMinimizeScript::run<LexCostWarehouses,BAB,Options>(
opt);
BoolVar expr(Home home, const BoolExpr &e, const IntPropLevels &ipls)
Post Boolean expression and return its value.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
Parametric base-class for scripts.
Passing integer arguments.
Passing integer variables.
void iterations(unsigned int i)
Set default number of iterations.
void solutions(unsigned int n)
Set default number of solutions to search for.
void model(int v)
Set default model value.
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
void update(Space &home, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
Model with cost defined lexicographically.
IntVar c_open
Cost for open warehouses.
virtual IntVarArgs cost(void) const
Return solution cost.
IntVar c_stores
Cost for stores.
virtual Space * copy(void)
Copy during cloning.
virtual void print(std::ostream &os) const
Print solution.
LexCostWarehouses(const Options &opt)
Actual model.
LexCostWarehouses(LexCostWarehouses &s)
Constructor for cloning s.
Model with cost defined as sum.
IntVar c_total
Total cost.
virtual Space * copy(void)
Copy during cloning.
virtual void print(std::ostream &os) const
Print solution.
virtual IntVar cost(void) const
Return solution cost.
SumCostWarehouses(SumCostWarehouses &s)
Constructor for cloning s.
SumCostWarehouses(const Options &opt)
Actual model.
Example: Locating warehouses
IntVarArray supplier
Which warehouse supplies a store.
int main(int argc, char *argv[])
Main-function.
BoolVarArray open
Is a warehouse open (warehouse needed)
IntVarArray c_store
Cost of a store.
Warehouses(Warehouses &s)
Constructor for cloning s.
Warehouses(const Options &opt)
Actual model.
const int n_stores
Number of stores.
const int c_fixed
Fixed cost for one warehouse.
@ MODEL_LEXCOST
Use lexicographic cost.
@ MODEL_SUMCOST
Use sum as total cost.
const int c_supply[n_stores][n_warehouses]
Cost for supply a store by a warehouse.
const int n_warehouses
Number of warehouses.
const int capacity[n_warehouses]
Capacity of a single warehouse.
LinFloatExpr sum(const FloatVarArgs &x)
Construct linear float expression as sum of float variables.
void count(Home home, const IntVarArgs &x, int n, IntRelType irt, int m, IntPropLevel)
Post propagator for .
void element(Home home, IntSharedArray c, IntVar x0, IntVar x1, IntPropLevel)
Post domain consistent propagator for .
@ IPL_DOM
Domain propagation Options: basic versus advanced propagation.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
IntVarBranch INT_VAR_REGRET_MIN_MAX(BranchTbl tbl)
Select variable with largest min-regret.
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
Gecode::FloatVal c(-8, 8)