Saving/Reading variables based on ga optimization results
조회 수: 11 (최근 30일)
이전 댓글 표시
I have a question with regards to the ga solver in which I want to get the output of specific intermediate variables within the problem I am trying to solve. I only want to see the results corresponding to the optimal values.
In my objective function, I am trying to minimize the electricity cost of a building by optimizing the resistance of the insulation materials of the walls. The optimization works fine and I can get the x values and the cost of electricity by default. The script is long but lets say I have the zone indoor temperature (ZoneTemp) and the electricity end use (ElecUse) as intermediate variables that the final electricity cost depends on, how can I get these 2 variables as an output from the ga solver? I am sure there is a way to store these values to be read after the optimization is done. I tried to look at the "Custom Output Function for Genetic Algorithm" documentation but I am somehow lost as I am new to MATLAB.
I will just give a simple example of what I am trying to get
%This is my objective function in which I am using ga to minimize the toal cost of electricity
%To calculate the TotalCost there are too many variables and equations, these include ElecUse and ZoneTemp.
TotalCost = ElecUse * ElecRate
ElecUse = LightLoad + HVACLoad + PplLoad ... etc...
HVACLoad = ZoneTemp*...... etc...
I hope this is clear...
Any hints or examples would be appreciated. Thank you!
댓글 수: 4
Ameer Hamza
2020년 5월 5일
So if you get the value of x at each iteration, you can then use those values to find the values of ZoneTemp and ElecUse at each iteration. Is that correct?
채택된 답변
Ameer Hamza
2020년 5월 5일
See my code here: https://www.mathworks.com/matlabcentral/answers/514594-plot-the-function-value-according-to-the-value-of-the-optimized-parameter-by-genetic-algorithm to see how to extract the best values of x for all iterations. The once extracted, you can use those to the values of x to calculate ZoneTemp and ElecUse according to their formula.
댓글 수: 4
Ameer Hamza
2020년 5월 5일
The outputFcn is only used to analyze the states of the optimizer itself. The code in my other answer is also a custom output function. They are still not aware of the internal mechanism of the objective function. They are used to analyze states of the optimizer, e.g., population size, current population members, their fitness values, etc.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Particle Swarm에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!