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

 Respuesta aceptada

Walter Roberson
Walter Roberson el 24 de Oct. de 2022

0 votos

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 comentarios

% 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);
NN
NN el 24 de Oct. de 2022
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
NN el 24 de Oct. de 2022
Movida: Walter Roberson el 25 de Oct. de 2022
  • 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 ?
NN
NN el 25 de Oct. de 2022
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
NN
NN el 25 de Oct. de 2022
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.
NN
NN el 26 de Oct. de 2022
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.
NN
NN el 8 de Nov. de 2022
Hi,
Can you please chekc on the above problem and suggest a solution please

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Versión

R2021a

Preguntada:

NN
el 24 de Oct. de 2022

Comentada:

NN
el 8 de Nov. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by