Using different solvers in Optimization Problem
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
Hi,
I am using problem based optimization problem and i am getting same optimized values for ga, patternsearch and particle swarm .but time taken is different.
Please advice what could be the mistake
채택된 답변
Walter Roberson
2022년 10월 24일
If you are getting exactly the same results, then there are a few possibilities:
- you might have a mistake in your equation implementation that causes it to return the same values all of the time;
- you might have a mistake in how you specify the solver, causing it to always be set the same;
- you might have specified options such as integer constraints that are leading Problem Based Solver to override your solver request because the other solvers cannot handle the options / request
If you are getting the same results to within round-off error but not bit-for-bit identical:
- you might be using a simple linear equation or quadratic equation; all of the functions should converge for those kinds of function
- the result you are getting might be right at one of the constraint boundaries, so all of the solvers might end up at much the same solution
댓글 수: 12
% Minimise the cost of power
prob.ObjectiveSense = 'minimize';
prob.Objective =dt *Cost'*PESSV;
showproblem(prob)
options = optimoptions('ga',prob.optimoptions,'Display','iter');
%options = optimoptions('patternsearch',prob.optimoptions,'Display','iter');
%options = optimoptions('ga',prob.optimoptions,'Display','iter');
%options = optimoptions(aprticleswarm',prob.optimoptions,'Display','iter');
[values,~,exitflag] = solve(prob,'Options',options);
fval = evaluate(prob.Objective,values);
Kindly review this code and plz let me know if there is a correction.
I have specified my constraints as below:
% Satisfy power load with power from PV, grid and ESS
prob.Constraints.loadBalance = Ppv + windV+ PgridV + PESSV == Pload;
prob.Constraints.grid = PgridV <=3e6;
prob.Constraints.solar = Ppv <=1e6;
Can you post your complete code for testing ?
function [Pgrid,Pess,Eess] = battSolarOptimizetrial3(N,dt,Ppv,Pwind,Pload,Einit,Cost,FinalWeight,batteryMinMax)
% Minimize the cost of power from the grid
prob = optimproblem;
% Decision variables
PgridV = optimvar('PgridV',N);
PessV = optimvar('PesssV',N,'LowerBound',batteryMinMax.Pmin,'UpperBound',batteryMinMax.Pmax);
EessV = optimvar('EesssV',N,'LowerBound',batteryMinMax.Emin,'UpperBound',batteryMinMax.Emax);
% Maximise the profit from the usage of battery and PV
prob.ObjectiveSense = 'minimize';
prob.Objective =dt *Cost'*PessV;
% Satisfy power load with power from PV, grid and battery
prob.Constraints.loadBalance = Ppv + Pwind+ PgridV + PessV == Pload;
prob.Constraints.grid = PgridV <=3e6;
prob.Constraints.solar = Ppv <=1e6;
showproblem(prob)
options = optimoptions('ga',prob.optimoptions,'Display','iter');
[values,~,exitflag] = solve(prob,'Options',options);
fval = evaluate(prob.Objective,values);
tb1=struct2table(values)
% Parse optmization results
if exitflag <= 0
Pgrid = zeros(N,1);
Pess = zeros(N,1);
Eess = zeros(N,1);
else
Pgrid = values.PgridV;
Pess = values.PessV;
Eess = values.EessV;
end
NN
2022년 10월 24일
이동: Walter Roberson
2022년 10월 25일
- you might have a mistake in how you specify the solver, causing it to always be set the same;--- I just changed the solver name in the solve command below:
options = optimoptions('ga',prob.optimoptions,'Display','iter');
- you might have specified options such as integer constraints that are leading Problem Based Solver to override your solver request because the other solvers cannot handle the options / request
How do i correct it without modifying the constraints?what is the possible solution ?
Please let me know what it means by moving the comment
You posted content as an Answer, but the content was not a solution to your question and was instead a reply to what I had posted. I used moderation facilities to move your content to be a Comment rather than an Answer
Ok Now understood I was actually asking what is the solution Please let me know if there are any solution after reviewing the code.
I haven't had time to test it yet.
Ok, please check if you are free .
When i used patternsearch, i got a warning like below:
You have passed PATTERNSEARCH options to LINPROG. LINPROG will use the common options and ignore the PATTERNSEARCH options that do not apply.
To avoid this warning, convert the PATTERNSEARCH options using OPTIMOPTIONS.
Hi,
Can you please chekc on the above problem and suggest a solution please
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
