在Java中使用Gurobi与在Ampl中使用Gurobi [英] Using gurobi with java vs gurobi with ampl

查看:653
本文介绍了在Java中使用Gurobi与在Ampl中使用Gurobi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Gurobi和AMPL代替使用Gurobi直接API(Java,C#,C ++等)来解决大型MIP问题有什么优势?使用Gurobi的API而不是AMPL可以提高性能吗?

What are the advantages of using Gurobi with AMPL instead of using Gurobi direct API (java, C#, C++, etc.) for solving large MIP problems? Are there performance benefits when using Gurobi's API instead of AMPL?

推荐答案

直到90年代中期,使用MIP求解器出现大规模问题(因此不包括电子表格)的唯一实用选择是

Up until the mid 90's the only practical options for using a MIP solver with large scale problems (so excluding spreadsheets) were

  • creating mps files
  • using the low-level C interface (known as the callable library in cplex)
  • using a domain specific language like AMPL or GAMS.

当时,对于非平凡复杂性的MIP模型,AMPL模型将更加简洁,易读且易于维护.即使到了今天,AMPL模型也将看起来更像是一种数学公式.

At the time, for MIP models of nontrivial complexity, the AMPL models would be much more concise, readable and easier to maintain. Even today and AMPL model is going to look much more like a mathematical formulation than anything else.

AMPL的一个优点是它的数据结构,但是如今C#,Java和C ++的标准库都具有很好的数据结构. AMPL的另一个优点是它的语法看起来非常直观

One advantage of AMPL is its data structures, however today the standard libraries for C#, Java and C++ all have great data structures. Another advantage of AMPL is that its syntax looks very intuitive

subject to {j in J} sum {i in I} x[i,j] <= b[j]

但是新的C ++ 0x和Java的最新版本的语法更接近于此.

but the new C++0x and the latest versions of Java have syntax that more closely mimics this.

AMPL在求解器之间是可移植的,但是在求解器之间的接口差别不大.虽然将应用程序从一个求解程序移植到另一个求解程序不是一件容易的事,但对我而言,这并不像尝试将数据库切换(例如从MySQL转换为Postgres)那样重要.

AMPL is portable between solvers, however the interfaces don't differ that much between solvers. While it's not a trivial task to port an application from one solver to another, for me it hasn't been as big of a deal as trying to switch databases (say from MySQL to Postgres).

AMPL有一些特定的缺点.对于大多数业务应用程序而言,将AMPL引入项目意味着在组合中添加另一种编程语言.花时间学习AMPL仅对编写数学编程模型有用.与Java,C#甚至C ++相比,AMPL的用户群很小,并且对底层技术的改进仅来自一家小型公司(充满了非常聪明的人,但是只有一家小型公司).如果您想使用混合方法来解决您的优化问题(例如,具有启发式生成其他列的启发式列生成策略),则可能会遇到麻烦.如果您想做一些事情,例如将求解器运行到最佳状态的1%,但要运行至少10秒钟,则不能使用AMPL来做到这一点,但是可以使用一种Gurobi API进行回调来做到这一点.

There are some specific disadvantages of AMPL. For most business applications, introducing AMPL to a project means adding another programming language to the mix. Time spent learning AMPL will be useful only for writing math programming models. AMPL has a tiny user base compared with Java, C# or even C++ and improvements to the underlying technology come from only one small company (full of very smart people, but a single small company nonetheless). If you want to use a hybrid approach to solving your optimization problem (for example, a column generation strategy with a heuristic to generate additional columns), you are left to some kludges. If you want to do something like run your solver until 1% of optimality, but run for at least 10 seconds, you can't do that with AMPL, but could do it with callbacks using one of the Gurobi APIs.

Python可能会提供两全其美的方法.它是一种通用的编程语言,具有广泛的应用领域. Gurobi拥有自己的Python API ,但是有内部特定于域的语言,例如 PuLP

Python may offer the best of both worlds. It is a general purpose programming language that is a wide variety of application areas. Gurobi has its own Python API, but there are internal domain specific languages like PuLP and Pyomo which portable between solvers.

这篇关于在Java中使用Gurobi与在Ampl中使用Gurobi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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