2016-07-07 11 views
0

私はいくつかの最適化の問題を解決するために、PythonでGUROBIと一緒に "パルプ"を使用しています。たとえば、計算がGUROBIのためにログされています。私は800K最適化問題を解決しようと私のコードがあまりにも遅くなり、出力にこれらのログを書いていますので、私はこの出力を無効にしたいパルプの計算ログを無効にする方法

Optimize a model with 12 rows, 25 columns and 39 nonzeros 
Coefficient statistics: 
    Matrix range [1e+00, 1e+00] 
    Objective range [1e+00, 1e+00] 
    Bounds range [1e+00, 1e+00] 
    RHS range  [1e+00, 1e+00] 
Found heuristic solution: objective 12 
Presolve removed 3 rows and 12 columns 
Presolve time: 0.00s 
Presolved: 9 rows, 13 columns, 27 nonzeros 
Variable types: 0 continuous, 13 integer (13 binary) 

Root relaxation: objective 7.000000e+00, 11 iterations, 0.00 seconds 

    Nodes | Current Node |  Objective Bounds  |  Work 
Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time 

* 0  0    0  7.0000000 7.00000 0.00%  - 0s 

Explored 0 nodes (11 simplex iterations) in 0.00 seconds 
Thread count was 4 (of 4 available processors) 

Optimal solution found (tolerance 1.00e-04) 
Best objective 7.000000000000e+00, best bound 7.000000000000e+00, gap 0.0% 
('Gurobi status=', 2) 

。これらのログを無効にする考えはありますか?

答えて

1

私はちょうど私達がそれを行うことができる方法が見つかりました:代わりであるGurobiを呼び出すのデフォルトの方法の :

pulp.GUROBI().solve(prob) 

我々が記述する必要があります。

pulp.GUROBI(msg=0).solve(prob) 
0

m0_asの答えは正しいです。ちょっとした詳細を共有したいだけです。 PuLPライブラリでは、各ソルバークラスは同じ基本クラスLpSolverから派生しています。

class LpSolver: 
    """A generic LP Solver""" 

    def __init__(self, mip = True, msg = True, options = [], *args, **kwargs): 
     self.mip = mip 
     self.msg = msg 
     self.options = options 

これらは、ソルバーからstdoutへ情報をエコーするかどうかを定義するmsgパラメータです。これはclass GUROBI

参照ライン1774の実装である、それはあなたが簡単に非常に簡単にこのソースファイル内の他のソルバーの特定のパラメータを見つけることができ

@param msg: displays information from the solver to stdout 

言います。

関連する問題