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 件のコメント
NN
2022 年 10 月 24 日
% 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
2022 年 10 月 24 日
Kindly review this code and plz let me know if there is a correction.
NN
2022 年 10 月 24 日
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;
Walter Roberson
2022 年 10 月 24 日
Can you post your complete code for testing ?
NN
2022 年 10 月 24 日
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 ?
NN
2022 年 10 月 25 日
Please let me know what it means by moving the comment
Walter Roberson
2022 年 10 月 25 日
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
2022 年 10 月 25 日
Ok Now understood I was actually asking what is the solution Please let me know if there are any solution after reviewing the code.
Walter Roberson
2022 年 10 月 25 日
I haven't had time to test it yet.
NN
2022 年 10 月 26 日
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
2022 年 11 月 8 日
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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
