<?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: Reading multidimensional sets into proc optmodel in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Reading-multidimensional-sets-into-proc-optmodel/m-p/201818#M1041</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Shouldn't you have values to read in for proc optmodel? Anyway, maybe this code-snippet is helpful, even though I'm pretty sure, it's not what you are trying to (eventually!) accomplish. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Company_Data;&lt;BR /&gt;&amp;nbsp; input Customer $ Bill $ Value;&lt;BR /&gt;&amp;nbsp; datalines;&lt;BR /&gt;&amp;nbsp; cust1 B1 1&lt;BR /&gt;&amp;nbsp; cust1 B2 2&lt;BR /&gt;&amp;nbsp; cust1 B3 3&lt;BR /&gt;&amp;nbsp; cust2 B4 4&lt;BR /&gt;&amp;nbsp; cust3 B5 5&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt; &lt;BR /&gt;Proc Optmodel;&lt;BR /&gt;&amp;nbsp; Set &amp;lt;Str,Str&amp;gt; c_b;&lt;BR /&gt;&amp;nbsp; Num Comp_Data{c_b};&lt;BR /&gt;&amp;nbsp; Set Customer =SetOf{&amp;lt;c,b&amp;gt; in c_b} c;&lt;BR /&gt;&amp;nbsp; Set Bill =SetOf{&amp;lt;c,b&amp;gt; in c_b} b;&lt;BR /&gt;&amp;nbsp; Read Data Company_Data into c_b=[Customer Bill] Comp_Data=Value;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Print Comp_Data;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Jul 2015 12:10:28 GMT</pubDate>
    <dc:creator>user24feb</dc:creator>
    <dc:date>2015-07-14T12:10:28Z</dc:date>
    <item>
      <title>Reading multidimensional sets into proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Reading-multidimensional-sets-into-proc-optmodel/m-p/201817#M1040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Hi fellow SAS-users!&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;After much frustration and a lot of reading up on the proc optmodel and examples I turn to you. &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Essentially I am trying, by using sets, to read in some data which varies in the number of elements in several dimension. A simplified example of what I want would is:&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;data Company_Data;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; input Customer Bill;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; datalines;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; cust1 B1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; cust1 B2&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; cust1 B3&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; cust2 B4&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; cust3 B5&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;proc optmodel;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;set&amp;lt;string&amp;gt; Customers init {};&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;set&amp;lt;string&amp;gt; Bills{c in Customers};&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;read data Company_Data into Customers=[customer];&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;/*Magic to get Bills read into the model */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;/*What I want*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;Customers={'cust1','cust2','cust3'};&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;Bills['cust1'] = {'B1', 'B2', 'B3'};&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;Bills['cust2'] = {'B4'};&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;Bills['cust3'] = {'B5'};&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;/* End of model */&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;I have tried looking into different constructions of the read into as well as looping over the members of Bills, but unable to get the right data into the model. This feels like a thing that should be fairly easy. Alas I just cannot get it right. &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Any thoughts?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 07:36:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Reading-multidimensional-sets-into-proc-optmodel/m-p/201817#M1040</guid>
      <dc:creator>TueChristensen</dc:creator>
      <dc:date>2015-07-14T07:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: Reading multidimensional sets into proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Reading-multidimensional-sets-into-proc-optmodel/m-p/201818#M1041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Shouldn't you have values to read in for proc optmodel? Anyway, maybe this code-snippet is helpful, even though I'm pretty sure, it's not what you are trying to (eventually!) accomplish. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Company_Data;&lt;BR /&gt;&amp;nbsp; input Customer $ Bill $ Value;&lt;BR /&gt;&amp;nbsp; datalines;&lt;BR /&gt;&amp;nbsp; cust1 B1 1&lt;BR /&gt;&amp;nbsp; cust1 B2 2&lt;BR /&gt;&amp;nbsp; cust1 B3 3&lt;BR /&gt;&amp;nbsp; cust2 B4 4&lt;BR /&gt;&amp;nbsp; cust3 B5 5&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt; &lt;BR /&gt;Proc Optmodel;&lt;BR /&gt;&amp;nbsp; Set &amp;lt;Str,Str&amp;gt; c_b;&lt;BR /&gt;&amp;nbsp; Num Comp_Data{c_b};&lt;BR /&gt;&amp;nbsp; Set Customer =SetOf{&amp;lt;c,b&amp;gt; in c_b} c;&lt;BR /&gt;&amp;nbsp; Set Bill =SetOf{&amp;lt;c,b&amp;gt; in c_b} b;&lt;BR /&gt;&amp;nbsp; Read Data Company_Data into c_b=[Customer Bill] Comp_Data=Value;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Print Comp_Data;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 12:10:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Reading-multidimensional-sets-into-proc-optmodel/m-p/201818#M1041</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2015-07-14T12:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: Reading multidimensional sets into proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Reading-multidimensional-sets-into-proc-optmodel/m-p/201819#M1042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The example I showed was just part of bigger program and the parts in question is used to generated sets which I iterate over. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically what I am doing is defing the set I and J where J(i \in I). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will look into if I can use the idea of mapping everything into a set of several string (would be something like set&amp;lt;string,string,string, string&amp;gt; in my case) and then use SetOf to create the indices after reading the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the reply! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 12:59:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Reading-multidimensional-sets-into-proc-optmodel/m-p/201819#M1042</guid>
      <dc:creator>TueChristensen</dc:creator>
      <dc:date>2015-07-14T12:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Reading multidimensional sets into proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Reading-multidimensional-sets-into-proc-optmodel/m-p/201820#M1043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Got it!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One can use the setof function to extrapolate the data. The drawback is that one has to read all the data into the model, but for my reasonably small problems this will be no problem at all. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following code does what I want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Company_Data;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input Customer $ Bill $;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cust1 B1&lt;/P&gt;&lt;P&gt;&amp;nbsp; cust1 B2&lt;/P&gt;&lt;P&gt;&amp;nbsp; cust1 B3&lt;/P&gt;&lt;P&gt;&amp;nbsp; cust2 B4&lt;/P&gt;&lt;P&gt;&amp;nbsp; cust3 B5&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc optmodel;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set&amp;lt;string&amp;gt; Customers init {};&lt;/P&gt;&lt;P&gt;set&amp;lt;string&amp;gt; Bills{c in Customers};&lt;/P&gt;&lt;P&gt;set&amp;lt;string, string&amp;gt; AllData;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read data Company_Data into AllData=[customer Bill];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*This is what I want */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Customers = (setof{&amp;lt;i,j&amp;gt; in AllData} i); &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for {c in Customers} Bills&lt;C&gt; = (setof{&amp;lt;i,b&amp;gt; in AllData: i=c} b);&lt;/C&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;put Customers;&lt;/P&gt;&lt;P&gt;put Bills&lt;LI&gt;;&lt;/LI&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 14:03:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Reading-multidimensional-sets-into-proc-optmodel/m-p/201820#M1043</guid>
      <dc:creator>TueChristensen</dc:creator>
      <dc:date>2015-07-14T14:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Reading multidimensional sets into proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Reading-multidimensional-sets-into-proc-optmodel/m-p/201821#M1044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad you got it working.&amp;nbsp; Below is an alternative approach that passes through the data only once (instead of once per customer) after reading it.&amp;nbsp; For large data, you might see a performance improvement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc optmodel;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set&amp;lt;string&amp;gt; Customers init {};&lt;/P&gt;&lt;P&gt;set&amp;lt;string&amp;gt; Bills{c in Customers} init {};&lt;/P&gt;&lt;P&gt;set&amp;lt;string, string&amp;gt; AllData;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read data Company_Data into AllData=[customer Bill];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*This is what I want */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for {&amp;lt;i,j&amp;gt; in AllData} do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Customers = Customers union {i};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Bills&lt;I&gt; = Bills&lt;I&gt; union {j};&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;put Customers;&lt;/P&gt;&lt;P&gt;put Bills&lt;LI&gt;;&lt;/LI&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 14:14:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Reading-multidimensional-sets-into-proc-optmodel/m-p/201821#M1044</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2015-07-14T14:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Reading multidimensional sets into proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Reading-multidimensional-sets-into-proc-optmodel/m-p/201822#M1045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi RobPratt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your approach surely seem to be more efficient! I will try it out for my final implementation. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jul 2015 06:16:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Reading-multidimensional-sets-into-proc-optmodel/m-p/201822#M1045</guid>
      <dc:creator>TueChristensen</dc:creator>
      <dc:date>2015-07-15T06:16:57Z</dc:date>
    </item>
  </channel>
</rss>

