constrained maximization, share variables of tagret function and constraint

1 次查看(过去 30 天)
I want maximize a function f(x) s.t. nonlinear cosntraints c(x). Both the function f(x) and c(x) contain a computation step g(x), which is very time consuming.
How can i avoid doing the same computation twice at each step of tha maximization loop? (Once when the constraints are evaluated, once when the taget function is evaluated)?
  2 个评论
dominik
dominik 2014-1-31
Another way to ask is: can i put the target function and the constraints vector in the same function or do something equivalent.
Amit
Amit 2014-1-31
Can you post your problem. If not the code, atleast some description of f(x), c(x) and g(x). Without that its very hard to comment on solving the issue.

请先登录,再进行评论。

采纳的回答

Amit
Amit 2014-1-31
编辑:Amit 2014-1-31
Yes. You can. You can use nested functions to utilize g(x) without calculating twice. Nested functions share the variable.
See this post with a similar question:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by