fmincon and choosing different initial values
조회 수: 2 (최근 30일)
이전 댓글 표시
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 ?
댓글 수: 0
답변 (1개)
Star Strider
2023년 3월 1일
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
Star Strider
2023년 3월 1일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear Programming and Mixed-Integer Linear Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!