<div> </div>
<div>I have written the following small prograg to solve GAP on size (3, 10)</div>
<div> </div>
<div> 1 // $Id$<br> 2 #include "flopc.hpp"<br> 3 using namespace flopc;<br> 4 #include "OsiCbcSolverInterface.hpp"<br> 5<br> 6 /* Generalized Assignment Problem */<br> 7
<br> 8 class Gap : public MP_model {<br> 9 public:<br> 10 MP_set M,N;<br> 11 MP_data c;<br> 12 MP_data a;<br> 13 MP_data b;<br> 14 MP_variable x;<br> 15 MP_constraint cap, feas;
<br> 16<br> 17 Gap(int numM, int numN) : MP_model(new OsiCbcSolverInterface),<br> 18 M(numM), N(numN),<br> 19 c(M,N), a(M,N), b(M),<br> 20 x(M,N),<br> 21 cap(M), feas(N)<br> 22 {<br>
23 x.binary();<br> 24 cap(M) = sum(N, a(M,N)*x(M,N)) <= b(M);<br> 25 feas(N).<strong>such_that(N < N.size())</strong> = sum(M, x(M,N)) == 1;<br> 26 add(cap); add(feas);<br> 27 setObjective( sum(M*N, c(M,N)*x(M,N)));
<br> 28 }<br> 29 };<br> 30<br> 31 int main() {<br> 32 double cost[3][11] = {{47,16,27,21,25,12,55,31,40,40,1000},<br> 33 {45,18,56,33,36,46,11,17,31,50,1000},<br> 34 {50,23,22,59,31,35,40,41,40,11,1000}};
<br> 35<br> 36 double req[3][11] = {{24,12,8,12,16,14,13,15,23,5,100},<br> 37 {7,17,8,5,6,19,20,7,22,9,100},<br> 38 {23,18,14,8,18,23,19,11,15,11,100}};
<br> 39<br> 40 double capc[3] = {37,32,42};<br> 41<br> 42 Gap instance(3,11);<br> 43<br> 44 instance.c.value(&cost[0][0]);<br> 45 instance.a.value(&req[0][0]);<br> 46
instance.b.value(&capc[0]);<br> 47<br> 48 instance.minimize();<br> 49<br> 50 cout<<"numRow:="<<instance->getNumRows()<<"\n";<br> 51 cout<<"numCols:="<<instance->getNumCols()<<"\n";
<br> 52 cout<<"numEle:="<<instance->getNumElements()<<"\n";<br> 53 cout<<"obj:="<<instance->getObjValue()<<"\n";<br> 54
instance.x.display("Solution of first instance (x)");<br> 55 }<br> </div>
<div> To learn how the such_that statement works, I introduced the 11th job with very high cost of assignment and infeasible</div>
<div>requirement on any of the machines...to prevent infeasibility I write the "feas" constraints using such_that statement so </div>
<div>that 11th job doesn't have to be assigned....but I am not able to see whats wrong with the code that it doesn't work.</div>
<div>Any help on this is much appreciated..</div>
<div> </div>
<div>regards,</div>
<div>vishy</div>
<div> </div>