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

1 view (last 30 days)
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)?

Accepted Answer

Alan Weiss
Alan Weiss on 19 Jul 2023
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 Comments
Alan Weiss
Alan Weiss on 1 Aug 2023
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 on 2 Aug 2023
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

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!