Originally posted by: SystemAdmin
[Carina said:]
Hello.
I have to solve a restricted master problem, but I cannot get the solution printed.
It has been recommended that I use the OPL cover function to this, but it wonôt work.
I have tried to include this cover function, but I don't know how it is done correct.
When I try to run the code below I get following message:
-------------------------------
Solution to master problem:
-------------------------------
Objective value: 428.0000
1. Dual costs: (0) : runtime error: uninitialized Constraint
//
// OPL Model: restrictet master problem
//
import int+ n;
import int+ ncols;
range rows 1..n;
range cols 1..ncols;
var int+ y[cols] in 0..1;
import int+ A;
import float cost;
constraint cover[rows];
constraint numveh;
minimize sum(j in cols)cost[j]*y[j]
subject to{
forall(i in rows){
sum(j in cols) A[i,j]*y[j]>=1;
numveh: sum(j in cols)y[j]<=3;<br /> }
};
/*----------------------------------------------------------
OPL script for solving the master problem of Exercise 3
-----------------------------------------------------------*/
float infty:=1000;
/*-----------------------------------------------------------/
Declaration of variables
-------------------------------------------------------------*/
int+ n:=10;
int+ ncols:=16;
range rows 1..n;
range cols 1..ncols;
int+ A[rows,cols]:=[[1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1],
[0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1],
[0,0,1,0,0,0,0,0,0,0,0,0,1,1,0,0],
[0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0],
[0,0,0,0,1,0,0,0,0,0,0,1,0,1,0,0],
[0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0],
[0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0],
[0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1],
[0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1]];
float+ cost[cols]:=[82,44,100,84,44,102,102,64,72,122,137,143,104,130,148,150];
/*-----------------------------------------------------------
Begin of the main procedure
-------------------------------------------------------------*/
int i;
int j;
float obj;
Model master("master.mod") editMode;
obj:=0;
/* Solve master problem */
master.solve();
cout << "-------------------------------" << endl;<br />cout << "Solution to master problem:" << endl;<br />cout << "-------------------------------" << endl;<br />
forall ( j in cols )
obj := obj + cost[j]*master.y[j];
cout << "Objective value: "<< obj <<endl;<br />forall (i in rows){
cout << i << ". Dual costs: " << master.cover[i].dual<<endl;<br />
}
Can you help me?
#DecisionOptimization#OPLusingCPLEXOptimizer