小编use*_*345的帖子

如何在使用 CPLEX Python API 后获取经过时间的值

我正在使用 CPLEX python API 来解决优化问题。该模型被命名为 DOT。当我运行 DOT.solve() 时,python 控制台中会出现许多信息:

Iteration log ...
...
Network - Optimal:  Objective =    1.6997945303e+01
Network time = 0.48 sec. (91.93 ticks)  Iterations = 50424 (8674)
...
Run Code Online (Sandbox Code Playgroud)

我的问题是有没有一种简单的方法来获取经过时间的值(即我的情况为 0.48)?不仅适用于网络优化器,也适用于对偶方法、屏障方法。

我对 python 和 CPLEX 非常陌生,非常感谢您的帮助。

python cplex python-3.x

5
推荐指数
1
解决办法
1342
查看次数

Gurobi Python API:model.addVars() 太慢

我目前正在使用 Gurobi Python API 来解决大型 LP。我发现添加变量的过程花费了太多时间,在某些情况下甚至超过优化时间。我的代码大致是这样的(我删除了读取数据的部分,让它更简单):

from gurobipy import *
import numpy as np
import time

height = 32
width = 32
size = height * width

# set dummy data
supply = [1.0] * size
demand = [1.0] * size

# compute cost
costs = ((np.arange(size) // height  - 
             np.arange(size).reshape(size,1) // height) ** 2 + \
             (np.arange(size) % width - 
              np.arange(size).reshape(size,1) % width) ** 2).ravel().tolist()

# now build up the model
model = Model("model")
model.Params.Threads = 8

# add …
Run Code Online (Sandbox Code Playgroud)

python linear-programming python-3.x gurobi

5
推荐指数
1
解决办法
1001
查看次数

标签 统计

python ×2

python-3.x ×2

cplex ×1

gurobi ×1

linear-programming ×1