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

Andrew Makhorin <[email protected]> Sun, 28 May 2023 21:19:44 +0300
Newsgroups gmane.comp.gnu.glpk
Message-ID <[email protected]>
--=-fEOqwy2uCdi/HWdsTFOA
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit

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

Date: Sun, 28 May 2023 14:08:46 -0300
Subject: Re: [Fwd: Re: [Fwd: MathProg set vs param]]
Cc: [email protected], Andrew Makhorin <[email protected]>
To: Jeff Kantor <[email protected]>
From: Code Raguet <[email protected]>
>  
> > The ’set’ and ‘param’ statements need to be considered from
> > theperspective 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 <[email protected]> wrote:
> > -------- Forwarded Message --------
> > 
> > From: Jeff Kantor <[email protected]>
> > 
> > To: Andrew Makhorin <[email protected]>
> > 
> > Cc: [email protected]
> > 
> > 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 <[email protected]>
> > wrote:
> > 
> > > > 
> > 
> > > > -------- Forwarded Message --------
> > 
> > > > From: Code Raguet <[email protected]>
> > 
> > > > To: [email protected]
> > 
> > > > 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.
> > 
> > > 
> > 
> > > 
> > 
> > 
> 
> 
--=-fEOqwy2uCdi/HWdsTFOA
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div>-------- Forwarded Message --------</div><div=
><br></div><div><b>Date</b>: Sun, 28 May 2023 14:08:46 -0300</div><div><b>S=
ubject</b>: Re: [Fwd: Re: [Fwd: MathProg set vs param]]</div><div><b>Cc</b>=
: <a href=3D"mailto:[email protected]">[email protected]</a>, Andrew Makhor=
in &lt;<a href=3D"mailto:Andrew%20Makhorin%20%[email protected]%3e">[email protected]=
</a>&gt;</div><div><b>To</b>: Jeff Kantor &lt;<a href=3D"mailto:Jeff%20Kant=
or%20%[email protected]%3e">[email protected]</a>&gt;</div><div><b>From</b>: Code Rag=
uet &lt;<a href=3D"mailto:Code%20Raguet%20%[email protected]%3e">ign=
[email protected]</a>&gt;</div><blockquote type=3D"cite"><!-- text/html -=
-><div dir=3D"ltr"><div>&nbsp;</div><blockquote type=3D"cite"><div>The =E2=
=80=99set=E2=80=99 and =E2=80=98param=E2=80=99 statements need to be consid=
ered from the</div><div>perspective of a mathematical optimization model. <=
/div><br></blockquote><div>This may be the cause of my struggling. My lack =
of knowledge in LP isn't helping to link the proper domain abstractions.</d=
iv><div><br></div><div>For example, I need to work with some dataset as a m=
atrix:</div><div>



=09
=09
	<span></span>
=09
=09
=09



<table style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small" =
cellspacing=3D"0" border=3D"0">
	<colgroup width=3D"85" span=3D"3"></colgroup>
	<tbody style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small"=
><tr style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small">
		<td style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small" h=
eight=3D"32" align=3D"center"><br></td>
		<td style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small" a=
lign=3D"center"><b><font face=3D"Liberation Serif">p1</font></b></td>
		<td style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small" a=
lign=3D"center"><b><font face=3D"Liberation Serif">p2</font></b></td>
	</tr>
	<tr style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small">
		<td style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small" h=
eight=3D"17" align=3D"center"><b><font face=3D"Liberation Serif">A</font></=
b></td>
		<td style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small" a=
lign=3D"left"><font face=3D"Liberation Serif">100</font></td>
		<td style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small" a=
lign=3D"left"><font face=3D"Liberation Serif">20</font></td>
	</tr>
	<tr style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small">
		<td style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small" h=
eight=3D"32" align=3D"center"><b><font face=3D"Liberation Serif">B</font></=
b></td>
		<td style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small" a=
lign=3D"left"><font face=3D"Liberation Serif">200</font></td>
		<td style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small" a=
lign=3D"left"><font face=3D"Liberation Serif">30</font></td>
	</tr>
	<tr style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small">
		<td style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small" h=
eight=3D"32" align=3D"center"><br></td>
		<td style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small" a=
lign=3D"left"><br></td>
		<td style=3D"font-family:&quot;Liberation Sans&quot;;font-size:x-small" a=
lign=3D"left"><br></td>
	</tr>
</tbody></table>I managed to encode this table as the following statements.=
 This works but my rationale is that the whole table is my "parameter".<br>=
