help-glpk
[Top][All Lists]
Advanced

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

[Fwd: Re: [Fwd: Re: [Fwd: MathProg set vs param]]]


From: Andrew Makhorin
Subject: [Fwd: Re: [Fwd: Re: [Fwd: MathProg set vs param]]]
Date: Sun, 28 May 2023 21:19:44 +0300

-------- Forwarded Message --------

Date: Sun, 28 May 2023 14:08:46 -0300
Subject: Re: [Fwd: Re: [Fwd: MathProg set vs param]]
Cc: help-glpk@gnu.org, Andrew Makhorin <mao@gnu.org>
To: Jeff Kantor <jeff@nd.edu>
From: Code Raguet <ignacio.code@gmail.com>
 
The ’set’ and ‘param’ statements need to be considered from the
perspective of a mathematical optimization model.

This may be the cause of my struggling. My lack of knowledge in LP isn't helping to link the proper domain abstractions.

For example, I need to work with some dataset as a matrix:

p1 p2
A 100 20
B 200 30



I managed to encode this table as the following statements. This works but my rationale is that the whole table is my "parameter".
I'd like to be able to solve the model with another dataset where the only things that would remain are column names (p1 and p2).
Everything else may change.
So, do I need the S set? why? Is it possible to do this with param p only?
I think that my parameter is just p and not p and s.

set S := A B;
param p :
            p1   p2    :=
        A   100  20
        B   200  30
        ;

Thank you very much for your help, time and kindness.
Ignacio.

On Sun, May 28, 2023 at 10:18 AM Andrew Makhorin <mao@gnu.org> wrote:
-------- Forwarded Message --------
From: Jeff Kantor <jeff@nd.edu>
To: Andrew Makhorin <mao@gnu.org>
Cc: help-glpk@gnu.org
Subject: Re: [Fwd: MathProg set vs param]
Date: Sat, 27 May 2023 20:00:37 -0500

> Hi Ignacio,
>
> The ’set’ and ‘param’ statements need to be considered from the
> perspective of a mathematical optimization model. A ’set’ refers to a
> mathematical set of objects that will index other components of the
> model, such as parameters, constraints, and decision variables. The
> elements of the set must be unique. They can be integers or strings.
> Identifying appropriate sets for a particular problem is often
> obvious, but other times worth some thought.
>
> Elements of a set index parameters and provide a symbolic reference to
> the numbers needed to specify expressions appearing in your model.
>
> Parameters and sets are very different things.
>
> Jeff
>
> > On May 27, 2023, at 7:17 PM, Andrew Makhorin <mao@gnu.org> wrote:
> >
> > -------- Forwarded Message --------
> > From: Code Raguet <ignacio.code@gmail.com>
> > To: help-glpk@gnu.org
> > Subject: MathProg set vs param
> > Date: Sat, 27 May 2023 19:51:01 -0300
> >
> > > Hi, there!
> > > I'm new to MathProg (and LP) but I have several years as a
> > > software
> > > developer.
> > > I would like to understand the semantic differences between set
> > > and
> > > param.
> > > When reading the doc and looking at examples, I understand that
> > > the
> > > set statement is for sets, arrays, vectors, (n-tuples) and simple
> > > symbolic elements. On the other hand, param statement is for
> > > simple
> > > scalar values or values of a set (usually indexed).
> > >
> > > My issues are about the semantics and rationale behind these
> > > statements.
> > > Why are two different statements for doing quite similar (in my
> > > understanding) purpose?
> > > I mean, both declare data structures (and initialize in the data
> > > section).
> > > Aren't sets kind of a param after all?
> > >
> > > for ex.:
> > > Imagine declaring an array of simple elements:
> > > set S := {'A', 'B'};
> > > param P{i in {'A', 'B'}};
> > >
> > > How are these statements different?
> > >
> > >
> > > Thanks in advance,
> > > Ignacio.
>
>


reply via email to

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