Optimization of discontinuous function where function constants come from an array.

4 views (last 30 days)
Hello!
I am sort of new to matlab and haven't been able to find a clear answer to my problem. Thanks in advance for the help! Here's the issue:
I am analyzing solar power production (x) with an hourly resolution (8760 hours in a year) over 15 years. I want to minimize "forgone revenues" in a proyect defined by the sum of energy that can't be used (N) throughout the whole proyect (reason irrelevant here). So my optimization problem is:
A and m are different for every hour and every year, i.e. each is an 8760x15 array.
The issue here is that I don't know how to define N so that I can find the optimum with Matlab since it is also an 8760x15 array. I assume an if-else statement won't work as an input to a the Optimization toolbox functions such as linprog(), fmincon() or ga(). I tried a piecewise / handle function:
N = @(x) (0).*((Ax + m)<=n) + (Ax + m - n).*((Ax + m)>n);
But the conditional doesn't seem to work when I evaluate it with feval. For example, for lower values of x I am 100% sure I should get some N=0, but I don't. I assume the handle function doesn't work when the function constants are arrays.
Also, I believe linprog() and fmincon() won't work for discontinuous functions, any suggestions on what optimization function I might be able to use?
I am so new that I am not sure what else I should explain, so feel free to ask questions to help me solve mine. Thanks again!
  2 Comments
Amalia Diaz
Amalia Diaz on 25 Jul 2019
Edited: Amalia Diaz on 25 Jul 2019
Thank's for the fast reply Torsten! That works to define the function quite well.
What function would you suggest to run the optimization? For this problem my constraints depend on that same N, so they are dependent constraints, that is:
N_i,y - U_i,y = n - m; where U is a function similar to N_i,y in form
and
A*x <= n - m; (This one doesn't depend on N , though)
Thank you!

Sign in to comment.

Accepted Answer

Matt J
Matt J on 25 Jul 2019
Reformulate the problem as the following linear program in x and N_{i,y}
The solution has to have the property that N_{i,y}=max(0,A*x+m-n), because otherwise there would be room to further reduce N_{i,y} without violating the constraints.

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!