フィルターのクリア

automatic change in variable's value during optimisation

1 回表示 (過去 30 日間)
Anwar
Anwar 2024 年 4 月 20 日
コメント済み: Walter Roberson 2024 年 4 月 21 日
I am currently working on optimising the cost of charge of an electric vehicule by scheduling a charging/discharging process during 9 intervals.
During the process an uncertainty of battery degradation occures in a specific interval, the capacity is reduced from 60ah to 58.2ah.
My question is to how to update the new value while the code is running so the optimisation algorithm performs a rescheduing based on the new value ? Thank you.

採用された回答

Walter Roberson
Walter Roberson 2024 年 4 月 20 日
You do not do that. It is a truism that during any one call to the optimization routine, that given any particular set of trial parameters, the cost function must always return the same value for those trial parameters. No scheduling is possible.
You need to instead loop running the optimization function in segments of consistent parameters.
For example,
nvars = 17; %adjust as needed
maxphases = 9;
battery_degredation = linspace(60, 58.2, maxphases);
pop = [];
scores = [];
A = []; b = [];
Aeq = []; beq = [];
lb = []; ub = [];
nonlcon = [];
for phase = 1 : maxphases
if phase == 1
opts = optimoptions('ga', 'MaxFunctionEvaluations', 1000, 'MaxIterations', 1000);
else
opts = optimoptions(opts, 'InitialPopulationMatrix', pop, 'InitialScoresMatrix', scores);
end
[X,FVAL,EXITFLAG,OUTPUT,pop,scores] = ga(@(PARAMS) do_cost_function(PARAMS, batter_degredation(phase)), nvars, A, b, Aeq, beq, lb, ub, nonlcon, opts);
if EXITFLAG < 0
warning('EXITFLAG %d on phase %d', EXITFLAG, phase);
break
end
end
  3 件のコメント
Torsten
Torsten 2024 年 4 月 21 日
編集済み: Torsten 2024 年 4 月 21 日
The code above assumes that the 9 phases can be optimized one after the other without coupling. Only the result of the last phase is used as initial input for the next phase.
The parameter "battery-degradation" is passed to your cost function so that it can be used there depending on the specific interval you are in:
[X,FVAL,EXITFLAG,OUTPUT,pop,scores] = ga(@(PARAMS) do_cost_function(PARAMS, battery_degredation(phase)), nvars, A, b, Aeq, beq, lb, ub, nonlcon, opts);
Walter Roberson
Walter Roberson 2024 年 4 月 21 日
I just realized that it should probably be
opts = optimoptions(opts, 'InitialPopulationMatrix', pop);
with no initial scores matrix -- the scores will change with the degraded battery.
The way this code works is to optimize a population given a particular battery degredation. Then it takes the optimal locations and uses them as starting points for the next phase, with the next battery degredation.
Because I used ga() here, mutation and cross-over will be taking place. As a result, the effect is not of tracing particles through from the beginning to the end. Each phase is effectively providing hints to the next phase, but only hints. And if you take the final population and run them through the cost calculations from the start, then you might get fairly different answers.
To be honest, I think the whole approach is not likely to match your needs.
I suspect that you instead need to model each phase as a variable (or two) that describes the charging strategy for the phase, and model the overall "score" of the charging somehow.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Optimization Toolbox についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by