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 08-30-2017 10:11 AM
(1386 views)

`Hi everyone, `

I am writing to you in hoping that someone would be able to help me. I am new in proc optmodel so i had really take time to learn the basic in

proc optmodel language before starting to solve my problem.

So, I am trying to solve a quadratic problem ( in 9.4 sas version ) with a minimizing function that is based of a

likelihood maximum formulation. In that way I have two tables :**tableau 1** that contains my real X (*188 rows and 8836 columns*) and **Marges** that contains my real Y (*188 rows, 188 columns*).

What I want is that estimates X and Y that respond to this function like for each row (i) of the two tables (that means for X and Y ) we have

min f = *[*(X(*to estimate*) - X( real *in "tableau")***)****2**/***X(real)***]*** + ***[(**Y(to estimate) - Y(real in "Marges")**)****2 **/** Y(real)**]**

following to the constraint that the sum of X - Y = 0 ( for each rows of the two tables ).

In my code the programm runs until the reading data step, there is no syntax error and it gives me the right format of my data but when i run the code with resolving part

I have the note : "out of memory" and it stopped. I've already changed my size of sas with (memsize 0) but when i re-run it is always in "out of memory".

Actually, my problem is that i really don't know if the problem is really the memory or if it's my syntax code wich that is not good.

So if you see the code below : do you think that the problem is that my code is not correct ?

Thanks for advance for the answer and hope that the question is clear (forgive about my english)

proc optmodel; /* I Tableau des M reels */ /*************************************************************/ /* declaration de paramètre */ set zone1 = 1..8836; set <num> C1; number trafic1{C1, zone1}; /* Lecture de la table */ read data Tableau1 into C1 = [_N_] {r in zone1} < trafic1[_N_, r]=col("Z"||r) >; print trafic1; /* II Tableau des contraintes réels ==> Y réels */ /*********************************************************************/ set Cont1 = 1..188; set <num> N1; number Marge1{N1, Cont1}; /* Lecture de la table */ read data Marges into N1 = [_N_] {m in Cont1} < Marge1[_N_, m]=col("O"||m) >; print Marge1; /* V Resolution */ /*********************************************************************/ /* V-1) Déclaration de variables */ var x{i in C1, d in zone1} >= 0 ; var y{j in N1, o in cont1} >= 0 ; /* V-2) La fonction objective : minimisation de la variance */ minimize f = sum{i in C1, d in zone1} ((X[i, d] - trafic1[i, d])**2/trafic1[i, d]) + sum{j in N1 , o in cont1} (( Y[j, o]- Marge1[j, o])**2/Marge1[j, o]); /* V-3) subject to the following constraints */ Con Bornes {i in C1, d in zone1, j in N1, o in cont1} :(X[i, d] - Y[j, o]) = 0; solve; print {i in C1, d in zone1: X[i, d] > 0} X ; quit;

- Tags:
- procoptmodel

1 ACCEPTED SOLUTION

Accepted Solutions

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

It looks like you have some data issues (missing values and mixture of Z and VAR column names), but I think I see what you are trying to do. You wanted 188 constraints, but you declared 188*8836*188*188 = 58.7 billion constraints instead. Try this:

```
Con Bornes {i in C1}: sum {d in zone1} X[i, d] = sum {o in cont1} Y[i, o];
```

A good way to make sure your model is correct is to use the EXPAND statement on a smaller instance.

9 REPLIES 9

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

Can you please share the data?

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

Thanks for replying . I have attached two files ("tableau" ( "marges").

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

I see only one attachment (marges.csv).

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

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

I have attached two reduced files because the orginals are too bigs. So instead of having (188 row, 8836 colums for tableau1 ) and (188 rows, 188 for marges), i send you (12 rows, 12 colums for tableau1 ) and (12 rows, 12 colums for marges).

Thanks

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

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

First I think i gave you a wrong reduced dataset for tableau1_set because for C1 = 1..12, I should give you a dataset with 12 rows and 144 columns (+C1). I don't know if there is a consequences for the resolution . Anyway I compressed the originals dataset ( that is attached with this mail ), i think it is better because of my error is about the note : "out of memory" that we would not see with the smaller contains.

About the constraint, in the orginal dataset, what i want for contraints is that

if** tableau1** have 188 rows and 8836 columns

if **marges** have 188 rows and 188 columns

Constraint 1 : (X1+....+X8836) - ( Y1+....+Y188) =0; (row 1)

Constraint 2 : (X1+....+X8836) - ( Y1+....+Y188) =0; (row1)

.....

Constraint 188 : (X1+....+X8836) - ( Y1+....+Y188) =0; (row188)

So i write the code like that **Bornes {i in C1, d in zone1, j in N1, o in cont1} :(X[i, d] - Y[j, o]) = 0; **

because i just want him to make sum operation for each row from row 1 to row 188. I don't know what exactly he does with this code.

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

It looks like you have some data issues (missing values and mixture of Z and VAR column names), but I think I see what you are trying to do. You wanted 188 constraints, but you declared 188*8836*188*188 = 58.7 billion constraints instead. Try this:

```
Con Bornes {i in C1}: sum {d in zone1} X[i, d] = sum {o in cont1} Y[i, o];
```

A good way to make sure your model is correct is to use the EXPAND statement on a smaller instance.

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

Thank you for your answer !

You understood very well what i wanted to do with the constraint. It was exactly what I wanted, i didn't know about the expand statement and I see it is a very good way to look after the code. So this morning i tried with your correction of the syntax (with expand) and I see that it write exactly the model and it solves very quickly so thank you very much beacause it helped me very well.

However, I see that the solutions is not very good but I think it is more in my model than in the code sas. Also , I see a note that sas changed the solver to NLP instead of QP so I'm gonna take a look at my model if it very optimal.

I also want to tell you that with the originals dataset, when I run the program I still needed to change the memsize to 0 then it solves in 19 second ( better with 188 constraint of course 🙂 ) .

Thank you again and I'll come back to you this evening if I find that it is my model wich us not goog or the QP solver is not adapted.

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

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.