MATLAB Answers

Dose who know about Optimization with Summation objective function?

26 views (last 30 days)
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
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 :)

Accepted Answer

Alan Weiss
Alan Weiss on 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
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
Alan Weiss
Alan Weiss on 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

Sign in to comment.

More Answers (1)

Muhammad Umair Javed
Muhammad Umair Javed on 9 Jun 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

Community Treasure Hunt

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

Start Hunting!

Translated by