Originally posted by: mkmk
In the example lpex1.c, the constraints include all the decision variables
Maximize
obj: x1 + 2 x2 + 3 x3
Subject To
c1: - x1 + x2 + x3 <= 20
c2: x1 - 3 x2 + x3 <= 30
Bounds
0 <= x1 <= 40
When implementing populatebynonzero, it defines all the rowlist, collist, and vallist as following.
rowlist[0] = 0; collist[0] = 0; vallist[0] = -1.0;
rowlist[1] = 0; collist[1] = 1; vallist[1] = 1.0;
rowlist[2] = 0; collist[2] = 2; vallist[2] = 1.0;
rowlist[3] = 1; collist[3] = 0; vallist[3] = 1.0;
rowlist[4] = 1; collist[4] = 1; vallist[4] = -3.0;
rowlist[5] = 1; collist[5] = 2; vallist[5] = 1.0;
IF the equation is
Maximize
obj:
x1^2 + 2 x2 + 3 x3
Subject To
c1: x2 + x3 <= 20
c2: x1 - 3 x2 <= 30
Bounds
0 <= x1 <= 40
then how can I define rowlist, collist, and vallist?
can I just leave the non-included decision variables blank? or ignore them??
rowlist[0] = 0; collist[0] = 1; vallist[0] = 1.0;
rowlist[1] = 0; collist[1] = 2; vallist[1] = 1.0;
rowlist[2] = 1; collist[2] = 0; vallist[2] = 1.0;
rowlist[3] = 1; collist[3] = 1; vallist[3] = -3.0;
Thanks much for your help!!
#CPLEXOptimizers#DecisionOptimization