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
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-25-2013 03:26 PM

Dear all;

I am running a proc iml program where i am minimizing a numerical integration. I have asked many questions concerning this program till I reached the current program.

1-My program now gives parameter estimates at the "optimization results" stage that satisfy the constraint(with a minor violation) but on the otherhand, these parameter estimates should give me another objective value than that displayed in the output (i.e.: when i substitute with the optimal parameter estimates in the objective function i don't get the displayed objective value) . I noticed that the objective value i got at the "optimization results" stage is the same objective value i got at the "optimization start" stage although the parameter estimates at the "optimization results" stage are different from the initial values i set for the parameters.

2-I noticed that even when i changed the minimization problem to maximization problem the objective value i got at the "optimization results" stage is the same as when the problem is a minimization problem. The value is exactly the same as that in the "optimization start" stage.

What might be the reason behind this?

I really need help,

The output file is attached,

Thanks

Emara

Accepted Solutions

Solution

02-04-2013
03:06 PM

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

02-04-2013 03:06 PM

I now see what your problem was. You defined FUNI using the variable hr as the parameter. IML was then treating hr inside FUN1 as a local, not a global parameter. When FUN is called from FUNI it uses the global value of hr in its calculations, and that wasn't being changed. I think what you really meant to do was define FUNI as:

start FUNI(hrx) global( hr);

hr = hrx;

<rest of your funtion as-is>

When I tried this I got objective values that were self-consistent and seemed reasonable.

All Replies

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

01-28-2013 03:52 PM

Coudl you attach your latest program that produced these results?

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

01-28-2013 04:45 PM

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

02-04-2013 01:11 PM

From playing around with your problem, it appears that your objective function is "broad" compared to your non-linear constraint. When I plug the computed optimal parameters into your objective function FUNI I do get the same value as the displayed objective value. I tried just maximizing your non-linear constraint, and after looking at the iteration history it appears that your non-linear constraint is >0 for only a small distance around (3.09, 0.92), and your objective function remains nearly constant inside the feasible area. That also explains why the max and min are the same within numerical precision, because your objective value does not change significantly within the feasible area.

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

02-04-2013 01:52 PM

Thanks alot for your reply, but could you please explain more? I run my syntax again, the optimal parameters I got are **{3.087771**, **0.731934**}, when i substituted with these values in the objective function module, I got the value "136.461", although the displayed optimal objective value of my program is "2827.940918". However, when i substitute with the initial values {**4** **0.8**}in the objective function module i got the value ""2827.940918".What is wrong with my program , I can't figure out the errors and I really need help with this syntax.

This is the output of my program:

Optimization Start

Parameter Estimates

Lower Upper

Bound Bound

N Parameter Estimate Constraint Constraint

1 X1 4.000000 0 10.000000

2 X2 0.800000 0 1.000000

Value of Objective Function = 2827.940918

Optimization Results

Parameter Estimates

N Parameter Estimate

1 X1 3.087771

2 X2 0.731934

Value of Objective Function = 2827.940918

and here is the output when substituting with the optimal parameter estimates in the objective function module:

K

136.461

I attached the syntax of the objective function module(the syntax in which i substituted with the optimal parameter estimates in the objective function)

Thanks too much,

Waiting for your reply and help,

Emara

Solution

02-04-2013
03:06 PM

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

02-04-2013 03:06 PM

I now see what your problem was. You defined FUNI using the variable hr as the parameter. IML was then treating hr inside FUN1 as a local, not a global parameter. When FUN is called from FUNI it uses the global value of hr in its calculations, and that wasn't being changed. I think what you really meant to do was define FUNI as:

start FUNI(hrx) global( hr);

hr = hrx;

<rest of your funtion as-is>

When I tried this I got objective values that were self-consistent and seemed reasonable.

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

02-05-2013 02:32 PM

Yes, it is working thank you sooooooooooooooo much. Could you explain more what is the differnce between local and global parameters and when to use each?

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

02-05-2013 03:17 PM

You can look at the IML doc on this at SAS/IML(R) 12.1 User's Guide to get the full explanation on how to specify global and local variables. Basically, local variables are used inside a module when you want to encapsulate those calculations so that you know what the inputs and outputs are and don't want to affect any other variables outside that module. Global variables exist above the scope of the module, and can be accessed inside a module if its definition doesn't have any parameters, or if they are specified explicitly with a global clause, such as

start foo; /* all variables inside foo are global */

or

start foo(a,b) global(m); /*a and b and any other variables inside foo are local, except that m is global */

Global parameter are useful for common data that may be used across several modules, but should be used with care. It is easy to introduce obscure errors in your program by accidentally modifying a global parameter that is normally assumed to be constant.