<?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 to Load 3D data to Proc Optmodel in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-Load-3D-data-to-Proc-Optmodel/m-p/729165#M3363</link>
    <description>&lt;P&gt;Like a previous poster, I'm trying to get a 3D data into PROC OPTMODEL. This is my first foray into optimization and OPTMODEL so I'm sure I'm making many beginner mistakes.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Here's the problem:&lt;/P&gt;
&lt;P&gt;I have a dataset with four variables: Camera, Orientation, Target, k.&lt;BR /&gt;For each observation, k is 1 if Target (t) is in the field of view of Orientation (r) of Camera (c); else, k is 0.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;There are 22 Cameras each with 8 possible Orientations available to cover 49 Gridpoints for a total of 8624 observations.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;How can I get this dataset into a 3D array (I'm calling it Matrix {CAMERAS, ORIENTATIONS, TARGETS} populated with the binary k values for optimization by Proc OPTMODEL and indexed by CAMERAS, ORIENTATIONS and TARGETS?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Below is the code that I've developed so far together with a few lines of the dataset work.coveragematrix. In the code provided, I first read ID's for CAMERAS from a separate dataset (work.cameraorientations), hardcode the 8 possible ORIENTATIONS, and read the ID codes for TARGETS from the data step at the beginning of the code. Next I establish the new array MATRIX which is to be filled with k-values from dataset work.coveragematrix. This is where things go horribly wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create data for Targets:  7x7 matrix of gridpoints is 49 total*/
data targets(drop=i);
do i=1 to 49;
gridpoint=i;
output;
end;
Proc optmodel;
/* Read CoverageMatrix data into index sets*/
	set &amp;lt;str&amp;gt; CAMERAS;
	read data work.cameraorientations into CAMERAS=[station];
	set &amp;lt;str&amp;gt; ORIENTATIONS=/'NHI' 'NLO' 'EHI' 'ELO' 'SHO' 'SLO' 'WHI' 'WLO'/;
	set &amp;lt;num&amp;gt; TARGETS;
	num Matrix {CAMERAS, ORIENTATIONS, TARGETS};
	read data work.CoverageMatrix into MATRIX= {c in CAMERAS, r in ORIENTATIONS, t in TARGETS}
	print matrix;
	quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Below is the log output, together with a snippet of work.coveragematrix&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thanks in advance for any guidance.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Gene&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         /* Create data for Targets:  7x7 matrix of gridpoints is 49 total*/
 74         data targets(drop=i);
 75         do i=1 to 49;
 76         gridpoint=i;
 77         output;
 78         end;
 
 NOTE: The data set WORK.TARGETS has 49 observations and 1 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              661.31k
       OS Memory           33964.00k
       Timestamp           03/25/2021 06:25:52 PM
       Step Count                        57  Switch Count  2
       Page Faults                       0
       Page Reclaims                     147
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 79         Proc optmodel;
 80         /* Read CoverageMatrix data into index sets*/
 81         set &amp;lt;str&amp;gt; CAMERAS;
 82         read data work.cameraorientations into CAMERAS=[station];
 NOTE: There were 22 observations read from the data set WORK.CAMERAORIENTATIONS.
 83         set &amp;lt;str&amp;gt; ORIENTATIONS=/'NHI' 'NLO' 'EHI' 'ELO' 'SHO' 'SLO' 'WHI' 'WLO'/;
 84         set &amp;lt;num&amp;gt; TARGETS;
 85         num Matrix {CAMERAS, ORIENTATIONS, TARGETS};
 86         read data work.CoverageMatrix into MATRIX= {c in CAMERAS, r in ORIENTATIONS, t in TARGETS}
                                                        _
                                                        22
 1          NAME
            ____
            583
 87         print matrix;
             _____
             79
             76
 ERROR 22-322: Syntax error, expecting one of the following: a name, COL.  
 
 ERROR 583-782: The implied subscript count does not match array 'Matrix', 0 NE 3.
 
 ERROR 79-322: Expecting a &amp;lt;.
 
 ERROR 76-322: Syntax error, statement will be ignored.
 
 88         quit;
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE OPTMODEL used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              1035.29k
       OS Memory           34228.00k
       Timestamp           03/25/2021 06:25:52 PM
       Step Count                        58  Switch Count  0
       Page Faults                       0
       Page Reclaims                     54
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 89         
 90         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 102        &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Snippet of data from dataset work.coveragmatrix&lt;/P&gt;
&lt;P&gt;camera orientation target k&lt;BR /&gt;US000A NLO 1 0&lt;BR /&gt;US000A NHI 1 0&lt;BR /&gt;US000A ELO 1 0&lt;BR /&gt;US000A SLO 11 1&lt;BR /&gt;US000A SHI 11 1&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Mar 2021 19:04:53 GMT</pubDate>
    <dc:creator>genemroz</dc:creator>
    <dc:date>2021-03-25T19:04:53Z</dc:date>
    <item>
      <title>How to Load 3D data to Proc Optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-Load-3D-data-to-Proc-Optmodel/m-p/729165#M3363</link>
      <description>&lt;P&gt;Like a previous poster, I'm trying to get a 3D data into PROC OPTMODEL. This is my first foray into optimization and OPTMODEL so I'm sure I'm making many beginner mistakes.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Here's the problem:&lt;/P&gt;
&lt;P&gt;I have a dataset with four variables: Camera, Orientation, Target, k.&lt;BR /&gt;For each observation, k is 1 if Target (t) is in the field of view of Orientation (r) of Camera (c); else, k is 0.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;There are 22 Cameras each with 8 possible Orientations available to cover 49 Gridpoints for a total of 8624 observations.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;How can I get this dataset into a 3D array (I'm calling it Matrix {CAMERAS, ORIENTATIONS, TARGETS} populated with the binary k values for optimization by Proc OPTMODEL and indexed by CAMERAS, ORIENTATIONS and TARGETS?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Below is the code that I've developed so far together with a few lines of the dataset work.coveragematrix. In the code provided, I first read ID's for CAMERAS from a separate dataset (work.cameraorientations), hardcode the 8 possible ORIENTATIONS, and read the ID codes for TARGETS from the data step at the beginning of the code. Next I establish the new array MATRIX which is to be filled with k-values from dataset work.coveragematrix. This is where things go horribly wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create data for Targets:  7x7 matrix of gridpoints is 49 total*/
data targets(drop=i);
do i=1 to 49;
gridpoint=i;
output;
end;
Proc optmodel;
/* Read CoverageMatrix data into index sets*/
	set &amp;lt;str&amp;gt; CAMERAS;
	read data work.cameraorientations into CAMERAS=[station];
	set &amp;lt;str&amp;gt; ORIENTATIONS=/'NHI' 'NLO' 'EHI' 'ELO' 'SHO' 'SLO' 'WHI' 'WLO'/;
	set &amp;lt;num&amp;gt; TARGETS;
	num Matrix {CAMERAS, ORIENTATIONS, TARGETS};
	read data work.CoverageMatrix into MATRIX= {c in CAMERAS, r in ORIENTATIONS, t in TARGETS}
	print matrix;
	quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Below is the log output, together with a snippet of work.coveragematrix&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thanks in advance for any guidance.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Gene&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         /* Create data for Targets:  7x7 matrix of gridpoints is 49 total*/
 74         data targets(drop=i);
 75         do i=1 to 49;
 76         gridpoint=i;
 77         output;
 78         end;
 
 NOTE: The data set WORK.TARGETS has 49 observations and 1 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              661.31k
       OS Memory           33964.00k
       Timestamp           03/25/2021 06:25:52 PM
       Step Count                        57  Switch Count  2
       Page Faults                       0
       Page Reclaims                     147
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 79         Proc optmodel;
 80         /* Read CoverageMatrix data into index sets*/
 81         set &amp;lt;str&amp;gt; CAMERAS;
 82         read data work.cameraorientations into CAMERAS=[station];
 NOTE: There were 22 observations read from the data set WORK.CAMERAORIENTATIONS.
 83         set &amp;lt;str&amp;gt; ORIENTATIONS=/'NHI' 'NLO' 'EHI' 'ELO' 'SHO' 'SLO' 'WHI' 'WLO'/;
 84         set &amp;lt;num&amp;gt; TARGETS;
 85         num Matrix {CAMERAS, ORIENTATIONS, TARGETS};
 86         read data work.CoverageMatrix into MATRIX= {c in CAMERAS, r in ORIENTATIONS, t in TARGETS}
                                                        _
                                                        22
 1          NAME
            ____
            583
 87         print matrix;
             _____
             79
             76
 ERROR 22-322: Syntax error, expecting one of the following: a name, COL.  
 
 ERROR 583-782: The implied subscript count does not match array 'Matrix', 0 NE 3.
 
 ERROR 79-322: Expecting a &amp;lt;.
 
 ERROR 76-322: Syntax error, statement will be ignored.
 
 88         quit;
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE OPTMODEL used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              1035.29k
       OS Memory           34228.00k
       Timestamp           03/25/2021 06:25:52 PM
       Step Count                        58  Switch Count  0
       Page Faults                       0
       Page Reclaims                     54
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 89         
 90         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 102        &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Snippet of data from dataset work.coveragmatrix&lt;/P&gt;
&lt;P&gt;camera orientation target k&lt;BR /&gt;US000A NLO 1 0&lt;BR /&gt;US000A NHI 1 0&lt;BR /&gt;US000A ELO 1 0&lt;BR /&gt;US000A SLO 11 1&lt;BR /&gt;US000A SHI 11 1&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 19:04:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-Load-3D-data-to-Proc-Optmodel/m-p/729165#M3363</guid>
      <dc:creator>genemroz</dc:creator>
      <dc:date>2021-03-25T19:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to Load 3D data to Proc Optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-Load-3D-data-to-Proc-Optmodel/m-p/729197#M3364</link>
      <description>&lt;P&gt;It looks like you forgot to read the targets, which you can do as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   read data targets into TARGETS=[gridpoint];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The correct READ DATA statement to populate Matrix is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	read data CoverageMatrix into [camera orientation target] Matrix=k;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Mar 2021 19:05:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-Load-3D-data-to-Proc-Optmodel/m-p/729197#M3364</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2021-03-25T19:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to Load 3D data to Proc Optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-Load-3D-data-to-Proc-Optmodel/m-p/729211#M3365</link>
      <description>Thanks, Rob, for your prompt reply and spot-on-advice.&lt;BR /&gt;&lt;BR /&gt;Gene</description>
      <pubDate>Thu, 25 Mar 2021 19:43:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-Load-3D-data-to-Proc-Optmodel/m-p/729211#M3365</guid>
      <dc:creator>genemroz</dc:creator>
      <dc:date>2021-03-25T19:43:45Z</dc:date>
    </item>
  </channel>
</rss>

