<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: substitution of variables in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/substitution-of-variables/m-p/84336#M578</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Leo.&lt;/P&gt;&lt;P&gt;I was looking at proc clp too, anyway, in those examples I don't see relationships between a continuos variable (j in my example) and a variable which I want to discretize (i in my example). If you want, I need to define a piecewise function from j in real numbers to i in integers. A priori I don't know j, I can only bound it. &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This discretization must be runtime, j varies (and the objective function is in terms of j) but consequently i (discretization of j) varies itself and I have a constraint on it.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;In the end, are you telling me that there's no easy way to re-write my last example defining i in terms of j?&lt;/P&gt;&lt;P&gt;Again, thank you so much for your time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Mar 2013 17:36:09 GMT</pubDate>
    <dc:creator>emil</dc:creator>
    <dc:date>2013-03-21T17:36:09Z</dc:date>
    <item>
      <title>substitution of variables</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/substitution-of-variables/m-p/84331#M573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everybody.&lt;/P&gt;&lt;P&gt;Look at this simple optmodel statement as an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: navy; background: white;"&gt;proc&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: navy; background: white;"&gt;optmodel&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; printlevel=&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; FD=CENTRAL; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; j; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max s = j&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con c: &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(if &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;lt;j&amp;lt;=&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;3&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; then &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;3&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; else &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;5&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;) &amp;lt;=&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-size: 10pt; background-color: white; font-family: 'Courier New'; background-position: initial initial; background-repeat: initial initial;"&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; solve; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create data output from j; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 10pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 10pt;"&gt;If you execute it, SAS doesn't find a maximum for j (it reaches 1.0001E19 with a default number of iterations), while to me it might be j=3, since the constraint is true only if 1&amp;lt;j&amp;lt;=3. I see that j disappears from the constraint, in the end, so there is no inequality in j, but in any case I don't understand why I cannot write this.&lt;/P&gt;&lt;P style="margin-bottom: 10pt;"&gt;Why?&lt;/P&gt;&lt;P style="margin-bottom: 10pt;"&gt;It looks to me like SAS translates the problem into something with the following 2 constraints:&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; color: black; background-color: white;"&gt;con c1: i &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; color: black; background-color: white;"&gt;&amp;lt;= &lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; color: black; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; color: black; background-color: white;"&gt;con c2: i = &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; color: black; background-color: white;"&gt;if &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; color: teal; background-color: white;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; color: black; background-color: white;"&gt;&amp;lt;j&amp;lt;=&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; color: teal; background-color: white;"&gt;3&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; color: black; background-color: white;"&gt; then &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; color: teal; background-color: white;"&gt;3&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; color: black; background-color: white;"&gt; else &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; color: teal; background-color: white;"&gt;5&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; color: black; background-color: white;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Now, for every j, this is a system made of an equality (i=3 or i=5) and an inequality (i&amp;lt;=4). Since there is no special priority checking the constraints, SAS will hardly find a valid solution: the only two valid solutions are j=3 and j=5. Is this problem equivalent to the first in SAS? Why?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;How can I solve it?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Thank you.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 08:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/substitution-of-variables/m-p/84331#M573</guid>
      <dc:creator>emil</dc:creator>
      <dc:date>2013-03-21T08:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: substitution of variables</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/substitution-of-variables/m-p/84332#M574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe this is clearer. Here I try to maximize i, but it doesn't give the right solution anyway.&lt;/P&gt;&lt;P&gt;It gives i=4.0000013216, hence 4, while it might be, in my opinion, 3, because of the c1 constraint:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;SPAN lang="EN-US" style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: navy;"&gt;proc&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;SPAN lang="EN-US" style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: navy;"&gt;optmodel&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; printlevel=&lt;/SPAN&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;SPAN lang="EN-US" style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: teal;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; FD=CENTRAL;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN lang="EN-US" style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; i,j;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN lang="EN-US" style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max s = i&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN lang="EN-US" style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con c1: i = if 1&amp;lt;j&amp;lt;=3 then 3 else 5;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN lang="EN-US" style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con c2: i&amp;lt;=4;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN lang="EN-US" style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; solve;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN lang="EN-US" style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create data output from i j;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 10pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: navy;"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 09:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/substitution-of-variables/m-p/84332#M574</guid>
      <dc:creator>emil</dc:creator>
      <dc:date>2013-03-21T09:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: substitution of variables</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/substitution-of-variables/m-p/84333#M575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What you are trying to do with the model? That might help you get a more specific answer. The 1 &amp;lt; j &amp;lt;= 3 snippet indicates to me that you might be trying to do something beyond what the solver was designed to handle.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The main improvement you could try is to add functions of j to the constraint c, instead of using the constants 3 and 5. The constants tell the solver whether the problem is feasible or not, but don't tell it what to try to do to make the solution feasible, or keep it feasible. So the solver keeps trying to find a better solution, because as far as it knows, feasibility isn't getting any better or worse.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are a couple of other important improvements you could try as well:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Try to avoid strict inequalities, &amp;lt; or &amp;gt;. The theory that underlies the solvers assume that constraints are always specified with &amp;lt;=, &amp;gt;=, or =. This is why PROC OPTMODEL will produce a syntax error if a constraint is defined with a strict inequality. Using a conditional, you can get around that, and it might work, but it might also fail unpredictably. In practice, even when the solver produces the right output, you will get values very very close to what you would have gotten with a &amp;lt;= or &amp;gt;= anyway.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;Try to always declare bounds for the variables if you can (in this case it appears that you can).&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here is a snippet that incorporates the guidelines above:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc optmodel;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var j &amp;gt;= 1 &amp;lt;= 3; /* use bounds if available */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max s = j;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* tell the solver that if j &amp;lt; 1 then it should be increased */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* warning: this defines an open set -- use with extreme caution -- avoid if possible */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con c: (if 1 &amp;lt; j then j else j/2 ) &amp;gt;= 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; solve;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create data output from j;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 15:12:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/substitution-of-variables/m-p/84333#M575</guid>
      <dc:creator>LeoLopes</dc:creator>
      <dc:date>2013-03-21T15:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: substitution of variables</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/substitution-of-variables/m-p/84334#M576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, thanks..maybe I'm using the proc optmodel in the wrong way. You've been very clear, but still I don't understand how I can define i=f(j). In other words, I need i to assume only some fixed values, depending on values of j (continue). Is there a way to do this? &lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc optmodel; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var i,j; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; min s = i+j; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* statement I'd like to be able to define, to have i a variable depentent on j */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; " i = if j&amp;gt;=0 then 1 else 5;"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* constraint on j*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con c1: j&amp;gt;=0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; solve;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create data output from i j; &lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want the solution to be i+j=1+0=1.&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 15:59:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/substitution-of-variables/m-p/84334#M576</guid>
      <dc:creator>emil</dc:creator>
      <dc:date>2013-03-21T15:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: substitution of variables</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/substitution-of-variables/m-p/84335#M577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. I am glad I was helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are several ways to do represent the relationship between two variables. Which one is the best depends on the size of the problem you are trying to solve and on the kind of relationship you need to express. Here are some rules of thumb:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the relationship is a lookup table, i.e., there is no simple way to write i as a function of j, and especially if you have many strict inequalities, you might want to look at PROC CLP. From the example in your response, I think this may be worth a look. See if this example is helpful: &lt;A href="http://support.sas.com/documentation/cdl/en/orcpug/65552/HTML/default/viewer.htm#orcpug_clp_examples07.htm" title="http://support.sas.com/documentation/cdl/en/orcpug/65552/HTML/default/viewer.htm#orcpug_clp_examples07.htm"&gt;SAS/OR(R) 12.1 User's Guide: Constraint Programming&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the relationship contains thresholds or represents fixed costs, you might be able to use integer variables with the MILP solver in OPTMODEL. If your other constraints are linear, then this is the option most likely to scale to very large problems. See if this example is helpful: &lt;A href="http://support.sas.com/documentation/cdl/en/ormpug/65554/HTML/default/viewer.htm#ormpug_milpsolver_examples02.htm" title="http://support.sas.com/documentation/cdl/en/ormpug/65554/HTML/default/viewer.htm#ormpug_milpsolver_examples02.htm"&gt;SAS/OR(R) 12.1 User's Guide: Mathematical Programming&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the relationship is a piecewise function, i.e., it changes at certain points but is continuous and smooth otherwise, then: if the problem is linear, use MILP. If it is nonlinear, you can try the NLP solver, especially with the multistart option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 16:46:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/substitution-of-variables/m-p/84335#M577</guid>
      <dc:creator>LeoLopes</dc:creator>
      <dc:date>2013-03-21T16:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: substitution of variables</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/substitution-of-variables/m-p/84336#M578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Leo.&lt;/P&gt;&lt;P&gt;I was looking at proc clp too, anyway, in those examples I don't see relationships between a continuos variable (j in my example) and a variable which I want to discretize (i in my example). If you want, I need to define a piecewise function from j in real numbers to i in integers. A priori I don't know j, I can only bound it. &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This discretization must be runtime, j varies (and the objective function is in terms of j) but consequently i (discretization of j) varies itself and I have a constraint on it.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;In the end, are you telling me that there's no easy way to re-write my last example defining i in terms of j?&lt;/P&gt;&lt;P&gt;Again, thank you so much for your time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 17:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/substitution-of-variables/m-p/84336#M578</guid>
      <dc:creator>emil</dc:creator>
      <dc:date>2013-03-21T17:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: substitution of variables</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/substitution-of-variables/m-p/84337#M579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No problem, I am glad to help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[&lt;STRONG&gt;Edit&lt;/STRONG&gt;: apologies -- in an effort to simplify the presentation I had a version of the code below that was incorrect.]&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;There are several ways to express the rule you propose, but which one will produce the best results depends on context. The rule is non-linear and discontinuous. In theory, that prevents the algorithms from doing clever things to produce results faster. But in practice, the algorithms implement many tricks that often produce great results. So you might have to experiment a little to see which algorithm and formulation will perform best in practice.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example: here is how you might do it if you have only linear expressions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc optmodel;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num jRange = 5; /* suppose J can vary between -5 and 5 */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num delta = .1; /* meaningful deviation from 0 -- Don't make too small.*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var JPosPart &amp;gt;= 0 &amp;lt;= jRange, JNegPart &amp;gt;= 0 &amp;lt;= jRange ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; impvar J = JPosPart - JNegPart;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var IsJNeg binary;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; impvar I = 1 + 4*IsJNeg;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* The bound is &amp;gt;= 1 only if J &amp;lt;= delta */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con ComputeIsJNeg1: &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IsJNeg &amp;lt;= (1/delta) * jNegPart ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* The right hand is &amp;gt; 0 only if jNegPart is &amp;lt; delta, but is always &amp;lt;= 1 */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con ComputeIsJNeg2: &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IsJNeg &amp;gt;= 1 / jRange * ( jNegPart - delta );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* The right hand is 1 only if jPosPart is 0, but always &amp;gt;= 0 */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con ComputeIsJNeg3: &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IsJNeg &amp;lt;= 1 - (1/(jRange + delta)) * jPosPart;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max s = 10*I + J ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; solve ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print I J IsJNeg JNegPart JPosPart;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are simpler ways if you make assumptions about objective sense. You might just have to experiment with some examples.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 19:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/substitution-of-variables/m-p/84337#M579</guid>
      <dc:creator>LeoLopes</dc:creator>
      <dc:date>2013-03-21T19:58:12Z</dc:date>
    </item>
  </channel>
</rss>

