Solving the Maximum and Minimum Problems of Multivariate Functions

1 回表示 (過去 30 日間)
xu
xu 2023 年 5 月 30 日
コメント済み: Torsten 2023 年 5 月 30 日
max y and min y
y=0.0435*x1-0.266*x2+4.2*x3+0.019*x1*x2-0.3 x1*x3-0.2485
10<x1<20, 0<x2<5, 30<x3<35
  4 件のコメント
xu
xu 2023 年 5 月 30 日
is this true?
Torsten
Torsten 2023 年 5 月 30 日
Yes, it's true. And the second call to fmincon with -f instead of f is the call to maximize f.
fun = @(x)0.0435*x(1)-0.266*x(2)+4.2*x(3)+0.019*x(1)*x(2)-0.3*x(1)*x(3)-0.2485;
lb=[10;0;30];
ub=[20;5;35];
A = [];
b = [];
Aeq = [];
beq = [];
x0 = [10,0,30];
[x,fval] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub);
Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
xmin = x
xmin = 1×3
20.0000 0.0000 35.0000
fval_min = fval
fval_min = -62.3785
[x,fval] = fmincon(@(x)-fun(x),x0,A,b,Aeq,beq,lb,ub);
Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
xmax = x
xmax = 1×3
10.0000 0.0000 35.0000
fval_max = -fval
fval_max = 42.1865

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

回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 5 月 30 日
移動済み: Walter Roberson 2023 年 5 月 30 日
No. You have coded finite lower bounds and upper bounds for x3, and you have coded a single region for x1. However your problem as stated has no bounds on x3, and gives two disconnected regions for x1.
fmincon and similar routines cannot handle two disconnected regions for a single variable. You will need to use ga with x1 defined over 10 to 35, and you will need to use nonlinear constraints to reject x1 that are not in either of the two regions.
  7 件のコメント
xu
xu 2023 年 5 月 30 日
So the solution I used is correct?
xu
xu 2023 年 5 月 30 日
I see. Thank you!

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

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by