How can I use some of the class properties as optimization parameters while keeping others fixed ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Abhijay Awasthi
am 13 Jun. 2020
Kommentiert: Abhijay Awasthi
am 13 Jun. 2020
Hi,
I have a class that contains the model parameters required to model a fuel cell. While modeling the fuel cell, I pass an object instance of this class to the functions where these parameters are used for calculations. Now, I want to use same model/functions and perform optimization/calibration on fuel cell. This would require me to vary some of the model parameters while keeping others as fixed vlaues. The split between the number of fixed and varying parameters can also change.
As per my limited understanding, If I pass the object with all the properties to the optimizer function then all the parameters would be varied. So, my question is: how can I divide the properties of the class object into two sets: fixed and varying and then pass them to the optimizer.
I have looked into the answer at link below that highlights the method of using wrapper functions. But I am still not sure how do apply this idea when the parameter set is contained inside a class object.
Thanks.
6 Kommentare
Akzeptierte Antwort
Walter Roberson
am 13 Jun. 2020
The split between the number of fixed and varying parameters can also change.
For each different combination, write a accessory function that accepts and object and a vector of values, and splits the values in pieces and sets the object properties to the extracted parts and returns the resulting object.
Then write an objective function that is parameterized to accept a vector of values and the "prototype" object and a function handle (to the accessory function.) The objective function should pass the vector of values and the prototype to the accessory function, getting back an object, and then the objective function should calculate the "cost" of that particular object.
As far as the optimization functions are concerned, they are calling a function that accepts a vector of values. The anonymous function captures the prototype and the accessory function handle, calls the accessory function to build the new object, and costs that out.
Depending on your needs, it might be possible to construct just one accessory function that takes a data structure that describes how to do the splitting, such as a struct with fields named for properties to set, and whose values are indices of values to take from the x vector and pass into the set() routine
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Genetic Algorithm finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!