Dose who know about Optimization with Summation objective function?
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
JunGi Kim
le 29 Jan 2020
Réponse apportée : Muhammad Umair Javed
le 9 Juin 2020
Hello, I want make objective function for 24-h Charging / Discharging scheduling.
So, I made like this
for 1:24
for 1:5
fun = a*P_char*C_cost1 - (1-a)P_dischar*C_cost2 %% a=charging signal, P = charging discharging power, C = charging discharging cost
end
end
but this function didn't consider other times cost, they just think current time step only.
How can I fix my function? Plz help me. thank you :)
0 commentaires
Réponse acceptée
Alan Weiss
le 29 Jan 2020
Maybe you should update fun to remember the entire sum, not just the final one. And maybe you should name your indices.
fun = optimexpr;
for i = 1:24
for j = 1:5
fun = fun + a(i)*P_char(i)*C_cost1(j) - (1-a(i))*P_dischar(i)*C_cost2(j) %% a=charging signal, P = charging discharging power, C = charging discharging cost
end
end
I may have messed up the i and j indices, but I hope that you get the idea. You could probably create the expression without any loops, too, and it would be more efficient to do so. See Expressions for Objective Functions.
Alan Weiss
MATLAB mathematical toolbox documentation
3 commentaires
Alan Weiss
le 30 Jan 2020
I am still not sure that I understand you.
First, are you using the problem-based approach or the solver-based approach? I thought at first you were using the problem-based approach, but now I am not so sure.
For the problem-based approach, you need to create an optimization problem and optimization variables. Your objective function should not be a function handle, but instead should be an optimization expression in the optimization variables. You can use this approach only for recent MATLAB versions.
For the solver-based approach, you need to get your indices straight.
I do not understand what the command opti('fun', fun,...) does.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
Plus de réponses (1)
Muhammad Umair Javed
le 9 Juin 2020
Hi Kim
I am also working on a mixed integer nonlinear problem and using MINLP MATLAB toolbox, and using SCIP solver. I am just wondering how you to give a nonlinear objective function in this suit?
Thanking you in anticipation
Umaie
0 commentaires
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!