Turn on suggestions

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

Showing results for

Options

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

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 02-13-2017 01:02 PM
(1546 views)

In my autodidactic approach towards knowledge in SAS IML I read the interesting article:

Example 9.10 Quadratic Programming :: SAS/IML(R) 13.2 User's Guide

This prompted me to apply this technique to a different problem exposed in the recommendable book

"Schaum's Outline of Operations Research".

In doing so I cash in on the following advantages: to reassure myself of the correctness of the solution I get by solving it with IML and secondly being guided with te recipe to state the problem and define the objective function and the restrictions.

And it works! although I must confess that my higher mathematics university course lays far in the past and I don't succeed in understanding completely what's the reasoning with the eigenvalue...

If someone wants to explain me that, I'm willing to put an effort in understanding it

And generally speaking about Operations Research in IML, can someone give me advice on how to define a Travelling Salesman Problem via IML (not OR) which is __ additionally subject__ to some restrictions? I manage to formulate most of the restrictions but I fail to force the solution to being a round trip (once arriving at node B continue travelling from there ...).

Here comes the case description as an excerpt from the mentioned book.

```
proc iml;
start qp( names, c, H, G, rel, b, activity);
if min(eigval(h))<0 then do;
error={'The minimum eigenvalue of the H matrix is negative.',
'Thus it is not positive semidefinite.',
'QP is terminating.'};
print error;
stop;
end;
nr=nrow(G);
nc=ncol(G);
/* Put in canonical form */
rev = (rel='<=');
adj = (-1 * rev) + ^rev;
g = adj# G;
b = adj # b;
eq = ( rel = '=' );
if max(eq)=1 then do;
g = g // -(diag(eq)*G)[loc(eq),];
b = b // -(diag(eq)*b)[loc(eq)];
end;
m = (h || -g`) // (g || j(nrow(g),nrow(g),0));
q = c // -b;
/* Solve the problem */
call lcp(rc,w,z,M,q);
/* Report the solution */
print ({'*************Solution is optimal***************',
'*********No solution possible******************',
' ', ' ', ' ',
'**********Solution is numerically unstable*****',
'***********Not enough memory*******************',
'**********Number of iterations exceeded********'}[rc+1]);
activity = z[1:nc];
objval = c`*activity + activity`*H*activity/2;
print objval[L='Objective Value'],
activity[r=names L= 'Decision Variables'];
finish qp;
c = { -7.6, -5, 1};
h = { 0.08 0 0 ,
0 0.04 0,
0 0 0};
g = { 0.2 0.2 0 ,
0.8 0.3 0,
1 0 0,
0 1 0,
0 0 1};
/* constraints: */
b = { 20 , 60, 30, 30, 673.5 };
rel = { '<=', '<=', '>', '>', '=' };
names = 'cheese1':'cheese3';
names [3]= 'dummy';
run qp(names, c, h, g, rel, b, activity);
```

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

There is a class of matrices with nice properties that called positive definite (PD) matrices. One of their defining properties is that all eigenvalues are positive.

In a QP problem, if the H matrix is PD then the objective function is "bowl shaped." That means that there is a unique solution to the unconstrained problem and a solution exists for a properly formed constrained problem.

If the H matrix is not PD, it might be that the graph of the objective function is an "upside down" bowl, which has no minimum. Or the graph of the objective function might be a saddle-shaped surface, which also has no minimum. In either case, the program aborts the computation because there is no global minimum, although there will be a local minimum if the constrained region is finite in extent.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Many thanks Rick for this excellent explication.

Your examples, posts and answers make me want to learn more and more IML.

It's fantastic and its usage seems unconstrained ☺

Your examples, posts and answers make me want to learn more and more IML.

It's fantastic and its usage seems unconstrained ☺

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Are you ready for the spotlight? We're accepting content ideas for **SAS Innovate 2025** to be held May 6-9 in Orlando, FL. The call is **open **until September 25. Read more here about **why** you should contribute and **what is in it** for you!

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.