• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

jump-dev/KNITRO.jl: Julia interface to the Artelys Knitro solver

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

jump-dev/KNITRO.jl

开源软件地址:

https://github.com/jump-dev/KNITRO.jl

开源编程语言:

Julia 100.0%

开源软件介绍:

KNITRO.jl

KNITRO.jl underwent a major rewrite between versions 0.12.0 and 0.13.0, with the low-level wrapper now being generated automatically with Clang.jl. Users of JuMP should see no breaking changes, but if you used the lower-level C API you will need to update your code accordingly.

The KNITRO.jl package provides an interface for using the Artelys Knitro solver from Julia. You cannot use KNITRO.jl without having purchased and installed a copy of Knitro from Artelys. This package is available free of charge and in no way replaces or alters any functionality of Artelys Knitro solver.

Refer to Knitro documentation for a full specification of the Knitro's API.

The Artelys Knitro wrapper for Julia is supported by the JuMP community (which originates the development of this package) and Artelys. Feel free to contact Artelys support if you encounter any problem with this interface or the solver.

MathOptInterface (MOI)

KNITRO.jl supports MathOptInterface and JuMP.

Here's an example showcasing various features.

using JuMP, KNITRO
m = Model(optimizer_with_attributes(KNITRO.Optimizer,
                                    "honorbnds" => 1, "outlev" => 1, "algorithm" => 4)) # (1)
@variable(m, x, start = 1.2) # (2)
@variable(m, y)
@variable(m, z)
@variable(m, 4.0 <= u <= 4.0) # (3)

mysquare(x) = x^2
register(m, :mysquare, 1, mysquare, autodiff = true) # (4)

@NLobjective(m, Min, mysquare(1 - x) + 100 * (y - x^2)^2 + u)
@constraint(m, z == x + y)

optimize!(m)
(value(x), value(y), value(z), value(u), objective_value(m), termination_status(m)) # (5)
  1. Setting KNITRO options.
  2. Setting initial conditions on variables.
  3. Setting box constraints on variables.
  4. Registering a user-defined function for use in the problem.
  5. Querying various results from the solver.

Low-level wrapper

KNITRO.jl implements most of Knitro's functionalities. If you aim at using part of Knitro's API that are not implemented in the MathOptInterface/JuMP ecosystem, you can refer to the low level API which wraps directly Knitro's C API (whose templates are specified in the file knitro.h).

Extensive examples using the C wrapper can be found in examples/.

Ampl wrapper

The package AmplNLWriter.jl allows to to call knitroampl through Julia to solve JuMP's optimization models.

The usage is as follow:

using JuMP, KNITRO, AmplNLWriter

model = Model(() -> AmplNLWriter.Optimizer(KNITRO.amplexe, ["outlev=3"]))

Installation Troubleshooting

If you are having issues installing, here are several things to try:

  • Make sure that you have defined your global variables correctly, for example with export KNITRODIR="/path/to/knitro-vXXX-$OS-64" and export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$KNITRODIR/lib". You can check that KNITRO.jl sees your library with using KNITRO; KNITRO.has_knitro().

  • If KNITRO.has_knitro() returns false but you are confident that your paths are correct, try running build KNITRO and restarting Julia. In at least one user's experience, installing and using KNITRO in a temporary Julia environment (activated with ] activate --temp) does not work and the need to manually build is likely the reason why.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap