BookmarkSubscribeRSS Feed
RogerP57
Calcite | Level 5
I have the below optmodel code to solve an LP problem with optmodel.  This is a very large model and the program runs 2.5 hours to solve.  My question is, this model spends 2 hours searching for negative solutions and the actual answer is never negative.  Is there a way to tell optmodel that the cost must be => 0 and to skip the negative tries?
 
minimize cost =
sum{<k,f,p,t> in ixPS} XP[k,f,p,t] * XPCost[p] 
+ sum{<k,f,p,t> in ixPU} PU[k,f,p,t] * PUCost[k,f,p,t]
+   sum{<ki,ko,w,pl,p,t> in ixPK} PK[ki,ko,w,pl,p,t] * pkgCost[ko,p,w]
+   sum{<k,f,fic,p,t> in ixIK} IK[k,f,fic,p,t] * invCost[k,p]
+   sum{<f,p,t> in ixIKMax1} X5[f,p,t] * X5Cst
+   sum{<fic,p,t> in ixIKMax2} X6[fic,p,t] * X6Cst
+   sum{<k,t> in ixMaxSku} XA[k,t] * XACst
+   sum{<k,t> in ixMinSku} XI[k,t] * XICst
+   sum{<k,f,fic,p,t> in ixIR} IR[k,f,fic,p,t] * LRInvCost[p,t]
+   sum{<k,f,fic,m,p1,p2,t> in ixTS} TS[k,f,fic,m,p1,p2,t] * TScost[k,f,fic,m,p1,p2,t]
+   sum{<k,f,fic,c,p,m,t> in ixS1} S1[k,f,fic,c,p,m,t] * FrtCost[k,f,fic,c,p,m,t]
+   sum{<k,f,fic,c,p,m,t> in ixS2} S2[k,f,fic,c,p,m,t] * OuCost[k,f,fic,c,p,m,t] 
+   sum{<k,c,m,t> in ixDMD1} X1[k,c,m,t] * X1Cst 
+   sum{<k,c,p,m,t> in ixMD1} XMD1[k,c,p,m,t] * X1Cst
+   sum{<k,c,m,t> in ixDMD2} X2[k,c,m,t] * X2Cst
+   sum{<k,c,p,m,t> in ixMD2} XMD2[k,c,p,m,t] * X2Cst
+   sum{<k,f,m,p,pr,t> in ixLR} LR[k,f,m,p,pr,t] * LRCost[k,f,m,p,pr,t]
+   sum{<c,p,t> in ixCP3Coeff} X3[c,p,t] * X3Cst
+   sum{<f,p,t> in ixMinBulk} X4[f,p,t] * X4Cst
+   sum{<k,g,t> in ixSkuAvgDem} X1Mos[k,g,t] * X1MosCst 
+   sum{<k,g,t> in ixSkuAvgDem} X2Mos[k,g,t] * X2MosCst
+   sum{<p,k,t> in ixFFTP} FFDX[p,k,t] * XFCst 
+   sum{<p,w,k,k2,t> in ixWCSal} X7[p,w,k,k2,t] * X7Cst
+   sum{<p,w,k,k2,t> in ixWCSal} X8[p,w,k,k2,t] * X8Cst                          
;  
 
Thanks,
Roger
1 REPLY 1
RobPratt
SAS Super FREQ

You can impose an explicit "objective cut" constraint:

con NonnegativeCost:
   cost >= 0;

But that will probably actually increase the solve time.

 

A more promising approach is to try different choices for the ALGORITHM= option.  If you can share the SOLVE statement you are currently using, as well as the LP solver's iteration log, I might be able to give a more specific recommendation.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Discussion stats
  • 1 reply
  • 399 views
  • 0 likes
  • 2 in conversation