[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] Multiple LP problem solving
From: |
Dorian Tourin-Lebret |
Subject: |
Re: [Help-glpk] Multiple LP problem solving |
Date: |
Thu, 9 Jun 2011 09:10:35 +0200 |
2011/6/8 Andrew Makhorin
<address@hidden>
> I guess I have to define the objective z as z1, then add the
> constraints for z2..zN, right? Otherwise, I don't know how I could
> define an objective z without specifying the coefficients for each
> variable, i.e. the columns in GLPK.
>
> Am I right?
Not exactly. In my example I assumed that z1, z2, ... are variables that
appear in the left-hand sides of equality constraints that define the
objective linear forms. In principle, you don't need to introduce such
variables, i.e. you might use the following formulation (in MathProg
syntax):
var z;
s.t. z1: z >= a1 * x1 + b1 * x2 + ...
z2: z >= a2 * x1 + b2 * x2 + ...
z3: z >= a3 * x1 + b3 * x2 + ...
minimize obj: z;
See similar example models cf12a.mod and cf12b.mod included in the glpk
distribution.
Thank you!
One last thing: how do I get the optimal values of x1, x2, ..., xN if I don't declare them as part of the variable z? So far, I declared the constraint matrix with glp_set_row_XYZ() functions and glp_load_matrix(). However, in the examples, z is always defined by the columns so that coefficient are affected to every variable x1, x2, ..., xN (glp_get_col_XYZ). For instance, z = x1 + 10.x2 + 6.x3. Then you can retrieve the optimal values of x1, x2, x3.
In your example, you only define a variable z that you minimize, but apparently z does not include x1, x2, ..., xN. How can you retrieve x1, x2, xN??
I may misunderstand the way you wrote the example which is not in C code...
Dorian.