help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] fixing a variable


From: xypron
Subject: Re: [Help-glpk] fixing a variable
Date: Thu, 18 Jun 2009 10:35:04 -0700 (PDT)

Hello Hussin,


hussin hassen wrote:
> 
> Is there any one who can help me by telling me how to fix the value of a
> variable at certain set members?

see example below.

Best regards

Xypron

# This example shows how to fix some of an array of variables.
#
# To see that is works try
# glpsol -m thisFile.mod --wcpxlp thatFile.lp
# and inspect the "Bounds" section of file thatFile.lp
#
# domain of variables
set S := 1..20;
# set of fixed values
set F, dimen 2;
# domain of fixed values
set FD := setof{(s,v) in F} s;
# fixed values
param f{s in FD} := sum{(s,v) in F} v;
# variable definition
var v{s in S}, >= if s in FD then f[s] else -Infinity, <= if s in FD then
f[s] else Infinity;
# objective
maximize obj :
  sum{s in S} v[s];
# some constraint
s.t. ub{s in S} :
  v[s] <= s;
# solve
solve;
# show result
display v;
# done
data;
# set of fixed values
set F :=
  (15, -15)
  (18, -18);
end;


-- 
View this message in context: 
http://www.nabble.com/fixing-a-variable-tp24091204p24095341.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]