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

Hello,

I have a silly question. However not sure if there is an answer to my silly question.

I am formulating a model where in one of the constraints, for a decision variable to be true, it depends on other decision variables.

example:

for all (<i,j,n> in MasterRoute>

if X=1 and W[i,j]=1 and sum{<nod,(n)> in PickUpNode, p in PickSanity:p=nod and nod=1} U

<= Ui <= Uj <= Udn then Y[i,j,n]=1

X, Y, U and Y are decision variables.

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

The proposition

if AND {j in 1..n} (P = 1) then Q = 1,

where P and Q are binary variables, can be enforced by the linear constraint

sum {j in 1..n} P - n + 1 <= Q.

Assuming X, W, and Y are binary variables in your problem, you can express the desired proposition in this form by introducing additional binary variables (and big-M constraints) to represent each of the following three propositions:

  • sum{<nod,(n)> in PickUpNode, p in PickSanity:p=nod and nod=1} U

    <= Ui

  • Ui <= Uj
  • Uj <= Udn

Do you have bounds for U?

View solution in original post

6 REPLIES 6
RobPratt
SAS Super FREQ

The proposition

if AND {j in 1..n} (P = 1) then Q = 1,

where P and Q are binary variables, can be enforced by the linear constraint

sum {j in 1..n} P - n + 1 <= Q.

Assuming X, W, and Y are binary variables in your problem, you can express the desired proposition in this form by introducing additional binary variables (and big-M constraints) to represent each of the following three propositions:

  • sum{<nod,(n)> in PickUpNode, p in PickSanity:p=nod and nod=1} U

    <= Ui

  • Ui <= Uj
  • Uj <= Udn

Do you have bounds for U?

V12DBS
Calcite | Level 5

Hi Rob,

Thanks for the quick reply. Infact, I have converted the above mentioned proposition into the following constraint. Please excuse my indexing technique. I used different notation for indexes as SAS kept giving me "hides outer declaration"error. My priority was to have a feasible model and then go back and have efficient coding for compression. 1000 is the Big-M and I have bounds for U. U is part of the MTZ subtour elimination. However, the solution is infeasible and I am grinding my teeth debugging the infeasibility. In the routing model that I am developing, I am have a DV "RV" that is indexed over i,j,product,size. In the model the product the truck carries are all unique from each other because the product is an automobile. I have another DV "R" indexed over i,j. While I am getting an optimal route with "R", I am not able to connect RV with R correctly.

example: Civic Medium pickup = Location A dropoff = Location C

              Accord Medium pickup = Location B dropoff = Location C

When I solve the model the "R" DV will correctly traverse the arc to get an optimal route, however the "RV" DV does not. I will see RV[A,B,Civic,medium] = 1 and not RV[A,B,Civic,medium]=1 and RV[B,C,Civic,medium]=1. Have the flow balance constraint but still does not work.

Con New{<f,t,ve,si> in MasterRoute}:

RV[f,t,ve,si] >= 5 - sum{<e,z> in Vehicle:e=ve and z=si} 1 * V[e,z] - sum{<fr,to> in RouteDistance:fr=f and to=t} 1 * R[fr,to] -

sum{<node,vehi,size> in JC:node=f and vehi=ve and size=si} 1* A[node,vehi,size]

- sum{<nod,veh,siz> in JC:nod=t and veh=ve and siz=si} 1 * B[nod, veh,siz] - sum{<bh,ga> in RouteDistance:bh=f and ga=t} 1 * C[bh,ga];

con New1{<no,ve,si> in JC}:

1000 * (A[no,ve,si] - 1) <= UAll[no] - sum{<nod,veh,siz> in PickUpNode, s in PickSanity:s=nod and nod=no and veh=ve and siz=si} 1 * UAll;

con New2{<no,ve,si> in JC}:

1000 * (A[no,ve,si] - 1) >= - UAll[no] + sum{<nod,veh,siz> in PickUpNode, s in PickSanity:s=nod and nod=no and veh=ve and siz=si} 1 * UAll;

con New3{<no,ve,si> in JC}:

1000 * (B[no,ve,si] - 1) <= - UAll[no] + sum{<nod,veh,siz> in DropOffNode, s in DropSanity:s=nod and nod=no and veh=ve and siz=si} 1 * UAll;

con New4{<no,ve,si> in JC}:

1000 * (B[no,ve,si] - 1) >= UAll[no] - sum{<nod,veh,siz> in DropOffNode, s in DropSanity:s=nod and nod=no and veh=ve and siz=si} 1 * UAll;

con New5{<fr,to> in RouteDistance}:

1000 * (C[fr,to] - 1) <= UAll[to] - UAll[fr];

con New6{<fr,to> in RouteDistance}:

1000 * (C[fr,to] - 1) >= - UAll[to] + UAll[fr];

RobPratt
SAS Super FREQ

It will help me understand better if you write the desired logical relationship among V, R, A, B, C, and RV as a proposition using IF, THEN, AND, OR, and NOT, without the indexing.

RobPratt
SAS Super FREQ

I suspect that you want to enforce the following proposition:

if V = 1 and R = 1 and A = 1 and B = 1 and C = 1 then RV = 1

The corresponding linear constraint would be:

V + R + A + B + C - 4 <= RV

But you currently have (Con New):

V + R + A + B + C + RV >= 5

V12DBS
Calcite | Level 5

Apologies for the delay.

V = Vehicle DV. Indexed over AutoID and Size. Type = Binary.

R = Arc DV. Indexed over I & J. Type = Binary

A = Visit Node. Indexed over I, AutoID and Size, Type = Binary

B = Visit Node. Indexed over J, AutoID and Size. Type = Binary

RV = Arc with AutoID. Indexed over I, J, AutoID and Size. Type = Binary

My main goal is to make sure that I carry my Automobile that is on a truck from it's pickup all the way to dropoff (while visiting transition nodes for other automobile pickup)

So If I select to carry(V) an Automobile and pass through an arc (R) and the arc's I th node and J th node than RV = 1.

Thanks for checking my constraint. I dont think I need the C though. However, The new2...new6 constraints that I have after the V + R + A + B + C + RV >= 5, seems to be the problem. Or probably I have something formulated in the model elsewhere that is causing the model's infeasibility.

RobPratt
SAS Super FREQ

Then I think you want

V + R + A + B - 3 <= RV

instead of your current Con New.

If that change doesn't correct the issue, you might try fixing variables to a known feasible solution, call the solver, and see which constraints are flagged as infeasible.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 6 replies
  • 1094 views
  • 6 likes
  • 2 in conversation