MATLAB: Optimisation with dynamic objective function

dynamic objective functionoptimisation

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

Best Answer

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.