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

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

Posted 11-22-2013 07:39 AM
(1847 views)

Hello,

I have a decision variable (x) that should be outputted from an optimization problem

This variable should be outputted as binary, taking only the values of "0" OR "1"

How can I define that at SAS proc iml?

As I can't find a syntax that puts that as a condition

In addition, I tried the below equation to be added to the constraints of my optimization problem, which ends up with the same meaning, but it gave no results

x*(1-x)=0

Please help

this is very urgent and I have due date with very limited timingssssssssssss

thanks a lot

16 REPLIES 16

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

In the SAS DATA step and in PROC IML you can form a logical expression that evaluates to true (1) or false (0).

For example, if you want to return 1 when x>0.7, just write

result = ( x>0.7 ); /* 0 or 1 */

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

sorry cant get what you mean quite well,

here are the below equations that I need to write at sas proc iml:

b+0.1*c>0

where b is a decision variable representing my coefficients at the model

c is a binary decision variable that should be outputted as 0 or 1, so how can I express that at my iml program?

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

Are you using the NLPQN function? If so, I think you need to specify the nonlinear constraint by using the NLC= option. See

the doc chapter "Nonlinear Optimization Examples: Parameter Constraints"

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

unfortunately, that doesn't solve my problem:

the below is my model I need to write at sas proc iml:

b(i)-0.1*c(i)>0

b(i)-c(i)<0

sum c(i)=4;

given that i=1.........6

**these equations shows that: if c (it is outputted) =1, then 0.1<b<1**

**and if c=0, then b=0**

This means that I need 4 c's =1 and 2 c's =0

and also I need 2 b's=0 and 4 b's having values ranging from 0.1 to 1

where b is a decision variable representing my coefficients at the model

c is a binary decision variable that should be outputted as 0 or 1, so how can I express that at my iml program?

did you get what I am trying to output?

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

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

Wow, that would be too difficult as that is just an example of equations at many problems I am trying to handle

are there any other ways of solving that problem? I have been trying to solve that problem for several monthsssssssssssss

PLEASE HELPPPPPPPPP

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

what is your objective function?

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

Depending on the problem size and your objective function, there are different ways to solve the problem you describe. If your objective function is linear, then you have a Mixed Integer Linear Program. If you have SAS/OR available to you, then you can use PROC OPTMILP to solve that directly.

If your objective function is a general non-linear function, then you have a Mixed Integer Non-linear Programming problem (MINLP) which in general is difficult to solve. If that is the case then in IML your best bet would be to use the Genetic Algorithm routines to try and solve your problem.

If you are trying to fit a traditional statistical model like a linear or logistic regression, then SAS/STAT offers extensive variable selection algorithms you can use to find the optimal set of decision variables.

Perhaps if you would describe the original problem that would help in figuring out the best way to solve it..

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

Try using the augmented Lagrangian method. The method gets rid of the nonlinear constraint by rewriting the objective function to include a penalty term. By adding a "nuisance parameterm," you can solve the original problem. For example, you might try introducing a new parameter lambda>0 and optimizing the objective function

OrigObjective + lambda*x*(1-x) + 10000*(x*(1-x))##2

In order to get rid of the penalty terms, x will be driven to 0 or 1 during the optimization.

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

Here is my model:

Minimize dp+dn

subject to

b0+biXij+dn-dp=0

bi-0.1*ci>0

bi-ci<0

sum ci=4

where i=1..........6

j is my set of observations

and my decision variables are:

b, dp, dn, and c

hope that makes my problem more clear for you to please assisttttttttttttttttt

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

I need also to make a simulation for that problem?

and also sometimes I have non-linear constraints at another problem I am doing simulation for and using at that stage nlpqn at sas proc iml

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

available?

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

unfortunately no

is there any other way using sas proc iml please?

I am using nlpqn call

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

Here is what I recommend, going back to my earlier suggestion.

1) generate all possible c vectors

2) for each c vector, solve the optimization problem treating the c as a constant.

this gives you a simple optimization problem with linear constraints.

3) the c vector that gives you the best optimum value coresponds to your global optimum value.

Here's how to get started:

Create a module that solves the problem for a given c vector, treating c as a constant, like

start optimize(opt_value, opt_vec) global( c);

/* set up constraints */

...

call nlpqn(rc, opt_vec, "objective_function"....); /* do optimization for a given c vector*/

opt_value = objective_function(opt_vec);

finish;

then loop through all the possible values of c:

ncoeff = 6; /* total number of c variables */

subset_size = 4; /* number of c variables to set to 1 */

perms = allcomb(ncoeff,subset_size); /* get all permutations of 4 out of 6 elements */

optval = 1e30; /* initialize to some some huge value */

do i = 1 to nrow(perms);

/* set up c vector */

c = j(ncoeff, 1, 0);

c[ perms[i,], 1 ] = 1;

run optimize(value, vector);

if value < optval then do;

/* save optimal values */

optval = value;

optvec = vector;

optc = c;

end;

end;

now you should have your optimum decision variables in optvec and optc and your optimum value in optval

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.