Subfunctions in optimization objective function

3 次查看(过去 30 天)
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?

采纳的回答

Matt J
Matt J 2020-7-23
编辑:Matt J 2020-7-23
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 个评论
Matt J
Matt J 2020-7-23
编辑:Matt J 2020-7-23
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.
Angshuman Podder
Angshuman Podder 2020-7-23
Thank you so much. On a second thought, I guess the moles need not be integers but positive numbers.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Problem-Based Optimization Setup 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by