在C ++中实现Matlab的fmincon函数 [英] Implementation of Matlab's fmincon function in C++

查看:1879
本文介绍了在C ++中实现Matlab的fmincon函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前正在使用Matlab的 fmincon 函数对我正在进行的项目进行非线性优化。我们需要将该项目的那部分移植到C ++,以便将其与项目的其他部分集成。是否有一个好的方法来将 fmincon 函数编译到我们可以在C ++中使用的库中?或者,在某个实现了 fmincon 的地方是否已经有一个库?

We're currently using Matlab's fmincon function to do non-linear optimization for a project I'm working on. We need to port that part of the project to C++ in order to integrate it with other parts of the project. Is there a good way to compile the fmincon function into a library that we can use in C++? Or, is there already a library available somewhere that implements fmincon?

如果上面两个都不是一个选项,

If neither of the above are an option, what optimization libraries are available that would be fairly easy to switch to from fmincon?

背景信息

我们正在尝试优化无人机的航点飞行路径,以尽可能接近沿着地面的给定航点相机路径。两个路径之间的路径点在时间上对应,因此当UAV到达第i个飞行路径航点时,照相机云台将指向第i个照相机航点。飞行路径段将都是相同的长度,因为UAV以恒定速度飞行。转弯半径也受上限约束。对相机路径没有约束,因此其段可以比飞行路径段更长或更短,并且其可以具有急转弯。成本函数是相应的飞行航点和相机航点之间的平方距离(忽略高度差)。

We're trying to optimize a waypoint flight path of a UAV to follow a given waypoint camera path along the ground as closely as possible. The waypoints between the two paths correspond temporally, so the camera gimbal will be pointed at the i-th camera waypoint when the UAV arrives at the i-th flight path waypoint. The flight path segments will all be the same length since the UAV flies at a constant speed. The turn radius is also constrained by an upper bound. There are no constraints on the camera path, so its segments may be longer or shorter than the flight path segments and it may have sharp turns. The cost function is the sum-squared distance between corresponding flight waypoints and camera waypoints (ignoring altitude differences).

推荐答案

时间,图书馆不会试图成为一个黑盒魔术一个适合所有的优化工具,如fmincon是 - 而是他们将需要你提供更多的细节,并自己做出更多的选择,这是更简单的他们应该导致你的软件更快。你当然可以使用MATLAB Engine或MATLAB Compiler从程序中调用fmincon,但是很可能你的软件运行得更快(如果你可以使用更多的结构知识,你可以避免购买MATLAB Compiler)优化问题并且调用一个合适的算法。

Most of the time, libraries out there won't try to be a black box magic one-size-fits-all optimization tool like fmincon is- instead they'll require you to provide more detail and make more choices on your own, which is simpler for them and should result in your software being faster. You can certainly use the MATLAB Engine or MATLAB Compiler to call fmincon from your program, but most likely your software will run a good deal faster (and you can avoid purchasing the MATLAB Compiler) if you can use a little more knowledge about the structure your optimization problem has and call an appropriate algorithm.

你的背景信息并没有描述你在做什么 - 你的可行集合是否足够让我能够告诉你应该使用什么,所以我可以做的是指向相关资源的方向。

Your background info doesn't describe what you're doing - esp. what your feasible set is- clearly enough for me to be able to tell you what to use, so all I can do is point you in the direction of relevant resources.

维基百科的优化页面链接到优化软件列表 - 最重要的是,它描述了更多特定类型的优化问题(例如,你可以用线性约束的二次规划来制定你的问题)和适合每种情况的软件。

Wikipedia's page on optimization links to lists of optimization software- most importantly, it describes more specific kinds of optimization problems (for instance, can you formulate your problem as quadratic programming with linear constraints?) and software appropriate for each situation.

Boyd的关于凸优化的书和链接的课程材料&视频是非常好的资源。

Boyd's book on convex optimization and the linked course materials & videos are really good resources.

这篇关于在C ++中实现Matlab的fmincon函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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