How to obtain the optimised decision variable in the lower-layer when using genetic algorithm for a two-layer optimisation problem?

1 次查看(过去 30 天)
I have a two-layer optimisation problem with some decision variables, and the number of the lower-layer decision variables (DV_Low) is dependent on the upper-layer decision avriable (DV_Up). The structure of my function looks like this:
[DV_Up_Opt,Obj_Up_Opt] = ga(@Objective_function_Up,...);
function [Obj_Up] = Objective_function_Up(DV_Up)
[DV_Low_Opt,Obj_Low_Opt] = ga(@Objective_function_Low,...);
Obj_Up = Obj_Low_Opt;
function [Obj_Low] = Objective_function_Low(DV_Low);
... (the size of DV_Low is dependent on the values of DV_Up)
end
end
I want to know if there is any way for me to obtain the optimised lower-layer decision variables (DV_Low_Opt) that correspond to my optimised upper-layer decision variables (DV_Up_Opt)?

采纳的回答

Alan Weiss
Alan Weiss 2023-7-19
You can write these to an array, if you like. Something like this:
function [DV_Up_Opt,Obj_Up_Opt,lowhistory] = myfun()
lowhistory = []; %%%
[DV_Up_Opt,Obj_Up_Opt] = ga(@(x)Objective_function_Up(x,lowhistory),...); %%%
function [Obj_Up,lowhistory] = Objective_function_Up(DV_Up,lowhistory)
[DV_Low_Opt,Obj_Low_Opt] = ga(@Objective_function_Low,...);
Obj_Up = Obj_Low_Opt;
lowhistory = [lowhistory;DV_Low_Opt]; %%%
function [Obj_Low] = Objective_function_Low(DV_Low);
... (the size of DV_Low is dependent on the values of DV_Up)
end
end
end
Alan Weiss
MATLAB mathematical toolbox documentation
  3 个评论
Alan Weiss
Alan Weiss 2023-8-1
That is a very interesting finding. I am not sure how the nested objective function behaves with the lowhistory data passed the way you do it.
As you probably know, ga in parallel distributes the objective function to various workers to evaluate. When doing so, it packages lowhistory as data along with the evaluation point. Because of the way you pass lowhistory as input and output from Objective_function_Up, I am not completely sure what happens, whether things are getting passed the way you want to the various workers, or whether things somehow get mixed up because the workers have different versions of lowhistory. I do not have time right now to investigate, sorry, but it might be worth trying to figure out what you want lowhistory to represent in a parallel computation. Do you want the workers to have different versions of lowhistory? How do you want to recombine them into a sensible history? Or do I misunderstand entirely?
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
Xuming Yuan
Xuming Yuan 2023-8-2
Hi Alan
I just want to obtain the optimal lower-layer solution that correspond to my optimal upper-layer solution. If it is possible to keep a record of the history of the optimised decision variables, it is even better, but this is not very necessary to me.
Best Wishes
Xuming Yuan

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by