Solve non-linear equation with 2 unknowns and lb/ub constraints

1 回表示 (過去 30 日間)
Sophia
Sophia 2012 年 6 月 21 日
Hello, I'm trying to maximize an objective function with 2 unknown variables subject to lower/upper bound constraints on the unknowns. The objective function is:
function F = v_optimal2(v)
%br: function has two optimal speed params
F = (13597150/(1+.000273)^((2781.4+6278.5)/(24*v(1))- (34993*(2781.4+6278.5)/(24*v(1))+ ...
600*55*((v(1)/16)^3)*(2781.4+6278.5)/24*v(1))/(1+.000273)^((2781.4)/24*v(1)- 34993*(2781.4+6278.5)/(24*v(2))+ ...
600*55*((v(1)/v(2))^3)*(2781.4+6278.5)/24*v(2))));
end
To solve, I run:
x0 = [13.5; 8]; %Make a starting guess at the solution
[x,fval] = fminimax(@v_optimal2,x0,[],[],[],[],8,16); %Call solver
>> solveOptimalSpeed
Local minimum possible. Constraints satisfied.
fminimax stopped because the size of the current search direction is less than
twice the default value of the step size tolerance and constraints are
satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
Optimization stopped because the norm of the current search direction, 0.000000e+00,
is less than 2*options.TolX = 1.000000e-06, and the maximum constraint
violation, 0.000000e+00, is less than options.TolCon = 1.000000e-06.
Optimization Metric Options
norm(search direction) = 0.00e+00 TolX = 1e-06 (default)
max(constraint violation) = 0.00e+00 TolCon = 1e-06 (default)
So my questions are:
1. Before I get really into depth on the stopping criteria, is this the correct Matlab function to use?
2. If minimax is okay, why isn't it solving and how do I get the max instead of min (doing -@voptimal2 did not work)

採用された回答

Sean de Wolski
Sean de Wolski 2012 年 6 月 21 日
FMINIMAX solves a minimax objective; you have a regular maximum objective and thus should be using FMINCON with the negative output of the objective function. Also, you will need LB/UB for as many variables as you have. Since v is a two element vector, you will want LB/UB to be 1x2 vectors.
  1 件のコメント
Sophia
Sophia 2012 年 6 月 22 日
Thanks! FMINCON worked with modified code:
x0 = [13.5; 8]; % Make a starting guess at the solution
lb = [8 8];
ub = [16 16];
[x,fval] = fmincon(@v_optimal3,x0,[],[],[],[],lb,ub); % Call solver

サインインしてコメントする。

その他の回答 (1 件)

Sargondjani
Sargondjani 2012 年 6 月 21 日
to get the min instead of max you have to put a minus in the objective (and yes this is annoying)
but if you just try to maximize a function with constraints, you should fmincon instead of fminimax ( fminsearchbnd in the file exchange could do the job as well, i suppose)
  1 件のコメント
Sophia
Sophia 2012 年 6 月 22 日
Thanks Sargondjani, I just stuck a minus sign in the function objective.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOptimization についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by