optimisation with dynamic objective function

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

 采纳的回答

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 个评论

Thank you for you fast response the problem is that the problem I showed before is a simple one in the beginning stage. I aim to have more decision variables like k(j) etc. With the same properties as p(i) and then have F(p,k,m,..)= pi*ci+kj*aj... . So it is very time consuming and not very dynamic and flexible.I have the scripts with the ci and aj .etc calculations and I cannot link them with the objective function.
Do you have any other ideas?
If the contributions to F are just added, is the solution not simply p(i)=1 for which ci is minimum, k(j)=1 for which aj is mimimum etc. ?
So again, a simple search for the minimum values of the ci, aj,... would be sufficient to solve your problem.
If this again is a simpified version of the problem you intend to solve, please post the "real" problem. Because the only MATLAB optimization tool that comes to mind is "intlinprog", and in order to use this tool, you will have to calculate the ci, aj,... in advance to supply the (constant) cost vector f.
By the way: which MATLAB tool did you try ?
Best wishes
Torsten.
I tried genetic algorithm. Sorry probably I cannot explain it well. I am working to develop an energy systems design tool, where the selection of the systems depends on the optimum cost. So P(i), k(j) etc are binary variables for each system category, for example electric thermal etc. So for example when p(1)=1 then the ci expresses the fuel cost, capital cost, operational cost for the life cycle performance, so in order to get the ci I perform a simulation which is different for every p(i) and also is affected by different k(j). So I cannot just calculate the parameters. I was just wondering how I can write in a function file in matlab intermediate calculations in order to attain the objective function. Do u think its possible? Thanks so much for your help, Nicky
for example:
function g=cs(p) if p(1)==1; file1 file2 file3 g=c (where c comes from file3) elseif p(2)==1;
file4 file5 file3 g=c ...
end
Do you think this can happen?
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.
Thank you so much, really appreciated! It sounds reasonable. Will try it right now!! Nicky

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Surrogate Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by