SAS Optimization, and SAS Simulation Studio

turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-30-2016 12:14 AM

Hello, i have to solve an optimization problem.

I attached two slides where you can see optimization problem(maximum revenue) with constraints and example.

What procedure can i use to solve problem, and how i write this optimization? I never used OR before.

Thank you

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-30-2016 12:27 AM - edited 10-30-2016 10:34 AM

You can use the OPTMODEL procedure in SAS/OR to formulate and solve optimization problems. There is a whole book of examples to help you.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-01-2016 10:33 AM

The problem thay i don't have sas SAS/OR, only SAS/IML. Can i use it to solve optimization?

Thank you

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-30-2016 06:31 AM

Here are several questions. What does Px stand for , how do you define Px ? How do you define x1=1 ? when you choose both cola and peanuts ? or just one of them ? Here is iML code for your example by Genetic Algorithm. proc iml; start func(x) global(x1,x2,x3,m,c,p,items,idx); if any(idx=sum(x)) then do; temp=p[loc(x)]; xx=all(element(x1,temp))|| all(element(x2,temp))|| all(element(x3,temp)) ; obj= sum(m#xx)-sum(c#x); end; else obj=-99999; return (obj); finish; items=3; p={cola peanuts cheese beer}; m={10 20 30}; c={5 3 1 4}; n=ncol(p); idx=1:items; encoding=repeat({0,1},1,n); x1={cola peanuts}; x2={peanuts cheese}; x3={peanuts beer}; id=gasetup(2,n,12345678); call gasetobj(id,1,"func"); call gasetcro(id,0.95,2); call gasetmut(id,0.95,3); call gasetsel(id,100,1,1); call gainit(id,10000,encoding); niter = 1000; do i = 1 to niter; call garegen(id); call gagetval(value, id); end; call gagetmem(mem, value, id, 1); print (p[loc(mem)])[l="members"],value[l = "Max Value:"] ; call gaend(id); quit; OUTPUT: members PEANUTS CHEESE BEER Max Value: 42

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-30-2016 10:32 AM

GA provides no measure of optimality for the solution it returns, and so you should probably use that only when a specialized solver is not available. In particular, if you are going to use IML to solve a MILP, you might as well call the MILPSOLVE subroutine, which invokes the same MILP solver that is accessible from PROC OPTMODEL. The PROC OPTMODEL syntax will more closely match your algebraic formulation.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-01-2016 10:45 AM

Unfortunately i don't have SAS/OR, only SAS/IML. Can i solve this optimization with SAS/IML?

Please see attached file. Thank you

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-01-2016 10:43 AM

Unfortunately i don't have SAS/OR, only SAS/IML. I attached more normal explanation. please see it. I have a lot of itemsets(X), they can be different bu size, for example, in one you can gave only milk, in other you have milk and sugar.

i have two decision variables to be optimized P and Q.(they binary variables, and got two values : 1 or zero, 1 means that product was choosen). Thank you for your help

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-01-2016 10:23 PM

Yeah. GA can't guarantee the optimal solution. But if the number of items is not too big, I think GA is ok . And change number of iteration in my code to be bigger and make sure to get better solution. I still am not understand Q1>=P1 . Q1,P1 in (0 ,1) ? How do you define P1=1 , when x1=both cola and peanuts ?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-02-2016 01:44 AM

That means when i choose itemset X1, and this itemset adds profit i.e P1=1, then every product inside itemset X1 have to be choosen, i.e i itemset X1 has three products then all Q1, Q2 and Q3 have to be equal to 1. P and Q decision binary variables. The problem that i have to data sets, one that include all itemsets and the second all products and their cost. I really dont know if sas can solve this problem. Maybe try other language?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-02-2016 07:19 AM

So My GA code is doing that. I also want see @rob post OR code, that might be your best choice.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-02-2016 01:49 PM

Thank you for your help

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-07-2016 11:06 AM

Here it is in PROC OPTMODEL with the MILP solver:

```
proc optmodel;
set ITEMS = /cola peanuts cheese beer/;
num cost {ITEMS} = [5 3 1 4];
set ITEM_SETS = 1..3;
set <str> X {ITEM_SETS};
X[1] = /cola peanuts/;
X[2] = /peanuts cheese/;
X[3] = /peanuts beer/;
num m {ITEM_SETS} = [10 20 30];
var P {ITEM_SETS} binary;
var Q {ITEMS} binary;
con SelectThreeItems:
sum {i in ITEMS} Q[i] <= 3;
con SetImpliesItem {s in ITEM_SETS, i in X[s]}:
P[s] <= Q[i];
max Z = sum {s in ITEM_SETS} m[s] * P[s] - sum {i in ITEMS} cost[i] * Q[i];
solve;
print P Q;
quit;
```

SAS Output

Solution Summary | |
---|---|

Solver | MILP |

Algorithm | Branch and Cut |

Objective Function | Z |

Solution Status | Optimal |

Objective Value | 42 |

Relative Gap | 0 |

Absolute Gap | 0 |

Primal Infeasibility | 0 |

Bound Infeasibility | 0 |

Integer Infeasibility | 0 |

Best Bound | 42 |

Nodes | 1 |

Iterations | 4 |

Presolve Time | 0.00 |

Solution Time | 0.00 |

[1] | P |
---|---|

1 | 0 |

2 | 1 |

3 | 1 |

[1] | Q |
---|---|

beer | 1 |

cheese | 1 |

cola | 0 |

peanuts | 1 |