Originally posted by: SystemAdmin
I am using CPLEX 12.3 on Windows XP to solve a set of LPs.
The attached file (myprob_0.lp) is a LP model whose coefficients c2 and c6 are zeros. I use CPXchgobj to change the coefficients. Below is the code that is used for this purpose:
double *obj_value =
new
double[5];
// Array of the new objective coefficients
int *obj_index =
new
int[5];
// Array of the indices of the new objective coefficients
for (j=0; j < 5; j++)
{ obj_value[j] = k(j); obj_index[j] = j;
} status = CPXchgobj (env, lp, 5, obj_index, obj_value);
if (status)
{ fprintf(stderr,
"Failed to change the objective coefficients.\n", status); system(
"pause");
} status = CPXwriteprob (env, lp,
"myprob_1.lp", NULL);
if (status)
{ fprintf(stderr,
"CPXwriteprob failed to write the LP Problem.\n", status); system(
"pause");
}
The array k of the new coefficients cj is (1.12 0.87 176 5 3.6). After applying the change, the new objective function is obj: 1.12 u1 + 0.87 u3 + 176 u4 + 5 u5 + 3.6 v1
The right coefficients are assigned to the wrong variables. This should be: obj: 1.12 u1 + 0.87 u2 + 176 u3 + 5 u4 + 3.6 u5
Is there any possible reason for this?
I appreciate your help.
Amar
#CPLEXOptimizers#DecisionOptimization