CBCSolver.hh 3.38 KB
Newer Older
1
2
// (C) Copyright 2015 by Autodesk, Inc.

3
4
//=============================================================================
//
5
//  CLASS CBCSolver
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
//=============================================================================
#ifndef COMISO_CBCSolver_HH
#define COMISO_CBCSolver_HH

//== COMPILE-TIME PACKAGE REQUIREMENTS ========================================
#include <CoMISo/Config/config.hh>
#if COMISO_CBC_AVAILABLE

//== INCLUDES =================================================================

#include <CoMISo/Config/CoMISoDefines.hh>
#include <vector>
#include <string>
#include "NProblemInterface.hh"
#include "NConstraintInterface.hh"
#include "VariableType.hh"

//== FORWARDDECLARATIONS ======================================================
class GRBModel;
class GRBVar;

//== NAMESPACES ===============================================================

namespace COMISO {

//== CLASS DEFINITION =========================================================

/**
    Solver interface for Coin-or Cbc.

    A more elaborate description follows.
*/
class COMISODLLEXPORT CBCSolver
{
public:
  /// Default constructor
  CBCSolver() {}

  /// Destructor
  ~CBCSolver() {}

  // ********** SOLVE **************** //
  //! \throws Outcome
50
  bool solve(
51
52
53
54
55
56
    NProblemInterface* _problem, // problem instance
    const std::vector<NConstraintInterface*>& _constraints, // linear constraints
    const std::vector<PairIndexVtype>& _discrete_constraints, // discrete constraints
    const double _time_limit = 60); // time limit in seconds

  //! \throws Outcome
57
 bool solve(
58
59
60
61
62
63
64
    NProblemInterface* _problem, // problem instance
    const std::vector<NConstraintInterface*>& _constraints, // linear constraints
    const double _time_limit = 60) // time limit in seconds
  {
    std::vector<PairIndexVtype> dc;
    return solve(_problem, _constraints, dc, _time_limit);
  }
65

66
67
68
69
70
71
72
73
74
75
76
77
78
//  // same as previous but more control over stopping criteria
//  // the optimizer runs in two phases
//  // phase 1) stops if solution with a MIP gap lower than _gap0 is found or _time_limit0 is reached
//  // phase 2) starts only if in phase 1 no solution with a MIP gap lower than _gap1 was found and
//  //          uses _gap1 and _time_limit2 as parameters
//  inline bool solve_two_phase(NProblemInterface*                  _problem,                // problem instance
//                    std::vector<NConstraintInterface*>& _constraints,            // linear constraints
//                    std::vector<PairIndexVtype>&        _discrete_constraints,   // discrete constraints
//                    const double                        _time_limit0 = 60, // time limit phase 1 in seconds
//                    const double                        _gap0 = 0.001,     // MIP gap phase 1
//                    const double                        _time_limit1 = 120, // time limit phase 2 in seconds
//                    const double                        _gap1 = 0.2,        // MIP gap phase 2
//                    const bool                          _silent = false);
79
80
81
82
83
84
85
86
87
88
89
90
};


//=============================================================================
} // namespace COMISO

//=============================================================================
#endif // COMISO_CBC_AVAILABLE
//=============================================================================
#endif // COMISO_CBCSolver_HH
//=============================================================================