Subfunctions in optimization objective function
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I am trying to use the fmincon function for a minimization problem.
I am trying to minimize the total gibbs energy of the system (objective function) but the function requires calculation of activities (which are modelled by a sub function). Can we use the general framework of fmincon to compute the optimization function?
For e.g
I want to optimize n(i) to get min(G)
G = n(1)*G(1) + n(1)*R*T*log(a1) + n(2)*G(2) + n(2)*R*T*log(a2) + ...... n(i)*G(i) + n(i)*R*T*log(ai)
Here, ai is the activity given by f(ni/(n1 + n2 + .... + ni)).
Will the current framework compute the activities at each iteration to produce the optimized value? Or do I have to reframe the problem? Or is there a better way?
0 commentaires
Réponse acceptée
Matt J
le 23 Juil 2020
Modifié(e) : Matt J
le 23 Juil 2020
fmincon does not know or care about the internals of your objective function code. You can do anything there, and call whatever subfunctions you wish, as long as the input/output relationship of the overall routine is that of a twice continuously differentiable function. The same with any nonlinear constraint functions you might supply.
In case it matters, though, note that fmincon will treat your unknown n(i) variables as continuous variables. You have no way of constraining the optimized n(i) to be integers, for example.
3 commentaires
Matt J
le 23 Juil 2020
Modifié(e) : Matt J
le 23 Juil 2020
This statement does baffle me because the fmincon should be able to do constraint optimizations since I definitely want n(i) to be positive integers.
Those aren't the kind of constraints fmincon supports. For integer-constrained non-linear optimization, you would have to use ga(). But it might be worthwhile to first solve with fmincon without integer constraints and then provide that solution as one of the population of initial guesses to ga().
So, what you are saying is that the principal variables i.e. n(i) can be cast into other variables to be used by other sub functions in the objective function?
Yes, the only thing fmincon cares about is that it can call a function y=f(n) with a guess of the n(i) and receive back a value y to be minimized ... and that that function be twice differentiable.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Problem-Based Optimization Setup dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!