How can I use some of the class properties as optimization parameters while keeping others fixed ?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Abhijay Awasthi
il 13 Giu 2020
Commentato: Abhijay Awasthi
il 13 Giu 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 Commenti
Risposta accettata
Walter Roberson
il 13 Giu 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
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Genetic Algorithm in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!