<?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 How do I determining max value in proc optmodel in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504164#M2438</link>
    <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am struggling with optmodel for bus arrangement optimization,&amp;nbsp;the problem is to assign routes with different traveling cost to bus at lowest totalcost (1 bus can travel &amp;gt;1 route), and when different routes taken by a bus, the highest cost (among routes) will be the ultimate traveling cost for that bus.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My program looks like this up to now: (SAS studio for students)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="opt.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24002iB51D5029AFC5C405/image-size/large?v=v2&amp;amp;px=999" role="button" title="opt.PNG" alt="opt.PNG" /&gt;&lt;/span&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In Min (totalcost)&amp;nbsp;formular, the totalcost is calculated with all&amp;nbsp;cost of all routes taken by bus, which creates an overlap.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Please&amp;nbsp;help&amp;nbsp;me know if there is any way&amp;nbsp;I can determine the max cost among routes for each bus.&lt;/P&gt;&lt;P&gt;Thank you very much indeed for your concern.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Oct 2018 01:54:29 GMT</pubDate>
    <dc:creator>Kris8896</dc:creator>
    <dc:date>2018-10-15T01:54:29Z</dc:date>
    <item>
      <title>How do I determining max value in proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504164#M2438</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am struggling with optmodel for bus arrangement optimization,&amp;nbsp;the problem is to assign routes with different traveling cost to bus at lowest totalcost (1 bus can travel &amp;gt;1 route), and when different routes taken by a bus, the highest cost (among routes) will be the ultimate traveling cost for that bus.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My program looks like this up to now: (SAS studio for students)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="opt.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24002iB51D5029AFC5C405/image-size/large?v=v2&amp;amp;px=999" role="button" title="opt.PNG" alt="opt.PNG" /&gt;&lt;/span&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In Min (totalcost)&amp;nbsp;formular, the totalcost is calculated with all&amp;nbsp;cost of all routes taken by bus, which creates an overlap.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Please&amp;nbsp;help&amp;nbsp;me know if there is any way&amp;nbsp;I can determine the max cost among routes for each bus.&lt;/P&gt;&lt;P&gt;Thank you very much indeed for your concern.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 01:54:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504164#M2438</guid>
      <dc:creator>Kris8896</dc:creator>
      <dc:date>2018-10-15T01:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I determining max value in proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504165#M2439</link>
      <description>Please post your code as text if you want anyone to run and be able to test it. Or work with it.</description>
      <pubDate>Mon, 15 Oct 2018 01:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504165#M2439</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-15T01:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do I determining max value in proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504166#M2440</link>
      <description>&lt;P&gt;Here is my code, thank you:&lt;/P&gt;&lt;P&gt;Proc optmodel;&lt;/P&gt;&lt;P&gt;Set bus={"1","2","3","4","5","6","7","8","9","10","11","12"}; /*bus available*/&lt;/P&gt;&lt;P&gt;Set dep={"C","BS","LT","HS","HX","KTX","TL","NT","HP","TĐ","TL","TN"}; /*departure*/&lt;/P&gt;&lt;P&gt;Number cap{bus}=[45 45 45 45 45 45 45 45 29 29 29 29]; /*bus seats*/&lt;/P&gt;&lt;P&gt;Number dem{dep}=[19 1 50 86 28 116 17 8 31 8 15 4]; /*passengers per route*/&lt;/P&gt;&lt;P&gt;Number cost{bus, dep}=[30 43 32 42 11 38 40 42 35 19 30 38 /*cost of each route when assigned to 45-seat bus*/&lt;BR /&gt;30 43 32 42 11 38 40 42 35 19 30 38&lt;BR /&gt;30 43 32 42 11 38 40 42 35 19 30 38&lt;BR /&gt;30 43 32 42 11 38 40 42 35 19 30 38&lt;BR /&gt;30 43 32 42 11 38 40 42 35 19 30 38&lt;BR /&gt;30 43 32 42 11 38 40 42 35 19 30 38&lt;BR /&gt;30 43 32 42 11 38 40 42 35 19 30 38&lt;BR /&gt;30 43 32 42 11 38 40 42 35 19 30 38&lt;BR /&gt;20 29 21 28 7 25 27 28 23 13 20 25 /*cost of each route when assigned to 29-seat bus*/&lt;BR /&gt;20 29 21 28 7 25 27 28 23 13 20 25&lt;BR /&gt;20 29 21 28 7 25 27 28 23 13 20 25&lt;BR /&gt;20 29 21 28 7 25 27 28 23 13 20 25];&lt;/P&gt;&lt;P&gt;Var x{I in bus, j in dep}&amp;gt;=0; /*passengers on bus i for route j*/&lt;BR /&gt;Var y{I in bus, j in dep} binary; /*y=1 if bus i is chosen for route j*/&lt;/P&gt;&lt;P&gt;Min totalcost=sum{i in bus,j in dep}cost[I,j]*Y[i,j]; /*problem is here*/&lt;/P&gt;&lt;P&gt;Constraint demsum{j in dep}:sum{I in bus}X[I,j]&amp;gt;=dem[j];&lt;/P&gt;&lt;P&gt;Constraint caplimit{I in bus}:sum{j in dep}X[I,j]&amp;lt;=cap[I];&lt;/P&gt;&lt;P&gt;constraint nolink{i in bus, j in dep}:X[i,j]-cap[i]*Y[i,j]&amp;lt;=0;&lt;/P&gt;&lt;P&gt;Solve;&lt;/P&gt;&lt;P&gt;Print X;&lt;/P&gt;&lt;P&gt;Print Y;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 01:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504166#M2440</guid>
      <dc:creator>Kris8896</dc:creator>
      <dc:date>2018-10-15T01:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I determining max value in proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504167#M2441</link>
      <description>Thank you for reminding me, the code is posted below</description>
      <pubDate>Mon, 15 Oct 2018 02:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504167#M2441</guid>
      <dc:creator>Kris8896</dc:creator>
      <dc:date>2018-10-15T02:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I determining max value in proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504170#M2442</link>
      <description>&lt;P&gt;You have TL twice in the dep set, so rename the second one to, say, TL2 to avoid errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your current objective is equivalent to the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var buscost{bus};
