Operations Research topics: SAS/OR,
SAS Optimization, and SAS Simulation Studio

Optmodel Efficiency

New Contributor
Posts: 4

Optmodel Efficiency


I am looking for help in terms of improving the efficiency/runtime of Proc Optmodel. Here's some background on my problem:

It's specifically optimizing selection. I have 200,000 rows with the variable being a Binary Include flag. The subset I want "included" has to meet various constraints in the aggregate - weighted averages, sums, etc.

I am using the Mixed Integer Linear solver, as that is the one that works given I have a Binary variable.

Issue is that once I add a key constraint, the runtime has increased from 20 seconds to above 4 minutes. I know that this key constraint is "limiting", ie the result is right at my constraint boundary. Otherwise, it is very similar to other constraints I have that do not seem to slow down runtime. I know optmodel has tons of options, but I'm just not sure which could help me.

I did cut the runtime in half by setting Presolver=aggressive, but I'm weary about what this actually does to the data. I get the following in log:

"WARNING: Removed 17 constraint coefficients whose absolute values are not greater than 1E-9." This confuses me because none of the hard coded values I have in there are < 1E-9, but maybe I need to better understand what all is included in a constraint coefficient. I'm nopt using any other options on the solve line.

Let me know if anything else will help describe my problem. Any suggestions are greatly appreciated! Thanks

SAS Employee
Posts: 538

Re: Optmodel Efficiency

Please post your code, along with the data if possible.

SAS Employee
Posts: 49

Re: Optmodel Efficiency

Would you be willing to share your data and model code? I can take a look and perhaps make a suggestion.

SAS Employee
Posts: 37

Re: Optmodel Efficiency

If you are unable to share your original code, you may want to at least try finding these small coefficients. They are probably a sign that your model could be improved by handling some special case in the data more precisely.

One way to find them is to use the expand statement, then search for E- (like that, with no spaces) in the results. That will match scientific notation. For example, this code:

proc optmodel;

    var XE, Y;

    con SmallCoefficients{i in 1..10}: 1/(10**i)* xE - 6*y <= 1;



will produce:

Var XE

Var Y

Constraint SmallCoefficients[1]: 0.1*XE - 6*Y <= 1

Constraint SmallCoefficients[2]: 0.01*XE - 6*Y <= 1

Constraint SmallCoefficients[3]: 0.001*XE - 6*Y <= 1

Constraint SmallCoefficients[4]: 0.0001*XE - 6*Y <= 1

Constraint SmallCoefficients[5]: 0.00001*XE - 6*Y <= 1

Constraint SmallCoefficients[6]: 1E-6*XE - 6*Y <= 1

Constraint SmallCoefficients[7]: 1E-7*XE - 6*Y <= 1

Constraint SmallCoefficients[8]: 1E-8*XE - 6*Y <= 1

Constraint SmallCoefficients[9]: 1E-9*XE - 6*Y <= 1

Constraint SmallCoefficients[10]: 1E-10*XE - 6*Y <= 1

Because of the way optmodel formats the output, you will only encounter the E- pattern in a small number, unless your data encodes it in a string.

Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation