MATLAB Answers

Can Matlab Optimisation Toolbox solve this problem?

17 views (last 30 days)
Jeff on 23 Jan 2014
Commented: Walter Roberson on 4 Dec 2020
I want to maximise a linear objective function, but 2 of the variables are time dependent with discrete values.
Essentially, the problem involves maximising revenues using batteries to store electricity from the grid and then sell it at a later time. So the electricity spot market price will vary with time. Later, I also have to incorporate the battery system with solar panels, so the power output will also vary with time. I want to optimise the charging schedule to generate the most profit.
I can express everything linearly, but after reading some examples on the kind of problems you can solve with the optimisation toolbox, none had variables that change depending on the time like the spot market prices. Is't possible to adapt my problem and solve it using linear programming?

Accepted Answer

Alan Weiss
Alan Weiss on 23 Jan 2014
I am not sure that I understand you properly. When you say "2 of the variables are time dependent with discrete values" does it mean that the variables that you are trying to solve for must be discrete valued, or that the data you are supplying is discrete valued, and the solution at each time is the solution to a linear programming problem?
If you want some solution variables to be discrete valued, then the only solver that applies is GA from the Global Optimization Toolbox. See the documentation on mixed integer optimization. Be aware that GA is a slow and rather fickle optimizer.
If your solution variables are all continuous, and only the problem data is time-dependent and discrete, then I think you can solve the problem at each time point using linprog. Maybe you don't know how many time points to choose, but I think some experimentation would show the way.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
Walter Roberson
Walter Roberson on 4 Dec 2020
The equation I'm trying to maximise is the revenue, which is the sum of price * power exported into the grid - (price + tariff) * power imported from the grid over time t=1 to 24.
You cannot reliably maximize revenue in any actual electral system.
Suppose I have 1000 units of electrical capacity to sell. Suppose it is cold tonight, so there is a demand for electricty for heating, and consumers are willing to pay "decently". Do I sell the units now, or do I hold on to them hoping that I can get a better price later?
So I listen to the weather forecast (which is information not available to your model as-stands, but potentially could be available), and I see that there is a high pressure system coming in from the west, and there is a low pressure system beside it. 80% of the time when that kind of weather pattern is coming through, the high pressure will sit over the city and bring significantly colder weather (polar vortex), so there is an 80% chance that the demand for electricity, which is elevated already, will increase dramatically tomorrow, so if I hold on to those 1000 units tonight, there is an 80% chance that tomorrow I will be able to get a much better spot price for them. But! The remaining 20% of the time, the low pressure front will direct the polar vortex south of the city instead and there will be low pressure over the city tomorrow, which will bring some snow but also will be warmer than today, so demand for electricty will fall, and I would be much better off selling the units today at the "decent" but not exceptional price.
What do I do?
The model being proposed in this Question, in order to maximze revenue, requires perfect knowledge of what the future will bring. The weather forecast for tomorrow might be identical to the forecast for today, but overnight a major petroleum exporting country might announce that it is increasing capacity or decreasing capacity, so demand for electricty might go down or up due to non-physical factors.
So.. assuming I know the precise weather for tomorrow, and assume that somehow I know that OPEC is not going to change capacity overnight. Can I still reliably predict what I should do? No! Because whether I make the electrical units available or not can change the demand!
Thus, even if you make a retrospective analysis of what you "should" have done if you had had perfect knowledge of weather and OPEC, actual demand could have changed depending on whether you made the units available or not! In situations where there is any surplus units available on the market, the more units you release, the more prices fall, as competitors lower their prices to try to be the ones that customers buy from instead of you.
You can only maximize revenue within toy systems of perfect future knowledge and when prices do not vary according to whether you sell or not.

Sign in to comment.

More Answers (1)

AHMED FAKHRI on 4 Dec 2020
please are you aware of any example that maximise that consumer and producer surplus?

Community Treasure Hunt

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

Start Hunting!

Translated by