con buscostcon{i in bus}: buscost[i] = sum{j in dep} cost[i,j]*Y[i,j];
Min totalcost = sum{i in bus} buscost[i];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It sounds like you want to change the buscost formula as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;con buscostcon{i in bus}: buscost[i] = max{j in dep} cost[i,j]*Y[i,j];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The new constraint is nonlinear.&amp;nbsp; You can use SOLVE WITH LSO to get a good feasible solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you can instead get an optimal solution by linearizing the constraint as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;con buscostcon{i in bus, j in dep}: buscost[i] &amp;gt;= cost[i,j]*Y[i,j];&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This linear constraint guarantees that buscost[i] &amp;gt;= max{j in dep} cost[i,j]*Y[i,j].&amp;nbsp; Because the objective is minimization, this&amp;nbsp;inequality will naturally be satisfied with equality at optimality.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 02:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504170#M2442</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-10-15T02:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I determining max value in proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504176#M2443</link>
      <description>&lt;P&gt;Your formula&amp;nbsp;just worked out right, Prof.&lt;/P&gt;&lt;P&gt;Thank you very much indeed.&lt;/P&gt;&lt;P&gt;Sincerely.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="opt.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24003i49E319F67D8935B8/image-size/large?v=v2&amp;amp;px=999" role="button" title="opt.PNG" alt="opt.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 03:03:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504176#M2443</guid>
      <dc:creator>Kris8896</dc:creator>
      <dc:date>2018-10-15T03:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I determining max value in proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504633#M2445</link>
      <description>&lt;P&gt;Dear Sir,&lt;/P&gt;&lt;P&gt;Thank you for your help last time. The formula you introduced to me to determine the max value of a string is great, and I&amp;nbsp;have applied it to extend my previous problem. This time, it is to change the cost of route into other value, when the route is combined with others (forcing travel on different route with greater distance, rendering higher cost).&lt;/P&gt;&lt;P&gt;Everything is fine with the max formula except for the crossmax, which I added in the end to make sure no route with greater cost is obmited for maxlongcost calculation. According to the result, the problem is a bad type, and I think it can be due to the crossmax.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have checked all the way but still cannot figure out what's wrong with it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would be great if you could again help me with this.&lt;/P&gt;&lt;P&gt;Thank you very much for your concern.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="opt1.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24045i7ECB8A2B268E7B50/image-size/large?v=v2&amp;amp;px=999" role="button" title="opt1.PNG" alt="opt1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="opt2.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24043i234D9FF203946246/image-size/large?v=v2&amp;amp;px=999" role="button" title="opt2.PNG" alt="opt2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 08:17:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504633#M2445</guid>
      <dc:creator>Kris8896</dc:creator>
      <dc:date>2018-10-16T08:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I determining max value in proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504826#M2447</link>
      <description>&lt;P&gt;I don't quite understand the cost rules, but the "Bad Problem Type"&amp;nbsp;is because&amp;nbsp;you are combining integer variables and nonlinear constraints without using SOLVE WITH LSO.&amp;nbsp; The nonlinearity arises from the product of variables y and crossmax here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;constraint finalcostcon1{i in bus, j in dep}: finalcost[i]&amp;gt;=longcost[i,j]*y[i,j]*crossmax[j];&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Because the crosscon constraint and the minimization objective together imply that crossmax[j] &amp;gt; 0 only when y[i,j] = 1, you can linearize as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;constraint finalcostcon1{i in bus, j in dep}: finalcost[i]&amp;gt;=longcost[i,j]*crossmax[j];&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, your pickup constraint should instead be:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;constraint pickup{i in bus}:sum{j in dep} Y[i,j] &amp;lt;= 2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or just remove the parentheses from your version.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 18:31:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504826#M2447</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-10-16T18:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I determining max value in proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504980#M2448</link>
      <description>Dear Sir, it worked again.&lt;BR /&gt;Thank you very much.</description>
      <pubDate>Wed, 17 Oct 2018 07:26:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-determining-max-value-in-proc-optmodel/m-p/504980#M2448</guid>
      <dc:creator>Kris8896</dc:creator>
      <dc:date>2018-10-17T07:26:59Z</dc:date>
    </item>
  </channel>
</rss>

