coin-or / SHOT

A solver for mixed-integer nonlinear optimization problems
https://shotsolver.dev
Eclipse Public License 2.0
117 stars 25 forks source link

segfault in SHOT::MIPSolverCplex::addMIPStart #125

Closed svigerske closed 3 years ago

svigerske commented 3 years ago

With GAMS modellib model gear and current master + changes from #124, I get a deference of a null-pointer inside IloCPLEX from

        cplexInstance.addMIPStart(cplexVars, startVal, IloCplex::MIPStartRepair);

I don't really know where this comes from. cplexVars and startVal seem to be non-null and also cplexInstance.getImpl() isn't null.

╶ Supporting Hyperplane Optimization Toolkit (SHOT) ──────────────────────────────────────────────────────────────────╴

 Andreas Lundell and Jan Kronqvist, Åbo Akademi University, Finland.
 See documentation for full list of contributors and utilized software libraries.

 Version: 1.0.1. Git hash: 2083800b. Released: Jun 30 2021.

 For more information visit https://shotsolver.dev

 Time to extract information on quadratics: 0.033000
 Performing bound tightening on reformulated problem.
  - Bounds for 0 variables tightened in 0.05 s and 1 passes.

╶ Problem instance ───────────────────────────────────────────────────────────────────────────────────────────────────╴

                                    Original             Reformulated

 Problem classification:            MINLP, nonconvex     MINLP, nonconvex

 Objective function direction:      minimize             minimize
 Objective function type:           nonlinear            nonlinear

 Number of constraints:             2                    2
  - linear:                         2                    2

 Number of variables:               4                    4
  - integer:                        4                    4
  - nonlinear:                      4                    4

╶ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────╴

 No options file specified.

 Options specified:

  - Dual.ESH.InteriorPoint.CuttingPlane.IterationLimit = 50
  - Dual.HyperplaneCuts.ConstraintSelectionFactor = 1
  - Dual.HyperplaneCuts.UseIntegerCuts = true
  - Dual.MIP.NumberOfThreads = 1
  - Dual.MIP.Presolve.UpdateObtainedBounds = false
  - Dual.MIP.SolutionLimit.Initial = 2147483647
  - Dual.Relaxation.Use = false
  - Dual.TreeStrategy = 0
  - Model.Variables.Continuous.MaximumUpperBound = 1e+20
  - Model.Variables.Continuous.MinimumLowerBound = -1e+20
  - Primal.FixedInteger.CallStrategy = 0
  - Primal.FixedInteger.OnlyUniqueIntegerCombinations = false
  - Primal.FixedInteger.Solver = 1
  - Primal.FixedInteger.Source = 0
  - Subsolver.Ipopt.LinearSolver = 1
  - Termination.IterationLimit = 2147483647
  - Termination.ObjectiveGap.Absolute = 1e-10
  - Termination.ObjectiveGap.Relative = 1e-05
  - Termination.TimeLimit = 10000000000

 Dual strategy:              Multi-tree
  - cut algorithm:           ESH
  - solver:                  CPLEX 20.1

 Primal NLP solver:          CONOPT (automatically selected) in GAMS 36.0

╶ Main iteration step ────────────────────────────────────────────────────────────────────────────────────────────────╴

    Iteration     │  Time  │  Dual cuts  │     Objective value     │   Objective gap   │     Current solution
     #: type      │  tot.  │   + | tot.  │       dual | primal     │    abs. | rel.    │    obj.fn. | max.err.
╶─────────────────┴────────┴─────────────┴─────────────────────────┴───────────────────┴──────────────────────────────╴

     1: MILP-O       4.11                           0 | 36.1768      3.6e+01 | 1.0e+00            0 | 0                
     1: NLPNEWDB-O   5.60                           0 | 36.1768      3.6e+01 | 1.0e+00      36.1768 | 0                
     2: MILP-O       6.05      2 | 2                0*| 9.10921      9.1e+00 | 1.0e+00            0 | 0                
     3: MILP-O       6.21      2 | 4                0*| 2.31395      2.3e+00 | 1.0e+00            0 | 0                
     4: MILP-O       8.58      2 | 6                0*| 1.00702      1.0e+00 | 1.0e+00            0 | 0                
==1758163== Invalid read of size 8
==1758163==    at 0x5D4E815: IloCplexI::addMIPStart(IloNumVarArray, IloNumArray, IloCplex::MIPStartEffort, char const*) (in /home/stefan/work/gams/build/gms test/libshtcclib64.so)
==1758163==    by 0x58E8920: IloCplex::addMIPStart(IloNumVarArray, IloNumArray, IloCplex::MIPStartEffort, char const*) (ilocplex.h:516)
==1758163==    by 0x58E2354: SHOT::MIPSolverCplex::addMIPStart(std::vector<double, std::allocator<double> >) (MIPSolverCplex.cpp:1275)
==1758163==    by 0x5AF570F: SHOT::TaskPresolve::run() (TaskPresolve.cpp:72)
==1758163==    by 0x5AC2DD2: SHOT::SolutionStrategyMultiTree::solveProblem() (SolutionStrategyMultiTree.cpp:330)
==1758163==    by 0x58786DD: SHOT::Solver::solveProblem() (Solver.cpp:597)
==1758163==    by 0x5983838: shtCallSolver (EntryPointsGAMS.cpp:213)
==1758163==    by 0x5983E90: C__shtCallSolver (EntryPointsGAMS.cpp:270)
==1758163==    by 0x52E03F5: GMSCONF_tgmsconf_DOT_sccallsolver(GMSCONF_tgmsconf_OD_S*, int, void*, void*) (gmsconf.c:2783)
==1758163==    by 0x52D3B61: libsolver(unsigned char*, unsigned char*, unsigned char const*, GMOMDODEFEX_tgmomodel_OD_S**, GEVDOORG_tgmsenvironment_OD_S**) (gevdoorg.c:3068)
==1758163==    by 0x52D5263: GEVDOORG_tgmsenvironment_DOT_gevcallsolver(GEVDOORG_tgmsenvironment_OD_S*, void*, unsigned char const*, unsigned char const*, int, int, unsigned char const*, unsigned char const*, double, int, int, double, double, void**, unsigned char*) (gevdoorg.c:3457)
==1758163==    by 0x52634E7: gevcallsolver (joatdclib.c:5867)
==1758163==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==1758163== 

Do you have some idea what goes wrong?

andreaslundell commented 3 years ago

Hmm... I am not at the computer at the moment. One thing would be if not all of the variables get a value, e.g. something went wrong in the reformulation in SHOT so that the reformulated problem is malformed. I remember something about CPLEX being picky that the MIP start should be complete.

svigerske commented 3 years ago

Yes, cplexVars has more elements than startVal.

I can wait until you are back at a computer. :) I was just testing the current SHOT in anticipation of the next release.

andreaslundell commented 3 years ago

This should be fixed in master now. Can you check @svigerske?

svigerske commented 3 years ago

I took the changes from 7f43837a4c7 and that seems to fix it.

(I had actually tried the same changes with the startVars on my uncessesful attempt, but looks like the change to MIPStartAuto is essential.)