1. 介绍

官网https://www.maths.ed.ac.uk/hall/HiGHS/介绍如下:
HiGHS is high performance serial and parallel software for solving large-scale sparse linear programming (LP), mixed-integer programming (MIP) and quadratic programming (QP) models, developed in C++11, with interfaces to C, C#, FORTRAN, Julia and Python.
HiGHS is based on the high performance dual revised simplex implementation (HSOL) and its parallel variant (PAMI) developed by Qi Huangfu. Features such as presolve, crash and advanced basis start have been added by Julian Hall and Ivet Galabova. The QP solver and original language interfaces were written by Michael Feldmeier. Leona Gottwald wrote the MIP solver. The software engineering of HiGHS was developed by Ivet Galabova.

  • 可求解线性规划/混合整数规划/二次规划
  • 有C, C#, FORTRAN, Julia和Python借口
  • 核心是并行的对偶改进单纯形法

参数如下

  --model_file arg        File of model to solve.
  --presolve arg          Presolve: "choose" by default - "on"/"off" are alternatives.
  --solver arg            Solver: "choose" by default - "simplex"/"ipm" are alternatives.
  --parallel arg          Parallel solve: "choose" by default - "on"/"off" are alternatives.
  --run_crossover arg     Run crossover after IPM: "on" by default - "choose"/"off" are alternatives.
  --time_limit arg        Run time limit (seconds - double).
  --options_file arg      File containing HiGHS options.
  --solution_file arg     File for writing out model solution.
  --write_model_file arg  File for writing out model.
  --random_seed arg       Seed to initialize random number generation.
  --ranging arg           Report cost, bound, RHS and basic solution ranging in any solution file: "off" by default - "on" is alternatives.
  --read_solution_file    File of solution to be read

2. 在python和Julia中使用

在Julia中配合JuMP使用即可:

using JuMP
import HiGHS
model = Model(HiGHS.Optimizer)
set_optimizer_attribute(model, "presolve", "on")
set_optimizer_attribute(model, "time_limit", 60.0)

在python中使用下面的方式安装:pip install highspy
简单例子:

import highspy
h = highspy.Highs()
h.readModel("stein9.mps")
h.silent()
h.run()
for i, val in enumerate(h.getSolution().col_value):
    print(f"{h.getColName(i)[1]} = {val}")
print(f"obj: {h.getInfo().objective_function_value}")

以及

from highspy import HighsVarType, ObjSense
m = highspy.Highs()
m.silent()
x = m.addVariable(lb=0, ub=4, type=HighsVarType.kContinuous, name='x')
y = m.addVariable(lb=1, ub=7, type=HighsVarType.kContinuous, name='y')
m.addConstr(5 <= x + 2 * y <= 15)
m.addConstr(6 <= 3 * x + 2 * y)
m.minimize(x + y)
for i, val in enumerate(m.getSolution().col_value):
    print(f"{m.getColName(i)[1]} = {val}")

建模语言python-mip目前也支持highs了,参考运筹系列51.

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