BookmarkSubscribeRSS Feed
norachanisara
Calcite | Level 5

Hi,

 

I am new to SAS and wondering what should be the right SAS syntax for the following

 

/* Time constraints */
con time_constraints_A:
   sum{i in LOCATIONS, j in LOCATIONS} t_A[i, j] * x[i, j, k]
   + sum{i in LOCATIONS} s_A[i] * y[i, k] <= max_time[k], 
   for all k in VEHICLES where z[k] = 1;

I don't think the last line is correct but that is the logic in plain english I want to do. I want the sum + sum for all k in set VEHICLE where z[k] = 1

 

Same for this constraint

con type_link:
      v_A[i] * z[k] + v_B[i] * (1 - z[k]) >= x[i, j, k], 
      for all i in LOCATIONS, j in LOCATIONS, k in VEHICLES;

Thanks a lot

2 REPLIES 2
RobPratt
SAS Super FREQ

Assuming that you also want z[k] = 0 to imply that x[i,j,k] = 0 and y[i,k] = 0, you can impose the following:

con time_constraints_A {k in VEHICLES}:
   sum{i in LOCATIONS, j in LOCATIONS} t_A[i, j] * x[i, j, k]
   + sum{i in LOCATIONS} s_A[i] * y[i, k] <= max_time[k] * z[k];

For the second constraint, here is correct syntax:

con type_link {i in LOCATIONS, j in LOCATIONS, k in VEHICLES}:
      v_A[i] * z[k] + v_B[i] * (1 - z[k]) >= x[i, j, k];

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

Discussion stats
  • 2 replies
  • 1118 views
  • 0 likes
  • 3 in conversation