optimisation with dynamic objective function

5 views (last 30 days)
Hi guys I am new in optimisation and matlab. I am looking to solve a problem described as followed: decision variable pi i=1..n, binary and with constraint p(1)+p(2)+...p(n)=1 min F(p) but the issue is that F(p)=pi*ci is calculated as followed:
if p(1)=1 then ci is calculated from a sequence of equations because F describes the life cycle cost of a specific design. The same for every p(i). I could calculate the ci for every case and have something like Fi=ci*pi the problem is that there are so many cases and it is computational impossible with the optimisation and also it is not very smart. Do you have any idea how this could happen. Because I tried in the objective function file to put if p(1)==0 then the files that end up calculating the ci but matlab does not accept it.
Thank you very much in advance.
Nicky

Accepted Answer

Torsten
Torsten on 12 May 2017
If the pi's are binary and p(1)+p(2)+...+p(n)=1, then there are only n cases to consider as possible solutions.
So just calculate F(p) for these n cases and choose the one with minimum cost. Using an optimization routine will always be slower for this simple problem.
Best wishes
Torsten.
  6 Comments
Torsten
Torsten on 12 May 2017
The general structure of the objective function routine could be like
function cost = objfun(x)
p=x(1:10);
k=x(11:20);
...
if p(1)==0 && k(1)==0
cost = ...;
else if ...
cost = ...;
else if ...
cost = ...;
end if
To determine "cost" for the different cases, you can call other functions.
Do not include the function files here.
Best wishes
Torsten.
Nicky Trivyza
Nicky Trivyza on 12 May 2017
Thank you so much, really appreciated! It sounds reasonable. Will try it right now!! Nicky

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!