</div><div>I'd like to be able to solve the model with another dataset wher=
e the only things that would remain are column names (p1 and p2).</div><div=
>Everything else may change.<br></div><div>So, do I need the <span style=3D=
"font-family:monospace">S</span> set? why? Is it possible to do this with <=
span style=3D"font-family:monospace">param  p</span> only?</div><div>I thin=
k that my <i>parameter</i> is just <span style=3D"font-family:monospace">p<=
/span> and not <span style=3D"font-family:monospace">p</span> <u>and</u> <s=
pan style=3D"font-family:monospace">s.</span><br></div><div><span style=3D"=
font-family:monospace"><br></span></div><div><span style=3D"font-family:mon=
ospace">set S :=3D A B;<br>param p :<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; p1 &nbsp; p2 &nbsp; &nbsp;:=3D<br>&nbsp; &nbsp; &nbsp; &nbsp; A &nbs=
p; 100 &nbsp;20<br>&nbsp; &nbsp; &nbsp; &nbsp; B &nbsp; 200 &nbsp;30<br>&nb=
sp; &nbsp; &nbsp; &nbsp; ;</span></div><br>Thank you very much for your hel=
p, time and kindness.<br>Ignacio.<div><span style=3D"font-family:monospace"=
><br></span></div><div><div><div class=3D"gmail_quote"><div dir=3D"ltr" cla=
ss=3D"gmail_attr">On Sun, May 28, 2023 at 10:18=E2=80=AFAM Andrew Makhorin =
&lt;<a href=3D"mailto:[email protected]">[email protected]</a>&gt; wrote:<br></div><blo=
ckquote type=3D"cite">-------- Forwarded Message --------<br>
From: Jeff Kantor &lt;<a href=3D"mailto:[email protected]" target=3D"_blank">jeff=
@nd.edu</a>&gt;<br>
To: Andrew Makhorin &lt;<a href=3D"mailto:[email protected]" target=3D"_blank">ma=
[email protected]</a>&gt;<br>
Cc: <a href=3D"mailto:[email protected]" target=3D"_blank">[email protected]=
g</a><br>
Subject: Re: [Fwd: MathProg set vs param]<br>
Date: Sat, 27 May 2023 20:00:37 -0500<br>
<br>
&gt; Hi Ignacio,<br>
&gt; <br>
&gt; The =E2=80=99set=E2=80=99 and =E2=80=98param=E2=80=99 statements need =
to be considered from the<br>
&gt; perspective of a mathematical optimization model. A =E2=80=99set=E2=80=
=99 refers to a<br>
&gt; mathematical set of objects that will index other components of the<br=
>
&gt; model, such as parameters, constraints, and decision variables. The<br=
>
&gt; elements of the set must be unique. They can be integers or strings.<b=
r>
&gt; Identifying appropriate sets for a particular problem is often<br>
&gt; obvious, but other times worth some thought.<br>
&gt; <br>
&gt; Elements of a set index parameters and provide a symbolic reference to=
<br>
&gt; the numbers needed to specify expressions appearing in your model.<br>
&gt; <br>
&gt; Parameters and sets are very different things.<br>
&gt; <br>
&gt; Jeff<br>
&gt; <br>
&gt; &gt; On May 27, 2023, at 7:17 PM, Andrew Makhorin &lt;<a href=3D"mailt=
o:[email protected]" target=3D"_blank">[email protected]</a>&gt; wrote:<br>
&gt; &gt; <br>
&gt; &gt; -------- Forwarded Message --------<br>
&gt; &gt; From: Code Raguet &lt;<a href=3D"mailto:[email protected]" t=
arget=3D"_blank">[email protected]</a>&gt;<br>
&gt; &gt; To: <a href=3D"mailto:[email protected]" target=3D"_blank">help-g=
[email protected]</a><br>
&gt; &gt; Subject: MathProg set vs param<br>
&gt; &gt; Date: Sat, 27 May 2023 19:51:01 -0300<br>
&gt; &gt; <br>
&gt; &gt; &gt; Hi, there!<br>
&gt; &gt; &gt; I'm new to MathProg (and LP) but I have several years as a<b=
r>
&gt; &gt; &gt; software<br>
&gt; &gt; &gt; developer.<br>
&gt; &gt; &gt; I would like to understand the semantic differences between =
set<br>
&gt; &gt; &gt; and<br>
&gt; &gt; &gt; param.<br>
&gt; &gt; &gt; When reading the doc and looking at examples, I understand t=
hat<br>
&gt; &gt; &gt; the<br>
&gt; &gt; &gt; set statement is for sets, arrays, vectors, (n-tuples) and s=
imple<br>
&gt; &gt; &gt; symbolic elements. On the other hand, param statement is for=
<br>
&gt; &gt; &gt; simple<br>
&gt; &gt; &gt; scalar values or values of a set (usually indexed).<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; My issues are about the semantics and rationale behind these=
<br>
&gt; &gt; &gt; statements.<br>
&gt; &gt; &gt; Why are two different statements for doing quite similar (in=
 my<br>
&gt; &gt; &gt; understanding) purpose?<br>
&gt; &gt; &gt; I mean, both declare data structures (and initialize in the =
data<br>
&gt; &gt; &gt; section).<br>
&gt; &gt; &gt; Aren't sets kind of a param after all?<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; for ex.:<br>
&gt; &gt; &gt; Imagine declaring an array of simple elements:<br>
&gt; &gt; &gt; set S :=3D {'A', 'B'};<br>
&gt; &gt; &gt; param P{i in {'A', 'B'}};<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; How are these statements different?<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Thanks in advance,<br>
&gt; &gt; &gt; Ignacio.<br>
&gt; <br>
&gt; <br>
<br></blockquote></div></div></div></div>
</blockquote></body></html>
--=-fEOqwy2uCdi/HWdsTFOA--