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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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