help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] Constraining var values to a specified set


From: Andrew Makhorin
Subject: Re: [Help-glpk] Constraining var values to a specified set
Date: Tue, 27 Nov 2007 17:48:38 +0300

> is it possible, in mathprog, to specify that var values should be
> contained in a defined set?

> Actually my var declaration is:
var p {i in C} >>=0 <=1;

> but in my problem vars are not in a continous interval but they're more
> like:
> #MODEL
> set S;
> var p {i in C} in S; #this tell the solver that p_i values are to be
> taken from set S

> s.t. ...

> #DATA
> set S:= s1 s2

> Is it possible to obtain something like this in mathprog, and if not,
> could please point me to a tool able to solve such kind of problem?

If you need variable p[i] to take values over finite set
S = {s1, s2, ..., sn}, you can model that as follows:

var p{i in C};

var z{i in C, j in S}, binary;
/* z[i,j] = 1 iff p[i] = s[j] */

s.t. foo{i in C}: sum{j in S} z[i,j] = 1;

s.t. bar{i in C}: p[i] = sum{j in S} s[j] * z[i,j];





reply via email to

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