<?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: Optmilp: read composed index with missing values in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Optmilp-read-composed-index-with-missing-values/m-p/902281#M4049</link>
    <description>&lt;P&gt;Thank you, this is exactly what I needed!&lt;/P&gt;
&lt;P&gt;(Your are correct, it's optmodel, but I was thinking about something else, sorry.)&lt;/P&gt;</description>
    <pubDate>Thu, 09 Nov 2023 07:48:58 GMT</pubDate>
    <dc:creator>asasgdsfa</dc:creator>
    <dc:date>2023-11-09T07:48:58Z</dc:date>
    <item>
      <title>Optmilp: read composed index with missing values</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Optmilp-read-composed-index-with-missing-values/m-p/901860#M4047</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May I ask for an advise? I'm trying to read 2D data to proc optmilp and I'm getting error:&lt;BR /&gt;"ERROR: The symbol 'student' has no value at line XXX column YYY"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think, it is because I'm trying to load data where not all combinations of indices are present.&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;student&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;class&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;payment&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;1&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;A&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;2&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;A&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;2&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;B&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;3&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;A&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;3&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;B&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;So here, you can see that there is not combination of studen 1 in class B. Could this be a reason for the error?&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Code:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmilp;
	set student;
	set &amp;lt;str&amp;gt; class;
	
	num income {student, class};
	read data work.input into [student class] payment = income;
	
	...
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I need to have data in the single table and filling missing records (1-B) would probably lead to numerically more difficult task.&lt;/DIV&gt;
&lt;DIV&gt;I tried to use only a single index (composed of student-class) and it worked, but for the problem, I need to access these two indexes independently.&lt;/DIV&gt;</description>
      <pubDate>Tue, 07 Nov 2023 08:23:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Optmilp-read-composed-index-with-missing-values/m-p/901860#M4047</guid>
      <dc:creator>asasgdsfa</dc:creator>
      <dc:date>2023-11-07T08:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: Optmilp: read composed index with missing values</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Optmilp-read-composed-index-with-missing-values/m-p/901880#M4048</link>
      <description>&lt;P&gt;A couple of suggestions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;1.&amp;nbsp; You're calling the OPTMILP procedure, but the syntax more closely resembles the OPTMODEL procedure. Change PROC OPTMILP to PROC OPTMODEL&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*proc optmilp;

proc optmodel;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; 2.&amp;nbsp; Declare a set of ARCS indexed by both students and classes. Declare a payment parameter indexed by ARCS, and read the table into the OPTMODEL procedure.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set &amp;lt;num,str&amp;gt; ARCS;

num payment{ARCS};

read data work.input into ARCS = [student class] payment;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; 3.&amp;nbsp; To create a set of STUDENTS and a set of CLASSES from the ARCS set, use the setof{ } operator.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set STUDENTS = setof{&amp;lt;s,c&amp;gt; in ARCS} s;

set CLASSES = setof{&amp;lt;s,c&amp;gt; in ARCS} c;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Full code below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.input;
 input student class $ payment;
datalines;
1 A 1
2 A 2
2 B 3
3 A 4
3 B 5
;

*proc optmilp;
proc optmodel;

set &amp;lt;num,str&amp;gt; ARCS;

num payment{ARCS};

read data work.input into ARCS = [student class] payment;

set STUDENTS = setof{&amp;lt;s,c&amp;gt; in ARCS} s;
set CLASSES = setof{&amp;lt;s,c&amp;gt; in ARCS} c;

/* write the elements of each set to the log */
put ARCS=;
put STUDENTS=;
put CLASSES=;

/* print payment to the results viewer */
print payment;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Structuring it this way allows you to sum across all students, or sum across all classes later in the program without the missing element &amp;lt;1,B&amp;gt; causing an issue:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;num total_by_class{c in CLASSES} = sum{&amp;lt;s,(c)&amp;gt; in ARCS} payment[s,c];

num total_by_student{s in STUDENTS} = sum{&amp;lt;(s),c&amp;gt; in ARCS} payment[s,c];

print total_by_class;
print total_by_student;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The MISSINGS set below captures all of the student-class combinations not present in your data, and as a result, not part of the new calculated parameters above.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set MISSINGS = (STUDENTS cross CLASSES) diff ARCS; 
put MISSINGS=;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Nov 2023 14:01:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Optmilp-read-composed-index-with-missing-values/m-p/901880#M4048</guid>
      <dc:creator>ChanceTGardener</dc:creator>
      <dc:date>2023-11-07T14:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: Optmilp: read composed index with missing values</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Optmilp-read-composed-index-with-missing-values/m-p/902281#M4049</link>
      <description>&lt;P&gt;Thank you, this is exactly what I needed!&lt;/P&gt;
&lt;P&gt;(Your are correct, it's optmodel, but I was thinking about something else, sorry.)&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 07:48:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Optmilp-read-composed-index-with-missing-values/m-p/902281#M4049</guid>
      <dc:creator>asasgdsfa</dc:creator>
      <dc:date>2023-11-09T07:48:58Z</dc:date>
    </item>
  </channel>
</rss>

