<?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: Parameter Declaring in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/442373#M2198</link>
    <description>The constraint is indexed by k, but the rhs depends on i.  In words, what is the constraint intended to enforce?</description>
    <pubDate>Mon, 05 Mar 2018 14:36:29 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2018-03-05T14:36:29Z</dc:date>
    <item>
      <title>Parameter Declaring</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/442325#M2197</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having trouble with declaration of parameter i. Trying to write&amp;nbsp; a constraint&amp;nbsp; per vehicle, although I defined the parameter i and j, at the if&amp;nbsp;part of&amp;nbsp; constraint I got error that i has't been declared.How can I solve this?Thanks in advance:)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="xis-codeBlock"&gt; con Balance { k in VEHICLES}:
       sum {&amp;lt;i,j)&amp;gt; in ARCS} Flow[i,j,k]&amp;lt;= (if demand[i]&amp;lt;500 then 1000 else demand[i]);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Mar 2018 12:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/442325#M2197</guid>
      <dc:creator>ALexandraJ86</dc:creator>
      <dc:date>2018-03-05T12:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter Declaring</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/442373#M2198</link>
      <description>The constraint is indexed by k, but the rhs depends on i.  In words, what is the constraint intended to enforce?</description>
      <pubDate>Mon, 05 Mar 2018 14:36:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/442373#M2198</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-03-05T14:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter Declaring</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/442615#M2199</link>
      <description>&lt;PRE class="xis-codeBlock"&gt; con Balance { k in VEHICLES}:
       sum {&amp;lt;i,j)&amp;gt; in ARCS} Flow[i,j,k]&amp;lt;= (if demand[i]&amp;lt;500 then 1000 else volume[k]);&lt;/PRE&gt;&lt;P&gt;You're right. rhs part depends on k,I added,&amp;nbsp; but still can't define i.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if I declare&amp;nbsp; it like below, it works but doesn't calculate&amp;nbsp; per vehicle.&lt;/P&gt;&lt;PRE class="xis-codeBlock"&gt;con Balance { k in VEHICLES,i in NODES}:&lt;BR /&gt;sum {&amp;lt;(i),j)&amp;gt; in ARCS} Flow[i,j,k]&amp;lt;= (if demand[i]&amp;lt;500 then 1000 else volume[k]);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Mar 2018 20:27:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/442615#M2199</guid>
      <dc:creator>ALexandraJ86</dc:creator>
      <dc:date>2018-03-05T20:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter Declaring</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/442629#M2200</link>
      <description>&lt;P&gt;I'm not sure what "doesn't calculate per vehicle" means.&amp;nbsp; The lhs variables and the rhs do depend on k.&amp;nbsp; Is volume[k] different for different values of k?&amp;nbsp; You might find it helpful to use the EXPAND statement to see the expanded form of the constraint.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Mar 2018 21:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/442629#M2200</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-03-05T21:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter Declaring</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/442631#M2201</link>
      <description>thank you. Yes volume is diffrent for diffrent values of k.</description>
      <pubDate>Mon, 05 Mar 2018 21:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/442631#M2201</guid>
      <dc:creator>ALexandraJ86</dc:creator>
      <dc:date>2018-03-05T21:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter Declaring</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/444716#M2204</link>
      <description>&lt;P&gt;Hi, i could not do with expand statement. I tried to write a sample below that describes what I am trying to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is a metarial data and the factory data.&amp;nbsp; Each vehicle on material data&amp;nbsp; try to use its liquid and solid stock by delivering it to the factories. Vehicles that have liquid volume goes to factories that have liquid inventory.&lt;/P&gt;&lt;P&gt;And I am trying to write a flow constraint per vehicle&amp;nbsp; if inventory is liquid on factory data then use the liquid variable on material data else use solid variable.&lt;/P&gt;&lt;P&gt;Thx:)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data material;
input liquid solid vehicle ;
datalines ;
50 10 1
40 30 2
10 60 3
0 100 4
100 0 5
;
data  factory;
input  id inventory $ x y supply;
datalines;
1 liquid 10 20 10
2 solid 11 20 20
3 liquid 15 30 40
4 liquid  12 20 100
5 solid  13 15 100
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;
   set material;
   num liquid{material};
   num solid{material};
   num vehicle{material};
  
   read data material into material=[vehicle] liquid solid;

  
