SAS Optimization, and SAS Simulation Studio

turn on suggestions

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

Showing results for

Find a Community

Topic Options

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-19-2013 10:11 PM

Can OPTMODEL be used to minimize a function created with PROC FCMP? The documentation for FCMP says functions can be called by PROC NLP and a number of other procedures, but doesn't mention OPTMODEL. Is this correct? If NLP is the legacy procedure I assumed FCMP would be available to the newer procedure.

Accepted Solutions

Solution

07-19-2013
10:16 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to stoffprof

07-19-2013 10:16 PM

All Replies

Solution

07-19-2013
10:16 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to stoffprof

07-19-2013 10:16 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to RobPratt

07-21-2013 02:17 PM

Thanks. Can you give some guidance on the syntax? My attempt isn't working (optmodel can't find the function):

proc fcmp outlib=sasuser.funcs.tester;

function rosenbrock(x[2]);

f = 2 * (x[2] - x[1]**2)**2 + (1-x[1])**2;

return(f);

endsub;

run;

options cmplib=sasuser.funcs;

proc optmodel;

var x {1..2};

min rosenbrock;

solve;

print x;

quit;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to stoffprof

07-21-2013 02:20 PM

min z = rosenbrock(x);

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to RobPratt

07-21-2013 03:40 PM

Thanks Rob, especially for the super-fast answer (on a Sunday!). I'm trying to minimize a function I created in FCMP that takes only integer values. As far as I can tell, the problem does not fit into a MILP or LP setup, and NLP doesn't seem to allow integers. Is there a way to solve an arbitrary function that takes integers? I thought about modifying my program so it converts real numbers to integers, but I thought that might pose problems for a solver that looks at derivatives because they'd all be quite flat.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to stoffprof

07-21-2013 04:09 PM

You are correct that the NLP solver does not allow integer variables.

You might be interested in the new OPTLSO procedure, available in SAS/OR 12.3:

In a later release, this local search solver will also be accessible via OPTMODEL.

If you don't mind, would you please share the function you're trying to minimize? Do you have any constraints besides integrality of variables?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to RobPratt

07-24-2013 01:05 PM

Thanks Rob. The only constraints are that the variables are integers bounded by 0 and some integer usually close to 60. (There are about 50-100 such variables.) I don't think there's a straightforward way to share my objective function completely; it's a complicated function of many variables in a dataset. In short, the function is

f(x) = sum over all t of |a(t) - b(t)|

where a(t) is observable and b(t) = g(x; many parameters), and g() is, as I said, pretty complicated.

I've been minimizing this with a genetic algorithm in IML but am exploring other options with more flexibility. I recently heard about the GA procedure in SAS/OR, and wanted to try that as well. Are you aware of any sample code that shows how to use FCMP with PROC GA? In particular, I'm not clear on whether the functions have to be defined in exactly the same way as they are within GA (the first variable is an array). For example, suppose you wanted to write the function sumsq from this page within FCMP. How would that work, since I'm assuming you can't call ReadMember from FCMP?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to stoffprof

07-24-2013 04:29 PM

I'm not a PROC GA expert, but I believe for the example you referenced you could define a sum-of-squares function in PROC FCMP:

options cmplib=sasuser.funcs;

proc fcmp outlib=sasuser.funcs.temp;

function mysum(x

n = dim(x);

sum = 0;

do i = 1 to n;

sum + x* * x ;*

end;

return(sum);

endsub;

run;

And then call it from within the sumsq function in PROC GA:

/* compute the sum of the squares */

/* sum = 0;*/

/* do i = 1 to n;*/

/* sq = x* * x ;*/*

/* sum = sum + sq;*/

/* end;*/

sum = mysum(x);

Would it be possible for you to share your objective function by posting your actual code and data?