<?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 Proc optmodel: initializing an array-variable ? in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Proc-optmodel-initializing-an-array-variable/m-p/255838#M1253</link>
    <description>&lt;P&gt;Good afternoon fellow SAS-users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am dealing with a non-linear problem using Proc optmodel (SAS 9.4).&lt;/P&gt;&lt;P&gt;I am optimizing a diet (i.e a list of foods (n=400) with their respecting daily quantities). My objective function minimizes the deviation from the initial (or "observed") diet, and a set of linear and non-linear constraints is imposed.&lt;/P&gt;&lt;P&gt;The variables are thus the (optimized) quantities of the 400 foods.&lt;/P&gt;&lt;P&gt;Here part of my code to show how I defined my variables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set&amp;lt;str&amp;gt; foods;
/* [...] */

num qte_obs{foods}; /* this are the observed  quantities (what the population currently eats) */
/* [...] */

var qte_opt{foods}  &amp;gt;=0; /* in this case, no initialization specified */
/* [...] */&lt;BR /&gt;&lt;BR /&gt;minimize deviation = sum{p in foods}(delta[p]/qte_obs[p]); /* with delta[p] defined as (qte_opt[p] - qte_obs[p])*/
/* [...] */&lt;BR /&gt;
read data foods2 into foods=[_CODAL]  qte_obs=MEAN;
/* foods2 is the table that provides the observed quantities for each food item (column MEAN), _CODAL is the ID of each food item */&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I noticed that different initializations values may result in different optimal solutions.&lt;/P&gt;&lt;P&gt;So far I used the following syntax to initialize the variables :&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;var qte_opt{foods} init 3 &amp;gt;=0;   /* 3 is just an example*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Doing so, all the 400 quantities are initialized at 3 (3 g/day).&lt;/P&gt;&lt;P&gt;I would like each of the 400 variables to be initialized at a given value, i.e the observed value. The point of departure would thus be the observed diet.&lt;/P&gt;&lt;P&gt;I tried many syntaxes, all resulting in various errors. Here what I tried, to give you an idea of what I want :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var qte_opt{foods} init [1	... 400] &amp;gt;=0; /* I exhaustively typed 400 values: from 1 to 400 (as a try, the real values would be the 400 observed values)*/
&lt;BR /&gt;/* ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,
              a numeric constant, a datetime constant, a missing value, (, +, -, /, IF, INPUT,
              INTER, MAX, MIN, PROD, PUT, SETOF, SLICE, SUM, UNION, {.
ERROR 200-322: The symbol is not recognized and will be ignored. */&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;other try closer to what I want:&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;var qte_opt{foods} init qte_obs{foods} &amp;gt;=0; 

/*ERROR 22-322: Syntax error, expecting one of the following: !!, (, *, **, +, -, .., /, &amp;lt;=, &amp;lt;&amp;gt;,
              &amp;gt;&amp;lt;, &amp;gt;=, BY, CROSS, DIFF, ELSE, INIT, INTER, SYMDIFF, TO, UNION, [, ^, ||.

ERROR 76-322: Syntax error, statement will be ignored.*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and other unsuccessful attempts...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wondering &lt;STRONG&gt;if it is possible to do such an initialization, and what is the correct syntax&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;T.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Mar 2016 16:35:53 GMT</pubDate>
    <dc:creator>Tangui</dc:creator>
    <dc:date>2016-03-10T16:35:53Z</dc:date>
    <item>
      <title>Proc optmodel: initializing an array-variable ?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Proc-optmodel-initializing-an-array-variable/m-p/255838#M1253</link>
      <description>&lt;P&gt;Good afternoon fellow SAS-users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am dealing with a non-linear problem using Proc optmodel (SAS 9.4).&lt;/P&gt;&lt;P&gt;I am optimizing a diet (i.e a list of foods (n=400) with their respecting daily quantities). My objective function minimizes the deviation from the initial (or "observed") diet, and a set of linear and non-linear constraints is imposed.&lt;/P&gt;&lt;P&gt;The variables are thus the (optimized) quantities of the 400 foods.&lt;/P&gt;&lt;P&gt;Here part of my code to show how I defined my variables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set&amp;lt;str&amp;gt; foods;
/* [...] */

num qte_obs{foods}; /* this are the observed  quantities (what the population currently eats) */
/* [...] */

var qte_opt{foods}  &amp;gt;=0; /* in this case, no initialization specified */
/* [...] */&lt;BR /&gt;&lt;BR /&gt;minimize deviation = sum{p in foods}(delta[p]/qte_obs[p]); /* with delta[p] defined as (qte_opt[p] - qte_obs[p])*/
/* [...] */&lt;BR /&gt;
read data foods2 into foods=[_CODAL]  qte_obs=MEAN;
/* foods2 is the table that provides the observed quantities for each food item (column MEAN), _CODAL is the ID of each food item */&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I noticed that different initializations values may result in different optimal solutions.&lt;/P&gt;&lt;P&gt;So far I used the following syntax to initialize the variables :&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;var qte_opt{foods} init 3 &amp;gt;=0;   /* 3 is just an example*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Doing so, all the 400 quantities are initialized at 3 (3 g/day).&lt;/P&gt;&lt;P&gt;I would like each of the 400 variables to be initialized at a given value, i.e the observed value. The point of departure would thus be the observed diet.&lt;/P&gt;&lt;P&gt;I tried many syntaxes, all resulting in various errors. Here what I tried, to give you an idea of what I want :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var qte_opt{foods} init [1	... 400] &amp;gt;=0; /* I exhaustively typed 400 values: from 1 to 400 (as a try, the real values would be the 400 observed values)*/
&lt;BR /&gt;/* ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,
              a numeric constant, a datetime constant, a missing value, (, +, -, /, IF, INPUT,
              INTER, MAX, MIN, PROD, PUT, SETOF, SLICE, SUM, UNION, {.
ERROR 200-322: The symbol is not recognized and will be ignored. */&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;other try closer to what I want:&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;var qte_opt{foods} init qte_obs{foods} &amp;gt;=0; 

/*ERROR 22-322: Syntax error, expecting one of the following: !!, (, *, **, +, -, .., /, &amp;lt;=, &amp;lt;&amp;gt;,
              &amp;gt;&amp;lt;, &amp;gt;=, BY, CROSS, DIFF, ELSE, INIT, INTER, SYMDIFF, TO, UNION, [, ^, ||.

ERROR 76-322: Syntax error, statement will be ignored.*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and other unsuccessful attempts...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wondering &lt;STRONG&gt;if it is possible to do such an initialization, and what is the correct syntax&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;T.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 16:35:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Proc-optmodel-initializing-an-array-variable/m-p/255838#M1253</guid>
      <dc:creator>Tangui</dc:creator>
      <dc:date>2016-03-10T16:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Proc optmodel: initializing an array-variable ?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Proc-optmodel-initializing-an-array-variable/m-p/255914#M1255</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var qte_opt{p in foods} init qte_obs[p] &amp;gt;=0; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Mar 2016 19:57:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Proc-optmodel-initializing-an-array-variable/m-p/255914#M1255</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2016-03-10T19:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: Proc optmodel: initializing an array-variable ?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Proc-optmodel-initializing-an-array-variable/m-p/256033#M1257</link>
      <description>&lt;P&gt;Perfect !&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2016 08:02:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Proc-optmodel-initializing-an-array-variable/m-p/256033#M1257</guid>
      <dc:creator>Tangui</dc:creator>
      <dc:date>2016-03-11T08:02:43Z</dc:date>
    </item>
  </channel>
</rss>

