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 Exchange에서 Nonlinear 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