• Gurobi Staff

I'm not sure I understand your question well. Can you provide an example of a string that you want to convert into a linear expression?

Thank you for your reply, I have an old work with lp_solve, and I want to use gurobi API C++ : all my constraints written as string to a file, so I am looking for putting my string constraints equations to the model.

I try to do somthing like that (put a string to constraint) :

sprintf(Constraint1, "x%d + %d r%d - %d r%d - x%d - %d p%d%d - %d q%d%d <= - %d\n", i, hi, i, wi, i, j, M, i, j, M, i, j, wi);

My Old code :

------------------------------------------------

for (int i = 1; i <= block_list->size(); i++) {
for (int j = i + 1; j <= block_list->size(); j++) {
hi = block_list->at(i - 1)->height;
hj = block_list->at(j - 1)->height;
wi = block_list->at(i - 1)->width;
wj = block_list->at(j - 1)->width;
fprintf(f, "c%d: x%d + %d r%d - %d r%d - x%d - %d p%d%d - %d q%d%d <= - %d\n", eq++, i, hi, i, wi, i, j, M, i, j, M, i, j, wi);
fprintf(f, "c%d: y%d + %d r%d - %d r%d - y%d - %d p%d%d + %d q%d%d <= + %d\n", eq++, i, wi, i, hi, i, j, M, i, j, M, i, j, M-hi);
fprintf(f, "c%d: x%d - %d r%d + %d r%d - x%d - %d p%d%d + %d q%d%d >= - %d\n ", eq++, i, hj, j, wj, j, j, M, i, j, M, i, j,M-wj);
fprintf(f, "c%d: y%d - %d r%d + %d r%d - y%d - %d p%d%d - %d q%d%d >= - %d\n", eq++, i, wj, j, hj, j, j, M, i, j, M, i, j,(2 * M)-hj);
//fprintf(f, "\n");
}
}