Hello,
Please, how do I sove this non linear optimization problem?um.'. The idea is to declare max(1), max(2), and max(3) as constants, like 4, 6, 3..
for simplicity, I renamed the variables to; x1 = a, x2 = b, x3= c, beta1=p, beta2=q, beta3= r
minmodel = optimproblem
a=optimvar('a','Lowerbound',0);
b=optimvar('b', 'Lowerbound',0);
c=optimvar('b','Lowerbound',0);
p=optimvar('p','Lowerbound'0);
q=optimvar('q','Lowerbound'0);
r=optimvar('r','Lowerbound'0);

 採用された回答

Walter Roberson
Walter Roberson 2020 年 1 月 27 日

0 投票

If I recall correctly, non-linear optimization cannot yet be handled with Problem Based Optimization. Therefore you will need to switch to Solver Based Optimization:
z = @(xB) (exp(-xB(1)) .* max1 + xB(4).*xB(1)) + (exp(-xB(2)) .* max2 + xB(5).*xB(2)) + (exp(-xB(3)) .* max3 + xB(6).*xB(3));
fminsearch(z, rand(1,6))
However, we can see that can be combined with and into a single parameter that is their sum. Or to phrase this another way: unless you combine them into a single parameter, you will not be able to get a unique solution out of the search because the same total can be achieved by increasing one of the parameters slightly and reducing a different parameter slightly.
Perhaps the equations are not as you represented them? Perhaps you have ? But if so then the x1 parts could be combined...

3 件のコメント

Lala
Lala 2020 年 2 月 3 日
Thank you Walter. Problem based approach would not work. I had to make use fmincon. I am still not very sure of when to use Fmincon and Fminsearch. Do you have any insights?
%% Optimization Code
clc; clear;
n = 12; % Number of variables
% maximum values and beta values are defined here, the are defined in a
% vector form. Both vector are same lenght as the number of variables.
% Maximum value vector:
maxVals = [5 4 0.5 10 9 15 0.5 8.5 6 3 3.5 11];
% Beta coefficients
beta = randi([1,20],1,n);
% Defining initial guess. Let's assume a zero initial guess
x0 = zeros(1,n);
% This is the objective function that needs to be minizimed for different
% values of x.
Z = @(x) (exp(-x(1))*maxVals(1) + beta(1)*x(1)) + ...
(exp(-x(2))*maxVals(2) + beta(2)*x(2)) + ...
(exp(-x(3))*maxVals(3) + beta(3)*x(3)) + ...
(exp(-x(4))*maxVals(4) + beta(4)*x(4)) + ...
(exp(-x(5))*maxVals(5) + beta(5)*x(5)) + ...
(exp(-x(6))*maxVals(6) + beta(6)*x(6)) + ...
(exp(-x(7))*maxVals(7) + beta(7)*x(7)) + ...
(exp(-x(8))*maxVals(8) + beta(8)*x(8)) + ...
(exp(-x(9))*maxVals(9) + beta(9)*x(9)) + ...
(exp(-x(10))*maxVals(10) + beta(10)*x(10)) + ...
(exp(-x(11))*maxVals(11) + beta(11)*x(11)) + ...
(exp(-x(12))*maxVals(12) + beta(12)*x(12));
% Defining lower bound, meaning that the lowest values that the function
% can take
lb = zeros(n,1);
% Applying constraints
A = ones(1,n);
b = 1000;
% Calling fmincon, the function that will calculate the variables
opts = optimoptions('fmincon','display','none');
[xMin, val] = fmincon(Z,x0,A,b,[],[],lb,[],[],opts);
% Displaying result
fprintf('The value of Z that has been minimized is %0.4f.\n',val)
fprintf('x Values are: \n')
for i = 1:n
fprintf('\t\tx_%d:\t %0.3f\n',i,xMin(i))
end
Walter Roberson
Walter Roberson 2020 年 2 月 3 日
fmincon() and fminsearch() are both local optimizers.
fmincon() is more efficient because it has a series of stratagies to break problems into subproblems and use estimates of jacobians and related techniques. fmincon() can have constraints that are linear inequalities (and equalities) and nonlinear inequalities (and equalities)
fminsearch() uses a different search technique that is better at getting out of local basins of attraction. fminsearch() is not designed to handle constraints. However if you look in the File Exchange you can find adaptations by authors such as John D'Errico to use bounded fminsearch().
Both of them are deterministic.
Lala
Lala 2020 年 2 月 5 日
My bad. I had read without replying.
Thank you so much!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeNonlinear Optimization についてさらに検索

タグ

質問済み:

2020 年 1 月 26 日

コメント済み:

2020 年 2 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by