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

Function main

contribs/qecode/examples/network-pricing2.cpp:70–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70int main() {
71 int NCustomer = 2;
72 int NArc = 3;
73 int* c = new int[NCustomer*NArc]; // c[NArc*i + j] cost for ci to reach Aj
74 int* d = new int[NCustomer]; // demand for customer i
75 int* u = new int[NCustomer]; // max price for customer i
76 int max;
77
78 c[0*NArc+0] = 5; c[1*NArc+0] = 3;
79 c[0*NArc+1] = 4; c[1*NArc+1] = 6;
80 c[0*NArc+2] = 2; c[1*NArc+2] = 5;
81
82 d[0] = 10; d[1] = 7;
83 u[0] = 70; u[1] = 90;
84
85 max = 100;
86
87
88 IntArgs carg(NCustomer*NArc,c);
89 IntArgs darg(NCustomer,d);
90 IntArgs uarg(NCustomer,u);
91
92
93 bool q[] = {false,true,false};
94 int* nv = new int[3];
95 nv[0] = NArc;
96 nv[1] = 1;
97 nv[2] = 9;
98
99 Qcop problem(3,q,nv);
100 for (int i=0;i<NArc;i++)
101 problem.QIntVar(i,0,10); // t[i]
102 IntVarArgs branch1(NArc);
103 for (int i=0;i<NArc;i++)
104 branch1[i] = problem.var(i);
105 branch(*(problem.space()),branch1,INT_VAR_SIZE_MIN(),INT_VAL_MIN());
106 problem.nextScope();
107
108 problem.QIntVar(NArc,0,NCustomer-1); // k
109 IntVarArgs branch2(NArc+1);
110 for (int i=0;i<NArc+1;i++)
111 branch2[i] = problem.var(i);
112 branch(*(problem.space()),branch2,INT_VAR_SIZE_MIN(),INT_VAL_MIN());
113 problem.nextScope();
114
115 problem.QIntVar(NArc+1,0,NArc-1); // a
116 problem.QIntVar(NArc+2,0,max); // cost
117 problem.QIntVar(NArc+3,0,max); // Income
118 IntVar a(problem.var(NArc+1));
119 IntVar cost(problem.var(NArc+2));
120 IntVar income(problem.var(NArc+3));
121 problem.QIntVar(NArc+4,0,max);
122 problem.QIntVar(NArc+5,0,max);
123 problem.QIntVar(NArc+6,0,max);
124 problem.QIntVar(NArc+7,0,max);
125 problem.QIntVar(NArc+8,0,max);
126 problem.QIntVar(NArc+9,0,max);
127 IntVar aux1(problem.var(NArc+4)); // k* NArc + a

Callers

nothing calls this directly

Calls 15

INT_VAR_SIZE_MINFunction · 0.85
INT_VAL_MINFunction · 0.85
listAssignmentsFunction · 0.85
getExistentialMethod · 0.80
optimizeMethod · 0.80
getAggregateMethod · 0.80
printStrFunction · 0.70
branchFunction · 0.50
relFunction · 0.50
elementFunction · 0.50
multFunction · 0.50
QIntVarMethod · 0.45

Tested by

no test coverage detected