set factory;
   num id{factory};
   str inventory{factory};
   num east{factory};
   num north {factory};
   num supply{factory};
   read data factory into factory=[id] inventory east north supply;

 set EDGES = {i in factory, j in factory: i &amp;lt; j};
   num distance {&amp;lt;i,j&amp;gt; in EDGES} = 
      sqrt((east[i]-east[j])^2+(north[i]-north[j])^2);

	   var UseNode {factory} binary;
   var UseEdge {edges,material} binary;

   min TotalDistance 
      = sum {&amp;lt;i,j&amp;gt; in EDGES,k in material} distance[i,j] * UseEdge[i,j,k];

   con flow{k in material}:
      sum{&amp;lt;i,j&amp;gt; in edges} supply[i]*Useedge[i,j,k]
   &amp;lt;= (if inventory[i]="liquid" then liquid[k] else solid[k] );

   solve;
   quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 12:43:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/444716#M2204</guid>
      <dc:creator>ALexandraJ86</dc:creator>
      <dc:date>2018-03-12T12:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter Declaring</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/444889#M2205</link>
      <description>&lt;P&gt;I want to help, but I don't quite understand the business problem.&amp;nbsp; Can you please provide a sample solution (not necessarily optimal) that goes along with your sample data?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 19:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/444889#M2205</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-03-12T19:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter Declaring</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/445113#M2206</link>
      <description>&lt;P&gt;I couldn't a make proper sample to describe the problem clearly. I am trying to explain it again.&lt;/P&gt;&lt;P&gt;Each vehicle has both solid and liquid volumes.&lt;/P&gt;&lt;P&gt;The vehicles' volumes are specified at the material table as liquid and solid.&lt;/P&gt;&lt;P&gt;The factory's demand can be only solid or liquid.It is specified in factory data(inventory variable).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each vehicle tries to complete its volumes(solid and liquid).for example if a vehicle goes to a factory that has liquid inventory, this vehicle uses its liquid volume.if the same vehicle goes to a factory that has solid inventory,the vehicle uses its solid volume. So the flow constraint per vehicle changes according to factory inventory.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;con flow&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;k &lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt; material&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt;:
      &lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;lt;&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;j&lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt; edges&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt; supply&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;UseEdge&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;j&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;k&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;
   &lt;SPAN class="token operator"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; inventory&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"liquid"&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; liquid&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;k&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;else&lt;/SPAN&gt; solid&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;k&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The rhs part is important I couldnt declare the i parameter (inventory[i] )&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 11:40:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/445113#M2206</guid>
      <dc:creator>ALexandraJ86</dc:creator>
      <dc:date>2018-03-13T11:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter Declaring</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/445211#M2207</link>
      <description>&lt;P&gt;What is the meaning of the supply column?&amp;nbsp; Is it a capacity on the amount of liquid or solid that can be delivered to that factory?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where do the vehicles start and end?&amp;nbsp; For example, can vehicle 1 start at factory 3 and pay no cost (in terms of your distance objective) to arrive there?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I really think that a sample solution would help clarify the problem that you are trying to solve.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 15:48:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/445211#M2207</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-03-13T15:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter Declaring</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/445217#M2208</link>
      <description>I couldn't develop a model yet.Just trying to write ,declare parameters and constraints. I will add a depot that have no cost and every vehicle start and end their routes at this point. yes the supply column is the capacity that can be delivered to factories.</description>
      <pubDate>Tue, 13 Mar 2018 16:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/445217#M2208</guid>
      <dc:creator>ALexandraJ86</dc:creator>
      <dc:date>2018-03-13T16:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter Declaring</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/445658#M2209</link>
      <description>&lt;P&gt;OK, I think I understand now.&amp;nbsp; Besides the binary variables UseNode and UseEdge that you already have, you will also need continuous flow variables to represent the amount of liquid or solid&amp;nbsp;delivered to each factory by each vehicle:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   var LiquidFlow {i in FACTORIES, v in VEHICLES} &amp;gt;= 0 &amp;lt;= liquid[v];
   var SolidFlow {i in FACTORIES, v in VEHICLES} &amp;gt;= 0 &amp;lt;= solid[v];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the following constraints should capture the delivery of the liquids and solids:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   /* each vehicle must deliver its liquid */
   con LiquidVehicle {v in VEHICLES}:
      sum {i in FACTORIES} LiquidFlow[i,v] = liquid[v];

   /* each vehicle must deliver its solid */
   con SolidVehicle {v in VEHICLES}:
      sum {i in FACTORIES} SolidFlow[i,v] = solid[v];

   /* respect factory capacities */
   con LiquidFactory {i in FACTORIES}:
      sum {v in VEHICLES} LiquidFlow[i,v] 
   &amp;lt;= (if inventory[i] = 'liquid' then supply[i] else 0);
   con SolidFactory {i in FACTORIES}:
      sum {v in VEHICLES} SolidFlow[i,v] 
   &amp;lt;= (if inventory[i] = 'solid' then supply[i] else 0);

   /* if LiquidFlow[i,v] &amp;gt; 0 then UseNode[i,v] = 1 */
   con LiquidLogical {i in FACTORIES, v in VEHICLES}:
      LiquidFlow[i,v] &amp;lt;= LiquidFlow[i,v].ub * UseNode[i,v];

   /* if SolidFlow[i,v] &amp;gt; 0 then UseNode[i,v] = 1 */
   con SolidLogical {i in FACTORIES, v in VEHICLES}:
      SolidFlow[i,v] &amp;lt;= SolidFlow[i,v].ub * UseNode[i,v];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;A more efficient approach would use sparse index sets instead of introducing variables that must be 0.&amp;nbsp; See the &lt;A href="http://go.documentation.sas.com/?docsetId=ormpug&amp;amp;docsetTarget=ormpug_optmodel_examples07.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en" target="_self"&gt;Sparse Modeling example&lt;/A&gt; in the PROC OPTMODEL documentation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will need additional constraints to link the UseNode and UseEdge variables and to eliminate subtours.&amp;nbsp; See the "Milk Collection" and "Lost Baggage Distribution" examples in the &lt;A href="http://go.documentation.sas.com/?docsetId=ormpex&amp;amp;docsetTarget=titlepage.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en" target="_self"&gt;Mathematical Programming Examples documentation&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 22:43:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/445658#M2209</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-03-14T22:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter Declaring</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/445748#M2210</link>
      <description>&lt;P&gt;Wow that isn't easy as I thought. Thank you very much.:smileyhappy&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 07:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Parameter-Declaring/m-p/445748#M2210</guid>
      <dc:creator>ALexandraJ86</dc:creator>
      <dc:date>2018-03-15T07:42:16Z</dc:date>
    </item>
  </channel>
</rss>

