help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] How to use a subset of a set as a variable in GLPK


From: Andrew Makhorin
Subject: Re: [Help-glpk] How to use a subset of a set as a variable in GLPK
Date: Mon, 31 Jul 2017 18:57:29 +0300

> OK, I will rephase my question in a simpler manner. How would I go
> about the code if I want to restrict the set to only use dates 07 Mar
> to 11 Mar instead of the entire set? I do not know how to make a
> subset.

/* entire set whose contents are specified in the data section */
set D;

/* subset of D */
set S := {d in D : CONDITION};

where CONDITION is a logical condition that defines which d's from D
should be included into S.

For more details about the syntax please see the GNU MathProg Reference
Manual (gmpl.pdf) included in the distribution. See also some example
models (dist.mod, egypt.mod) included in the subdirectory 'examples'.

> 
> Thanks,
> Peter
> 
> Date    LT ST1 ST2 ST3
> 01-Mar 4 0 0 0
> 02-Mar 4 0 0 0
> 03-Mar 4 1 0 0
> 04-Mar 4 0 0 0
> 05-Mar 4 0 0 0
> 06-Mar 4 0 0 0
> 07-Mar 4 5 0 0
> 08-Mar 4 8 8 8
> 09-Mar 4 15 5 0
> 10-Mar 4 19 28 19
> 11-Mar 4 11 11 0
> 12-Mar 4 1 0 1
> 13-Mar 4 0 0 0
> 14-Mar 4 0 16 0
> 15-Mar 4 1 1 2
> 16-Mar 4 5 5 5
> 17-Mar 4 8 1 3
> 18-Mar 4 0 0 0
> 19-Mar 4 0 0 4
> 20-Mar 4 0 0 7
> 
> On Sat, Jul 29, 2017 at 10:04 AM, Andrew Makhorin <address@hidden> wrote:
> >> So say I have this set where I only have a certain dates where I want
> >> to add more items and after a certain date remove those items.
> >>
> >> How would approach this if I have this to start with:
> >
> > Your question is unclear. Please explain in more details what you need
> > to model.
> >
> >>
> >> # set of points
> >>
> >>
> >> set I;
> >>
> >> param x {i in I};
> >>
> >> param y {i in I};
> >>
> >> printf {i in I} "%.2f, %.2f, %.2f\n", i, x[i],y[i];
> >>
> >> data;
> >>
> >> param : I :   x    y :=
> >>
> >>         4.01     0    1
> >>
> >>         4.02   0.5  0.9
> >>
> >>         4.03     1  0.7
> >>
> >>         4.04   1.5  1.5
> >>
> >>         4.05   1.9    2
> >>
> >>         4.06   2.5  2.4
> >>
> >>         4.07     3  3.2
> >>
> >>         4.08   3.5    2
> >>
> >>         4.09     4  2.7
> >>
> >>        ;
> >> end;
> >>
> >
> >
> 





reply via email to

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