Re: Multiple outputs from fmincon
- From: Alan Weiss <aweiss@xxxxxxxxxxxxx>
- Date: Mon, 20 Apr 2009 14:09:57 -0400
Steve, it is possible that a solution is to remove a semicolon:
function x = try1(q)
x = -(4*q-.5*q^2);
y = -(5*q-23)*x % note: no semicolon
Here's a transcript of the MATLAB run:
[q,fval]=fmincon(@try1,x0,A,b);
Warning: Trust-region-reflective algorithm does not currently solve this type of problem,
using active-set (line search) instead.
> In fmincon at 436
y =
0
y =
-1.3709e-006
y =
-24.0000
y =
-24.0000
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the function tolerance,
and constraints were satisfied to within the default value of the constraint tolerance.
Alan Weiss
MATLAB mathematical toolbox documentation
Steve Kasperski wrote:
I am having trouble getting multiple outputs from fmincon. I want to retrieve the solution, the value of the objective function, and a third output which is a function of both the optimal solution as well as the value of the objective function. The simpliest form of this problem I could think of is described below:.
function [x,y] = try1(q)
x=-(4*q-.5*q^2);
y=-(5*q-23)*x;
x0=0;
A=1;
b=10;
[q,fval]=fmincon(@try1,x0,A,b);
The solution to this problem is obvious (q=4;x=-8;y=-24), but the only outputs I can get from fmincon are q=4 and fval=x=-8. My real problem is too complicated to discuss here, but y is not something that can be calculated after the values of q and x are determined by fmincon. Therefore I need fmincon to display multiple outputs or have an output function that displays the value of q, x, and y at every iteration and I can just take the ending value for y.
Any suggestions are welcome. Thanks for reading.
Steve
- Follow-Ups:
- Re: Multiple outputs from fmincon
- From: Steve Kasperski
- Re: Multiple outputs from fmincon
- References:
- Multiple outputs from fmincon
- From: Steve Kasperski
- Multiple outputs from fmincon
- Prev by Date: Re: image correlation matching
- Next by Date: Re: Help: Error when convert a very large integer(for example 2^256-1) to a binary due to the rounding error
- Previous by thread: Multiple outputs from fmincon
- Next by thread: Re: Multiple outputs from fmincon
- Index(es):
Relevant Pages
|