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 10-31-2012 08:48 AM
(1248 views)

Hi all,

I have an optimization problem where I want to minimize a numerical integration subject to certain constraints. Suppose that the objective function (the integration of "FUN") and the constraint are both computed using loops. I have one decesion variable "T" and one integration variable "M". I already wrote a part of the code(the part i wrote just performs the numerical integration )I really need to complete the code . What I need to complete is to minimize the integration of "FUN". The decesion variable is "T" . The constraint I have is computed in the same way of "FUN" , but with M=0 & "FUN"is restricted to the value "10". In otherwords, I want to minimize the integration of "FUN" where the integration variable is M, subject to the constraint that "FUN"=10 at M=0 and the decesion variable in this optimization is "T".

The code I was able to write(integrating "FUN") is:

proc iml;

start FUN(M);

x=0;

R=0;

do until (x<T);

x=normal(-1)+M;

R=R+5;

end;

return(R);

finish;

a={0 1}

call quad(k,"FUN",a};

quit;

Thanks,

Emara

1 REPLY 1

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

Emara,

There's a quite similar posting about this on comp.soft-sys.sas which I believe is from you as well.

I've responded in the newsgroup but will respond here also in the interest of getting the information

to as many interested parties as possible.

Thanks for posting this question. The best way to do this currently

is to use PROC NLP along with PROC FCMP (a Base SAS procedure) to

define the objective function. I consulted with one of our developers

on this question and he sent some sample code which uses this approach

for a problem that's pretty similar to yours. It's included at the

end of this email.

PROC OPTMODEL in SAS/OR is the successor to PROC NLP (it handles

not only nonlinear but also linear, mixed integer, and quadratic optimization).

However OPTMODEL is not yet FCMP-enabled and so it's best, given your

requirements, for you to stick with PROC NLP for now.

If you have any questions please feel free to contact me.

Thanks,

Ed Hughes

SAS/OR Product Manager

919-531-6916

Ed.Hughes@sas.com

Sample code follows:

data barddata;

input y @@;

datalines;

0.14 0.18 0.22 0.25 0.29 0.32 0.35 0.39

0.37 0.58 0.73 0.96 1.34 2.10 4.39

;

proc fcmp outlib=work.myfuncs.test;

function bard(x1, x2, x3);

array y[15] /nosymbols ;

rc = read_array('barddata', y);

fx = 0;

do k = 1 to 15;

vk = 16 - k;

wk = min(k,vk);

fxk = y

fx = fx + fxk**2;

end;

return (0.5*fx);

endsub;

run;

options cmplib = work.myfuncs;

proc nlp;

parms x1 x2 x3 = 1.0;

bounds 0 <= x1 <= 10,

0 <= x2 <= 10,

0 <= x3 <= 10;

min bardfn;

bardfn = bard(x1,x2,x3);

run;

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 16. 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.