BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
genemroz
Quartz | Level 8

Esteemed Advisers

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.

 

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?

 

The code below is the current Proc Optmodel statement that I am using.

 

Many thanks in advance for any guidance you can provide.

 

Regards,

 

Gene

 

Proc Optmodel;
	/* Read CoverageMatrix data into index sets*/
						set <str> stations;
						read data work.stationindex into stations=[station];
/* 						
/*						Modify Orientations below to reflect addition of elevation angles of 40 and 50 degrees */
						set <str> 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 <str> 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=&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] <=1;
						con TriplyCoveredCon {t in TARGETS}: XIT[t] >=k * IsTriplyCovered[t];

						/* Call Solver and Save Results:*/
						solve with milp/ relobjgap=&relobjgap;
/* 						solve; */
						create data work.OptimalSolution_&RoO from 
						[station orientation]={c in stations, o in orientations: CHI[c, o]>0.5} CHI;
					quit;
						/*Print Results*/
						proc print data=work.optimalsolution_&RoO;
						Title "Optimal Solution RoO=&RoO x &RoO km";
					run;
1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

If I understand correctly, you want to include the following "conflict" constraints that prohibit both binary variables from taking the value 1 simultaneously:

   set STATION_PAIRS = {<'A','B'>, <'C','D'>};
   con NotSameOrientation {<s1,s2> in STATION_PAIRS, o in ORIENTATIONS}:
      CHI[s1,o] + CHI[s2,o] <= 1;

View solution in original post

2 REPLIES 2
RobPratt
SAS Super FREQ

If I understand correctly, you want to include the following "conflict" constraints that prohibit both binary variables from taking the value 1 simultaneously:

   set STATION_PAIRS = {<'A','B'>, <'C','D'>};
   con NotSameOrientation {<s1,s2> in STATION_PAIRS, o in ORIENTATIONS}:
      CHI[s1,o] + CHI[s2,o] <= 1;
genemroz
Quartz | Level 8

Thanks, Rob!  I implemented your suggested code and it works perfectly. This was a big help.  I'm marking your solution as accepted.  Thanks again for your help with this.

 

Gratefully,

Gene

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 552 views
  • 2 likes
  • 2 in conversation