fmincon and choosing different initial values

4 views (last 30 days)
I have nonlinear optimization problem.I write the MATLAB code using fmincon given below. Now, I want to run the code for different initial point using a loop for to check the solutions. How can I do that and find the best initial values? Also, how can I improve my code and make sure that I am not having a local maximization ?
R=readtable('r.csv');
R=table2array(R);
w1= [ ; ; ; ; ; ];
w2= [ ; ; ; ; ; ];
w3= [ ; ; ; ; ; ];
w4= [ ; ; ; ; ; ];
w5= [ ; ; ; ; ; ];
w6= [ ; ; ; ; ; ];
W = [w1.'; w2.'; w3.'; w4.';w5.';w6.'];
gamma = 2;
Aeq = [1 1 1 1 1 1];
beq = 1;
lb = zeros(6,1);
ub = ones(6,1);
x0=
u = @(x) 1/(1-gamma)*x.^(1-gamma);
obj = @(x)-sum(u(x*W.'*R));
x = fmincon(obj,x0,[],[],Aeq,beq,lb,ub)
I run the code by using x0=0.1667*ones(1,6); and I recived
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.
<stopping criteria details>
How would I improve my solution ? what should I change ?

Answers (1)

Star Strider
Star Strider on 1 Mar 2023
The Global Optimization Toolbox has a number of functions that can search the parameter space for different initial parameter estimates and determine the best set. My favourite is ga, and there are others such as GlobalSearch, and MultiStart. Search the documentation for still more options.
  2 Comments
Az.Sa
Az.Sa on 1 Mar 2023
can you please explain more ? how can I add it to my code ?
Star Strider
Star Strider on 1 Mar 2023
Please see the documentation I linked to in order to understand how to use the appropriate function with your code.
Also, unless you need to know the column headers (variable names) in your file, use readmatrix instead of readtable and then table2array.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!