[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 <<a href=3D"mailto:Andrew%20Makhorin%20%[email protected]%3e">[email protected]= </a>></div><div><b>To</b>: Jeff Kantor <<a href=3D"mailto:Jeff%20Kant= or%20%[email protected]%3e">[email protected]</a>></div><div><b>From</b>: Code Rag= uet <<a href=3D"mailto:Code%20Raguet%20%[email protected]%3e">ign= [email protected]</a>></div><blockquote type=3D"cite"><!-- text/html -= -><div dir=3D"ltr"><div> </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:"Liberation Sans";font-size:x-small" = cellspacing=3D"0" border=3D"0"> <colgroup width=3D"85" span=3D"3"></colgroup> <tbody style=3D"font-family:"Liberation Sans";font-size:x-small"= ><tr style=3D"font-family:"Liberation Sans";font-size:x-small"> <td style=3D"font-family:"Liberation Sans";font-size:x-small" h= eight=3D"32" align=3D"center"><br></td> <td style=3D"font-family:"Liberation Sans";font-size:x-small" a= lign=3D"center"><b><font face=3D"Liberation Serif">p1</font></b></td> <td style=3D"font-family:"Liberation Sans";font-size:x-small" a= lign=3D"center"><b><font face=3D"Liberation Serif">p2</font></b></td> </tr> <tr style=3D"font-family:"Liberation Sans";font-size:x-small"> <td style=3D"font-family:"Liberation Sans";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:"Liberation Sans";font-size:x-small" a= lign=3D"left"><font face=3D"Liberation Serif">100</font></td> <td style=3D"font-family:"Liberation Sans";font-size:x-small" a= lign=3D"left"><font face=3D"Liberation Serif">20</font></td> </tr> <tr style=3D"font-family:"Liberation Sans";font-size:x-small"> <td style=3D"font-family:"Liberation Sans";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:"Liberation Sans";font-size:x-small" a= lign=3D"left"><font face=3D"Liberation Serif">200</font></td> <td style=3D"font-family:"Liberation Sans";font-size:x-small" a= lign=3D"left"><font face=3D"Liberation Serif">30</font></td> </tr> <tr style=3D"font-family:"Liberation Sans";font-size:x-small"> <td style=3D"font-family:"Liberation Sans";font-size:x-small" h= eight=3D"32" align=3D"center"><br></td> <td style=3D"font-family:"Liberation Sans";font-size:x-small" a= lign=3D"left"><br></td> <td style=3D"font-family:"Liberation Sans";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> = p1 p2 :=3D<br> A &nbs= p; 100 20<br> B 200 30<br>&nb= sp; ;</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 = <<a href=3D"mailto:[email protected]">[email protected]</a>> wrote:<br></div><blo= ckquote type=3D"cite">-------- Forwarded Message --------<br> From: Jeff Kantor <<a href=3D"mailto:[email protected]" target=3D"_blank">jeff= @nd.edu</a>><br> To: Andrew Makhorin <<a href=3D"mailto:[email protected]" target=3D"_blank">ma= [email protected]</a>><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> > Hi Ignacio,<br> > <br> > The =E2=80=99set=E2=80=99 and =E2=80=98param=E2=80=99 statements need = to be considered from the<br> > perspective of a mathematical optimization model. A =E2=80=99set=E2=80= =99 refers to a<br> > mathematical set of objects that will index other components of the<br= > > model, such as parameters, constraints, and decision variables. The<br= > > elements of the set must be unique. They can be integers or strings.<b= r> > Identifying appropriate sets for a particular problem is often<br> > obvious, but other times worth some thought.<br> > <br> > Elements of a set index parameters and provide a symbolic reference to= <br> > the numbers needed to specify expressions appearing in your model.<br> > <br> > Parameters and sets are very different things.<br> > <br> > Jeff<br> > <br> > > On May 27, 2023, at 7:17 PM, Andrew Makhorin <<a href=3D"mailt= o:[email protected]" target=3D"_blank">[email protected]</a>> wrote:<br> > > <br> > > -------- Forwarded Message --------<br> > > From: Code Raguet <<a href=3D"mailto:[email protected]" t= arget=3D"_blank">[email protected]</a>><br> > > To: <a href=3D"mailto:[email protected]" target=3D"_blank">help-g= [email protected]</a><br> > > Subject: MathProg set vs param<br> > > Date: Sat, 27 May 2023 19:51:01 -0300<br> > > <br> > > > Hi, there!<br> > > > I'm new to MathProg (and LP) but I have several years as a<b= r> > > > software<br> > > > developer.<br> > > > I would like to understand the semantic differences between = set<br> > > > and<br> > > > param.<br> > > > When reading the doc and looking at examples, I understand t= hat<br> > > > the<br> > > > set statement is for sets, arrays, vectors, (n-tuples) and s= imple<br> > > > symbolic elements. On the other hand, param statement is for= <br> > > > simple<br> > > > scalar values or values of a set (usually indexed).<br> > > > <br> > > > My issues are about the semantics and rationale behind these= <br> > > > statements.<br> > > > Why are two different statements for doing quite similar (in= my<br> > > > understanding) purpose?<br> > > > I mean, both declare data structures (and initialize in the = data<br> > > > section).<br> > > > Aren't sets kind of a param after all?<br> > > > <br> > > > for ex.:<br> > > > Imagine declaring an array of simple elements:<br> > > > set S :=3D {'A', 'B'};<br> > > > param P{i in {'A', 'B'}};<br> > > > <br> > > > How are these statements different?<br> > > > <br> > > > <br> > > > Thanks in advance,<br> > > > Ignacio.<br> > <br> > <br> <br></blockquote></div></div></div></div> </blockquote></body></html> --=-fEOqwy2uCdi/HWdsTFOA--