[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: [Help-glpk] formulation of a problem

**From**: |
Andrew Makhorin |

**Subject**: |
Re: [Help-glpk] formulation of a problem |

**Date**: |
Thu, 22 Jun 2006 16:43:33 +0400 |

>* I'm in trouble with set in a problem in the glpk datastructure and I*
>* can't find answers to my questions (perhaps I looked at the wrong *
>* places).*
>* The two main problems:*
>* 1. How can I set a variable to the right hand side?*
>* If I have a constraint like this: x1+x2 <= y1 I can't set:*
>* *
>* lpx_set_row_name(lp, 3, "constraint");*
>* lpx_set_row_bnds(lp, 3, LPX_UP, 0, y1);*
You should write all your constraint in a standard form:
a[i,1]*x[1] + ... + a[i,n]*x[n] <rho> b[i]
where <rho> is '=', '<=', or '>='.
In your case:
x1 + x2 - y1 <= 0
i.e. the right-hand size must be a constant, not a variable.
>* *
>* 2. How can I set 'holes' in the matrix (if a variable is not needed *
>* in one constraint)?*
>* *
>* For instance:*
>* x1+x2 = 3*
>* x1 <= 1*
>* *
>* then I would think the array assignments looks like that:*
>* *
>* ia[1] = 1, ja[1] = 1, ar[1] = 1.0;*
>* ia[2] = 1, ja[2] = 2, ar[2] = 1.0;*
>* ia[3] = 2, ja[3] = 1, ar[3] = 1.0;*
>* ia[4] = 2, ja[4] = 2, ar[4] = 0; // <- it doesn't work*
>* *
>* (a similar problem: if I don't need a basic variable in the minimize *
>* or maximize funktion, can I set the the coefficient to zero? like: *
>* lpx_set_obj_coef(lp,1,0.0); )*
You should omit all zero constraint coefficients.
If it is inconvenient, fill the matrix as is and then use the routine
lpx_remove_tiny to remove zero entries (it is not doc'ed, so see its
description in file glplpx7a.c).