解决解决方案边界 [英] fsolve with solution bounds

查看:134
本文介绍了解决解决方案边界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以在MATLAB中使用fsolve,为解决方案指定界限?即所有解决方案变量> 0

Is there a way to use fsolve in MATLAB, specifying a bound for the solution? i.e. all solution variables > 0

推荐答案

不是直接解决此问题,但是解决此问题的一种方法是在方程式中添加一个约束您问题的项.

Not directly, but one solution to this problem is to add a term to your equation which constrains your problem.

我没有优化工具箱,因此无法为您提供使用fsolve的特定示例,但是这是我将如何使用fminsearch来解决的问题,

I don't have the optimization toolbox, so I can't give you a specific example using fsolve, but here's how I would do it with fminsearch, which has the same issue.

myFun = @(args) abs( sin(args(1)) + cos(args(2)) )
fminsearch(myFun, [0, 0])
ans =

   -0.8520    0.7188

但是如果我想将我的问题限制为积极的解决方案

But if I want to constrain my problem to positive solutions

myFun = @(args) abs(sin(args(1)) + cos(args(2))) + (args(1)<0) + (args(2)<0)
fminsearch(myFun, [0, 0])
ans =

    0.0000    1.5708

应该有一种方法可以类似地调整方程式来解决您的问题.

There should be a way to tweak your equation similarly to solve your problem.

这篇关于解决解决方案边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