Skip to main content

Warmstart or VarHintVal in QP Python API

Answered

Comments

3 comments

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Oguz,

    You can use the MIP start and/or the VarHintVal for (MI)QPs the same way as you did for MIPs, see also How do I use MIP starts?

    Does your problem rather have problems finding a good feasible solution or does the lower bound move slowly? You could try experimenting with the MIPFocus parameter then. Set it to 1 if you need to find feasible solutions and to 2 or 3 if you think that feasible points are not a problem. You could also try the new no relaxation heuristic (NoRelHeurTime), for finding feasible points before the B&B starts.

    Other than that, you could try systematically removing parts of your model to detect the source of complexity in your problem. Please also note that finite bounds for all variables are strongly recommended for non-convex problems. Additionally, making sure that the coefficient ranges are not too big, in best case [1e0, 1e4] for quadratic problems, may help immensely.

    Best regards,
    Jaromił

    0
  • oguz toragay
    Gurobi-versary
    First Question
    First Comment

    Hi Jaromił,

    I tried whatever you suggested. Unfortunately, even after 6 hours, there is no incumbent solution. In Pyomo you can initialize the variable, I modeled my problem in Pyomo and used the initialization which works well (I used warmstart option for gurobi).

    In the current model where I want to remove all the integer (binary) variables and instead use the semi-continuous variable together with quadratic constraints, I have the following problem. I am trying to somehow accelerate the solving process but I couldn't find a good way.

    Changed value of parameter NonConvex to 2
    Changed value of parameter TimeLimit to 18000.0
    Changed value of parameter Threads to 8
    Changed value of parameter InfUnbdInfo to 1
    Changed value of parameter Method to 1
    No parameters matching 'Warmstart' found

    Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
    Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
    Optimize a model with 114 rows, 315 columns and 1314 nonzeros
    Model fingerprint: 0x23f04c73
    Model has 1100 quadratic constraints
    Variable types: 195 continuous, 0 integer (0 binary)
    Semi-Variable types: 120 continuous, 0 integer
    Coefficient statistics:
    Matrix range [1e+00, 5e+00]
    QMatrix range [4e-02, 9e+03]
    QLMatrix range [1e+00, 1e+00]
    Objective range [1e+01, 5e+01]
    Bounds range [1e-01, 8e-01]
    RHS range [0e+00, 0e+00]
    QRHS range [3e+01, 3e+01]
    Presolve removed 0 rows and 23 columns
    Presolve time: 0.31s
    Presolved: 5158 rows, 1309 columns, 16193 nonzeros
    Presolved model has 1417 bilinear constraint(s)
    Variable types: 1193 continuous, 116 integer (116 binary)
    Root relaxation: objective 2.794187e+00, 4986 iterations, 0.27 seconds


    Nodes | Current Node | Objective Bounds | Work
    Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time
    0           0           2.79419           0           224           -           2.79419           -           -           0s
    0           0           2.79454           0           220           -           2.79454           -           -           0s
    0           0           2.79454           0           220           -           2.79454           -           -           0s
    0           0           2.79454           0           220           -           2.79454           -           -           0s
    0           0           2.79454           0           220           -           2.79454           -           -           0s
    0           2           2.79454           0           220           -           2.79454           -           -           1s
    7373               5134               30.21362           58           233           -           5.18960           -           504           100s
    18291             14258             11.91965           20           164           -           6.03791           -           487           204s
    28608             22958             10.42726           30           251           -           6.57196           -           471           303s
    40140             32829             10.16517           20           160           -           6.92153           -           457           400s
    50557             41658             16.61083           29           227           -           7.12441           -           457           501s
    62226             51510             42.64595           71           143           -           7.39217           -           451           602s
    73487             60922             109.02659         123         143           -           7.53031           -           446           700s
    85578             71336             32.68718           45           122           -           7.69380           -           442           803s
    97249             80625             76.69195           105         143           -           7.83195           -           437           902s
    107226           89903             47.16659           60           210           -           7.92886           -           441           1007s
    118641           98948             35.52609           62           243           -           8.00238           -           436           1106s
    129754           108614           60.25825           95           198           -           8.10735           -           432           1200s
    142395           119387           63.30992           82           133           -           8.18412           -           428           1300s
    153314           127980           20.00406           32           141           -           8.30627           -           427           1402s
    165409           138069           14.33308           23           242           -           8.37944           -           426           1507s
    175966           147354           49.63338           73           119           -           8.44112           -           424           1601s
    187563           156633           13.90212           27           155           -           8.52486           -           423           1704s
    198463           166042           26.33586           41           173           -           8.60042           -           424           1804s
    209480           175007           35.06838           52           92           -           8.63331           -           422           1902s
    222243           185923           25.83243           47           233           -           8.70742           -           420           2002s
    233884           195684           30.40672           47           144           -           8.75580           -           420           2102s
    247020           205909           12.29822           30           200           -           8.85911           -           418           2205s
    257603           214812           44.97391           65           100           -           8.90862           -           418           2303s

    Actually I couldn't find any document or example explaining how to implement MIPstart or VarHintVal in Python API.

    I really appreciate your time and any help.

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Oguz,

    Here is the documentation of the Start attribute and the documentation of the VarHintVal attribute. The documentation of all attributes lists these under Variable attributes. An example of how to set a MIPstart can be found in the facility.py example at line 103.

    You can also write a MST file holding the starting point and provide it to Gurobi via the parameter InputFile. You can also provide a HNT file holding the hint values for all variables and pass it to Gurobi via the InputFile parameter.

    In general, you are trying to solve a non-convex problem with semi-continuous variables which represent a complex class on its own. Thus, it is not surprising that the solution time increases compared to your binary formulation. You could try removing the semi-continuous variables first by simply relaxing them to continuous variables to better locate the source of complexity. The guideline on the most important parameters for MIPs may also catch your interest.

    Best regards,
    Jaromił

    0

Please sign in to leave a comment.