Guropi solver fail without any clear reason
回答済みI'm implementing a guropi solver for a quadratic binary integer programming problem, and it just fail without any reason. My problem involve finding the mind of xHx, with x is a binary vector of size 378, H is a matrix of size 378x378. The matrix H is a matrix with positive diagonal, every value off-diagonal = 0. Below is my minimum code and the link to google drive contains matrices of constraint. Please help me find out what is the reason gurobi fail.
Link: https://drive.google.com/drive/folders/19XhlpmuZ4RpTnkK25YbkyUZZt8F5TGoo?usp=drive_link
import numpy as np
import torch
import cvxpy as cp
file_name = "all_constraint_optimization.pt"
all_constraint = torch.load(file_name)
diagonal_line = torch.tensor([1.2525e+03, 9.7295e+02, 4.2490e+02, 1.1673e+02, 6.3829e+01, 8.1240e+00,
9.8926e-01, 7.8628e+02, 2.9606e+02, 5.4056e+01, 1.6693e+01, 3.1802e+00,
1.5863e+00, 4.0531e-01, 4.2466e+02, 1.2126e+02, 3.9779e+01, 1.5050e+01,
1.2652e+00, 1.0762e+00, 4.8066e-01, 4.2026e+02, 9.4895e+01, 1.4343e+01,
5.7718e+00, 1.1434e+00, 2.3202e-01, 1.6105e-01, 2.0308e+03, 3.1875e+02,
6.3297e+01, 1.5572e+01, 3.5865e+00, 1.0065e+00, 2.5226e-01, 3.5530e+01,
1.4042e+01, 2.4167e+00, 6.4756e-01, 2.3935e-01, 4.9158e-02, 8.6918e-02,
7.4883e+02, 8.3016e+01, 1.5530e+02, 8.8465e+00, 1.4316e+01, 7.5778e-01,
2.6828e-01, 8.8426e+01, 1.8615e+01, 7.1063e+00, 2.5850e+00, 2.5981e-01,
1.7596e-01, 4.7290e-02, 1.3084e+02, 1.2487e+01, 4.1722e+00, 8.2224e-01,
4.5021e-01, 1.8046e-02, 1.9475e-02, 2.2598e+02, 2.9899e+01, 9.2085e+00,
2.0253e+00, 6.2246e-01, 1.8812e-01, 4.1639e-02, 2.7707e+02, 3.9004e+01,
9.1397e+00, 1.8779e+00, 5.5470e-01, 1.1793e-01, 0.0000e+00, 5.4764e+02,
1.2506e+02, 1.5378e+01, 5.2141e+00, 1.7108e+00, 4.5536e-01, 1.1366e-01,
2.4324e+02, 1.7591e+01, 5.2223e+00, 1.2038e+00, 7.0344e-01, 6.3978e-02,
5.6973e-02, 2.6071e+02, 6.8975e+01, 1.5866e+01, 5.5680e+00, 1.4551e+00,
4.3885e-01, 2.6352e-01, 3.0838e+02, 7.7244e+01, 1.9178e+01, 4.6728e+00,
1.2892e+00, 6.2781e-01, 1.2679e-01, 4.3042e+01, 1.1116e+01, 3.5652e+00,
3.7917e-01, 9.7780e-02, 6.6145e-02, 1.4888e-02, 2.0841e+02, 4.6140e+01,
1.3249e+01, 2.6195e+00, 7.4985e-01, 2.3551e-01, 8.2446e-02, 1.2883e+02,
2.4882e+01, 7.2592e+00, 1.5471e+00, 4.2695e-01, 1.2665e-01, 4.3976e-02,
4.9041e+01, 1.2128e+01, 2.1507e+00, 6.2128e-01, 1.7721e-01, 4.2942e-02,
1.5930e-02, 2.2093e+02, 1.3655e+01, 3.6789e+00, 9.2673e-01, 2.7743e-01,
8.0983e-02, 4.1457e-02, 5.2817e+01, 1.2991e+01, 5.0801e+00, 8.8538e-01,
9.4146e-01, 0.0000e+00, 4.0798e-02, 5.5224e+01, 8.7991e+00, 2.9960e+00,
7.4703e-01, 6.0489e-02, 1.0952e-01, 0.0000e+00, 1.2666e+02, 1.1303e+01,
2.7783e+00, 6.4297e-01, 2.5927e-01, 2.1052e-03, 0.0000e+00, 4.9272e+01,
1.1429e+01, 2.6665e+00, 3.5228e-01, 8.9500e-02, 1.1621e-01, 2.3529e-02,
6.3330e+02, 9.6525e+01, 2.9642e+01, 5.6173e+00, 2.0470e+00, 6.3282e-01,
1.1075e-01, 3.1552e+02, 2.6665e+01, 6.9573e+00, 1.6338e+00, 5.9670e-01,
2.0818e-01, 3.1426e-02, 3.2761e+02, 5.1484e+01, 1.5981e+01, 4.2796e+00,
1.0948e+00, 4.0624e-01, 1.7532e-01, 1.0524e+02, 2.9626e+01, 8.9242e+00,
2.1962e+00, 5.1428e-01, 1.2574e-01, 2.1217e-02, 7.5012e+01, 1.7928e+01,
4.1177e+00, 1.4196e+00, 3.0308e-01, 2.2731e-01, 2.4876e-03, 1.7973e+02,
2.6119e+01, 6.9838e+00, 1.9823e+00, 6.6638e-01, 2.0605e-01, 8.5401e-02,
1.0472e+02, 2.7505e+01, 8.9784e+00, 2.0148e+00, 7.8067e-01, 1.8138e-01,
5.2795e-02, 1.1375e+02, 1.9636e+01, 6.0499e+00, 2.0797e+00, 4.5743e-01,
1.8445e-01, 2.4181e-02, 2.3472e+02, 1.5098e+01, 3.8942e+00, 1.4666e+00,
5.0298e-01, 9.8779e-02, 3.2563e-02, 6.9781e+01, 1.7444e+01, 5.7184e+00,
1.6514e+00, 3.9180e-01, 1.1670e-01, 2.7425e-02, 9.4496e+01, 1.2985e+01,
3.4539e+00, 1.6764e+00, 3.5944e-01, 7.3787e-02, 6.0665e-02, 2.3470e+02,
1.5281e+01, 3.2893e+00, 1.4370e+00, 3.6739e-01, 1.2644e-01, 4.9863e-02,
5.3887e+01, 1.2165e+01, 3.9335e+00, 1.3971e+00, 3.2666e-01, 1.2689e-01,
6.4329e-02, 7.7040e+01, 1.5940e+01, 4.8654e+00, 1.9191e+00, 8.1373e-01,
2.6671e-01, 1.0220e-01, 1.0536e+02, 1.5339e+01, 3.9978e+00, 6.6039e-01,
4.9615e-01, 5.9513e-02, 0.0000e+00, 6.2157e+01, 1.3058e+01, 3.6886e+00,
7.3468e-01, 2.4646e-01, 9.3328e-02, 6.2606e-02, 1.9602e+02, 1.9988e+01,
7.5848e+00, 1.6497e+00, 6.4702e-01, 1.3914e-01, 1.1279e-01, 1.6915e+02,
1.6311e+01, 4.3886e+00, 1.6788e+00, 2.3090e-01, 1.5589e-01, 6.5742e-02,
8.0428e+01, 1.5120e+01, 3.8383e+00, 1.3950e+00, 6.7361e-01, 8.7440e-02,
6.2232e-02, 3.4076e+02, 7.4679e+01, 2.6462e+01, 9.7130e+00, 2.3537e+00,
7.5897e-01, 1.7328e-01, 4.5610e+02, 3.2187e+01, 7.4400e+00, 4.5974e+00,
1.4114e-01, 3.7285e-01, 2.4908e-01, 5.0092e+02, 6.2055e+01, 1.6063e+01,
6.0775e+00, 2.3364e+00, 4.5719e-01, 0.0000e+00, 2.1216e+02, 2.3072e+01,
6.1835e+00, 1.6485e+00, 5.8806e-01, 1.6575e-01, 5.4512e-02, 7.1253e+02,
4.0884e+01, 1.5118e+01, 4.1171e+00, 1.2515e+00, 3.8431e-01, 9.7005e-02,
6.9450e+02, 5.7954e+01, 1.4690e+01, 2.4038e+00, 1.7780e+00, 0.0000e+00,
3.0989e-01, 1.2033e+03, 3.1471e+02, 1.5894e+02, 4.5085e+01, 2.7082e+00,
4.0673e+00, 4.7928e-01, 4.1922e+02, 1.6758e+02, 6.0466e+01, 1.5106e+01,
1.3847e+01, 1.0273e+00, 1.0029e+00, 4.4204e+03, 4.2799e+02, 1.9486e+01,
5.1759e+00, 1.0851e+00, 3.5613e-01, 2.0448e-01, 6.5255e+02, 1.8346e+02,
3.2312e+01, 8.9642e+00, 1.9113e+00, 5.5657e-01, 1.3129e-01, 8.8452e+03,
2.0199e+02, 2.6627e+01, 7.7998e+00, 2.0748e+00, 4.9833e-01, 1.2194e-01],
dtype=torch.float64)
G_final = torch.diag(diagonal_line)
x = cp.Variable(G_final.size()[0],integer=True)
param_size_matrix = all_constraint["param_size_matrix"]
max_cost = all_constraint["max_cost"]
condition_layer_matrix = all_constraint["condition_layer_matrix"]
param_size_matrix = all_constraint["param_size_matrix"]
layer_condition_output = all_constraint["layer_condition_output"]
constraints = [param_size_matrix @ x <= max_cost,
condition_layer_matrix @ x == layer_condition_output,
x >= 0,
x <= 1]
prob = cp.Problem(cp.Minimize((1 / 2) * cp.quad_form(x, cp.psd_wrap(G_final))),
constraints
)
prob.solve(solver=cp.GUROBI,verbose=True)
-
Hi Hoang,
The program seems to finish to the end without failure on my side.
-------------------------------------------------------------------------------
Summary
-------------------------------------------------------------------------------
(CVXPY) Sep 28 10:16:06 PM: Problem status: optimal
(CVXPY) Sep 28 10:16:06 PM: Optimal value: 4.862e+02
(CVXPY) Sep 28 10:16:06 PM: Compilation took 1.563e-02 seconds
(CVXPY) Sep 28 10:16:06 PM: Solver (including time spent in interface) took 5.469e-01 secondsHow does it fail (or get error) on your side? Could you provide logs, errors, or anything else that explains the situation?
Also, the version of the module you are using, such as Gurobi, python, CVXPY, etc., is useful to reproduce the problem.Thanks,
Ryuta0 -
Thanks Ryuta, Luckily I found out the reason, the trial gurobi can only help me solve problem with < 200 decision variable, I get a free academic license and it work. However, I have another problem: how to run the gurobi in my university's HPC system? Cause academic license is only for personal PC
0 -
Hi Hoang,
Glad to hear the error was resolved. The license options for running on an HPC server are Academic WLS or Educational Institution Site License. The Site License should be managed by a system administrator. Please see:
What is an Academic WLS license? – Gurobi Help Center
How do I obtain a free academic license for a cluster or a shared computer lab? – Gurobi Help Center
Thanks,
Ryuta0
サインインしてコメントを残してください。
コメント
3件のコメント