<?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 Help Wanted: Coding a Constraint in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Help-Wanted-Coding-a-Constraint/m-p/781283#M3533</link>
    <description>&lt;P&gt;Esteemed Advisers&lt;/P&gt;
&lt;P&gt;I'm working to develop a general optimization approach for aiming a network of meteor cameras. The goal of this particular version of the model is to find the optimal orientation of 5 stations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to include a "constraint" in the model such that the optimal solution does not allow selected stations to be oriented in the same direction. To wit: given five stations (A,B,C,D and E), where Stations A and B are co-located as are Stations C and D (at a different location than A,B). How do I code a constraint that prohibits solutions where stations A,B have the same orientation and stations C,D have the same orientation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code below is the current Proc Optmodel statement that I am using.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks in advance for any guidance you can provide.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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;Proc Optmodel;
	/* Read CoverageMatrix data into index sets*/
						set &amp;lt;str&amp;gt; stations;
						read data work.stationindex into stations=[station];
/* 						
/*						Modify Orientations below to reflect addition of elevation angles of 40 and 50 degrees */
						set &amp;lt;str&amp;gt; ORIENTATIONS=/'360/55' '360/50' '360/45' '360/40' '360/35' '45/55' '45/50' 
						'45/45' '45/40' '45/35' '90/55' '90/50' '90/45' '90/40' '90/35' '135/55' '135/50' 
						'135/45' '135/40' '135/35' '180/55' '180/50' '180/45' '180/40' '180/35' '225/55' 
						'225/50' '225/45' '225/40' '225/35' '270/55' '270/50' '270/45' '270/40' '270/35' 
						'315/55' '315/50' '315/45' '315/40' '315/35'/;
							
						set &amp;lt;str&amp;gt; Targets;
						read data work.targets into TARGETS=[target];
						num Matrix {stations, ORIENTATIONS, TARGETS};
						read data work.RoOMatrix into [station orientation target] 
							Matrix=k;

						/* Set Constants*/
						/* optimal number of cameras covering each target*/						
						%Let k=3;
						num k=&amp;amp;k;
						/*Declare Variables*/
						var CHI {stations, ORIENTATIONS} binary;
						var IsTriplyCovered {TARGETS} binary;
						impvar XIT{target in TARGETS}=sum{station in stations, orientation in 
							orientations} matrix[station, orientation, target] *Chi[station, 
							orientation];

						/* Declare Model*/
						max NumTriplyCovered=sum{t in TARGETS} IsTriplyCovered[t];

						/*Subject to Following Constraints*/
						con CHI_constraint {station in stations}: 
						sum{orientation in ORIENTATIONS}CHI[station, orientation] &amp;lt;=1;
						con TriplyCoveredCon {t in TARGETS}: XIT[t] &amp;gt;=k * IsTriplyCovered[t];

						/* Call Solver and Save Results:*/
						solve with milp/ relobjgap=&amp;amp;relobjgap;
/* 						solve; */
						create data work.OptimalSolution_&amp;amp;RoO from 
						[station orientation]={c in stations, o in orientations: CHI[c, o]&amp;gt;0.5} CHI;
					quit;
						/*Print Results*/
						proc print data=work.optimalsolution_&amp;amp;RoO;
						Title "Optimal Solution RoO=&amp;amp;RoO x &amp;amp;RoO km";
					run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 19 Nov 2021 15:36:08 GMT</pubDate>
    <dc:creator>genemroz</dc:creator>
    <dc:date>2021-11-19T15:36:08Z</dc:date>
    <item>
      <title>Help Wanted: Coding a Constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Help-Wanted-Coding-a-Constraint/m-p/781283#M3533</link>
      <description>&lt;P&gt;Esteemed Advisers&lt;/P&gt;
&lt;P&gt;I'm working to develop a general optimization approach for aiming a network of meteor cameras. The goal of this particular version of the model is to find the optimal orientation of 5 stations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to include a "constraint" in the model such that the optimal solution does not allow selected stations to be oriented in the same direction. To wit: given five stations (A,B,C,D and E), where Stations A and B are co-located as are Stations C and D (at a different location than A,B). How do I code a constraint that prohibits solutions where stations A,B have the same orientation and stations C,D have the same orientation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code below is the current Proc Optmodel statement that I am using.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks in advance for any guidance you can provide.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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;Proc Optmodel;
	/* Read CoverageMatrix data into index sets*/
						set &amp;lt;str&amp;gt; stations;
						read data work.stationindex into stations=[station];
