I'm using Windows 7 and Eclipse IDE to code the problems and solve them in
Java.
>From further testing, it seems as though the error arrises around the
150,000th constraint. I know that this is still a trivial size problem as
it is just an LP problem. The following code is the developer of the
constraints that it seems to crash after 150,000 constraints. I had
originally split the two versions of the constraint set apart, but put them
together so that I only have to loop through the matrix once instead of
twice.
private void developMinusConstraintsMax(double[][] matrix) {
for(int i=1; i <= matrix.length; i++) {
for(int k=i+1; k <= matrix.length; k++) {
GLPK.glp_add_rows(_lp, 2);
int numRow = GLPK.glp_get_num_rows(_lp)-1;
GLPK.glp_set_row_name(_lp, numRow, "W[" + (i-1) + "-" + (k-1) + "]");
GLPK.glp_set_row_bnds(_lp, numRow, GLPKConstants.GLP_UP, 0.0, 0.0);
SWIGTYPE_p_int ind = GLPK.new_intArray(4);
GLPK.intArray_setitem(ind, 1, i);
GLPK.intArray_setitem(ind, 2, k);
GLPK.intArray_setitem(ind, 3, GLPK.glp_get_num_cols(_lp));
double ratioCoefficient = ((matrix[i-1][_j]) / (matrix[k-1][_j]));
SWIGTYPE_p_double val = GLPK.new_doubleArray(4);
GLPK.doubleArray_setitem(val, 1, 1.0);
GLPK.doubleArray_setitem(val, 2, ratioCoefficient);
GLPK.doubleArray_setitem(val, 3, -1.0);
GLPK.glp_set_mat_row(_lp, numRow, 3, ind, val);
GLPK.delete_intArray(ind);
GLPK.delete_doubleArray(val);
System.out.println("W[" + (i-1) + "-" + (k-1) + "] added.");
numRow = GLPK.glp_get_num_rows(_lp);
GLPK.glp_set_row_name(_lp, numRow, "W[" + (k-1) + "-" + (i-1) + "]");
GLPK.glp_set_row_bnds(_lp, numRow, GLPKConstants.GLP_UP, 0.0, 0.0);
ind = GLPK.new_intArray(4);
GLPK.intArray_setitem(ind, 1, k);
GLPK.intArray_setitem(ind, 2, i);
GLPK.intArray_setitem(ind, 3, GLPK.glp_get_num_cols(_lp));
val = GLPK.new_doubleArray(4);
GLPK.doubleArray_setitem(val, 1, ratioCoefficient);
GLPK.doubleArray_setitem(val, 2, 1.0);
GLPK.doubleArray_setitem(val, 3, -1.0);
GLPK.glp_set_mat_row(_lp, numRow, 3, ind, val);
GLPK.delete_intArray(ind);
GLPK.delete_doubleArray(val);
System.out.println("W[" + (k-1) + "-" + (i-1) + "] added.");
}
}
}
--David
_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk