fmincon with external function as constraint
显示 更早的评论
I use the fmincon to optimize the size of electrical motor. I also use the OctaveFemm toolbox to connect the Matlab with FEMM 4.2 solver. I have the function geometry.m which I use to load my model to FEMM (the inputs are dimensions of the machine). Next I use mi_analyse command to start FEMM calculations and after this I have the function torque_read which provides me the torque from obtained FEMM results as a value in Matlab.
I would like to add the optimisation constraint for torque range. Is it possible to implement my FEMM calculation procedure somewhere in fmincon function?
回答(1 个)
Walter Roberson
2017-2-22
0 个投票
The nonlcon parameter expects a function handle. The function can call upon whatever other functions it wants. The requirements are:
- the nonlcon function must return two outputs (not a vector of length two), the first of which is the nonlinear inequality constraints, and the second of which is the nonlinear equality constraints. Return [] in the appropriate position if a constraint does not apply
- the inequality constraint is a vector or matrix output. Each entry must be negative or 0 to indicate that the constraint is not violated, with positive indicating a constraint violation
- the nonlinear equality constraint should be 0 when the constraint is not violated.
类别
在 帮助中心 和 File Exchange 中查找有关 Quadratic Programming and Cone Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!