Operations Research topics: SAS/OR,
SAS Optimization, and SAS Simulation Studio

FCMP and OPTMODEL

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 16
Accepted Solution

FCMP and OPTMODEL

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
SAS Employee
Posts: 417

Re: FCMP and OPTMODEL

FCMP enablement in PROC OPTMODEL is not documented or supported but has been available as a hidden feature for several releases.  Official support for this functionality is on the roadmap for a coming release.

View solution in original post


All Replies
Solution
‎07-19-2013 10:16 PM
SAS Employee
Posts: 417

Re: FCMP and OPTMODEL

FCMP enablement in PROC OPTMODEL is not documented or supported but has been available as a hidden feature for several releases.  Official support for this functionality is on the roadmap for a coming release.

Occasional Contributor
Posts: 16

Re: FCMP and OPTMODEL

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;

SAS Employee
Posts: 417

Re: FCMP and OPTMODEL

  min z = rosenbrock(x);

Occasional Contributor
Posts: 16

Re: FCMP and OPTMODEL

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.

SAS Employee
Posts: 417

Re: FCMP and OPTMODEL

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:

http://support.sas.com/documentation/cdl/en/orlsoug/66102/HTML/default/viewer.htm#orlsoug_hplso_toc....

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?

Occasional Contributor
Posts: 16

Re: FCMP and OPTMODEL

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?

SAS Employee
Posts: 417

Re: FCMP and OPTMODEL

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?

    ☑ This topic is SOLVED.

    Need further help from the community? Please ask a new question.

    Discussion stats
    • 7 replies
    • 836 views
    • 3 likes
    • 2 in conversation