/* 						
/*						Modify Orientations below to reflect addition of elevation angles of 40 and 50 degrees */
						set &amp;lt;str&amp;gt; ORIENTATIONS=/'360/55' '360/50' '360/45' '360/40' '360/35' '45/55' '45/50' 
						'45/45' '45/40' '45/35' '90/55' '90/50' '90/45' '90/40' '90/35' '135/55' '135/50' 
						'135/45' '135/40' '135/35' '180/55' '180/50' '180/45' '180/40' '180/35' '225/55' 
						'225/50' '225/45' '225/40' '225/35' '270/55' '270/50' '270/45' '270/40' '270/35' 
						'315/55' '315/50' '315/45' '315/40' '315/35'/;
							
						set &amp;lt;str&amp;gt; Targets;
						read data work.targets into TARGETS=[target];
						num Matrix {stations, ORIENTATIONS, TARGETS};
						read data work.RoOMatrix into [station orientation target] 
							Matrix=k;

						/* Set Constants*/
						/* optimal number of cameras covering each target*/						
						%Let k=3;
						num k=&amp;amp;k;
						/*Declare Variables*/
						var CHI {stations, ORIENTATIONS} binary;
						var IsTriplyCovered {TARGETS} binary;
						impvar XIT{target in TARGETS}=sum{station in stations, orientation in 
							orientations} matrix[station, orientation, target] *Chi[station, 
							orientation];

						/* Declare Model*/
						max NumTriplyCovered=sum{t in TARGETS} IsTriplyCovered[t];

						/*Subject to Following Constraints*/
						con CHI_constraint {station in stations}: 
						sum{orientation in ORIENTATIONS}CHI[station, orientation] &amp;lt;=1;
						con TriplyCoveredCon {t in TARGETS}: XIT[t] &amp;gt;=k * IsTriplyCovered[t];

						/* Call Solver and Save Results:*/
						solve with milp/ relobjgap=&amp;amp;relobjgap;
/* 						solve; */
						create data work.OptimalSolution_&amp;amp;RoO from 
						[station orientation]={c in stations, o in orientations: CHI[c, o]&amp;gt;0.5} CHI;
					quit;
						/*Print Results*/
						proc print data=work.optimalsolution_&amp;amp;RoO;
						Title "Optimal Solution RoO=&amp;amp;RoO x &amp;amp;RoO km";
					run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Nov 2021 15:36:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Help-Wanted-Coding-a-Constraint/m-p/781283#M3533</guid>
      <dc:creator>genemroz</dc:creator>
      <dc:date>2021-11-19T15:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: Help Wanted: Coding a Constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Help-Wanted-Coding-a-Constraint/m-p/781285#M3534</link>
      <description>&lt;P&gt;If I understand correctly, you want to include the following "conflict" constraints that prohibit both binary variables from taking the value 1 simultaneously:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   set STATION_PAIRS = {&amp;lt;'A','B'&amp;gt;, &amp;lt;'C','D'&amp;gt;};
   con NotSameOrientation {&amp;lt;s1,s2&amp;gt; in STATION_PAIRS, o in ORIENTATIONS}:
      CHI[s1,o] + CHI[s2,o] &amp;lt;= 1;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Nov 2021 15:45:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Help-Wanted-Coding-a-Constraint/m-p/781285#M3534</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2021-11-19T15:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help Wanted: Coding a Constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Help-Wanted-Coding-a-Constraint/m-p/781416#M3535</link>
      <description>&lt;P&gt;Thanks, Rob!&amp;nbsp; I implemented your suggested code and it works perfectly. This was a big help.&amp;nbsp; I'm marking your solution as accepted.&amp;nbsp; Thanks again for your help with this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Gratefully,&lt;/P&gt;
&lt;P&gt;Gene&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 23:04:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Help-Wanted-Coding-a-Constraint/m-p/781416#M3535</guid>
      <dc:creator>genemroz</dc:creator>
      <dc:date>2021-11-19T23:04:27Z</dc:date>
    </item>
  </channel>
</rss>

