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

Showing results for

Find a Community

- Home
- /
- SAS Communities Library
- /
- Operation Research with IML

- Article History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Email to a Friend
- Printer Friendly Page
- Report Inappropriate Content

Labels:

Rick Wicklin's blog has encouraged me to solve via IML problems that appear in the book "Schaum's Outline of Operations Research".

I would like to share the problem expressed in the book and the IML approach I chose to solve it.

Start reading at **1.13**

The attached images describe the problem and its solution following the logic and the recipe of the book. Furthermore they serve as a verifier for the solution I get running the IML code.

And here comes the code:

```
proc iml;
/* information about the variables */
LowerB = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; /* lower bound constraints on x */
UpperB = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; /* upper bound constraints on x */
/* define the objective function */
c = {65, 73, 63, 57,
67, 70, 65, 58,
68, 72, 69, 55,
67, 75, 70, 59,
71, 69, 75, 57,
69, 71, 66, 59} ; /* vector for objective function c*x */
/* control vector for optimization */
ctrl = {1, /* maximize objective */
1}; /* print some details */
/* specify linear constraints */
A = {1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0, /* matrix of constraint coefficients */
0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,
0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0,
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0,
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0,
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1,
1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0,
0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0,
0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0,
0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1};
b = { 1, /* RHS of constraint eqns (column vector) */
1,
1,
1,
1,
1,
1,
1,
1,
1};
LEG = {L, L, L, L, L, L, G, G, G, G}; /* specify symbols for constraints:
'L' for less than or equal
'E' for equal
'G' for greater than or equal */
/* solve the LP problem */
CALL LPSOLVE(rc, objVal, result, dual, reducost, /* output variables */
c, A, b, /* objective and linear constraints */
ctrl, /* control vector */
LEG, /*range*/ , LowerB, UpperB);
print rc objVal, result[rowname={x11 x12 X13 X14 x21 x22 X23 X24 x31 x32 X33 X34 x41 x42 X43 X44 x51 x52 X53 X54 x61 x62 X63 X64}];
```

And it works giving me one of the optimal solutions.

I have managed to solve some other problems of the book with IML.

But I need some help figuring out how to blend the Travelling Salesman Problem with the networking optimisation described on page

Use case is the best route, minimizing the travelled miles, that a bakery business should define taking into consideration the supply and shortage of bread in their network of bakery shops. The factory has all the output that needs to be distributed to their network depending on the demand and stock at each shop.

Help would be very welcome. On reply I'll share the code I've tried so far.

Bye, Arne

2 Comments (2 New)

Hide Comments

Comments