[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] Calculated Variables in glpsol
From: |
Andrew Makhorin |
Subject: |
Re: [Help-glpk] Calculated Variables in glpsol |
Date: |
Thu, 27 May 2010 00:49:13 +0400 |
> I #8217;m trying to figure out a way to calculate variables
> in my .mod file.
> For example, say I have
> Var x
> Var y
> Param a
> Param b
> Max: a*x + b*y
> I want to replace this with something like
> Var x
> Var y
> Param a
> Param b
> Var x_a = x*a
> Var y_b = y*b
> Max: x_a + y_b.
> The reason for this is so that I have x_a and y_b showing up
> in my output.
You may either introduce additional variables and corresponding
equality constraints:
var x_a;
var x_b;
s.t. foo: x_a = x * a;
s.t. bar: x_b = x * b;
Or, that is better, use the printf statement:
...
solve; /* <- this statement should be specified */
printf "x * a = %g; x * b = %g\n", x * a, x * b;
...