Scippy

SCIP

Solving Constraint Integer Programs

Heur2opt.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2017 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License. */
12 /* along with SCIP; see the file COPYING. If not email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file Heur2opt.h
17  * @brief 2-Optimum - combinatorial improvement heuristic for TSP
18  * @author Timo Berthold
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #ifndef __HEUR2OPT_H__
24 #define __HEUR2OPT_H__
25 
26 #include "objscip/objscip.h"
27 
28 namespace tsp
29 {
30 
31 /** C++ wrapper */
32 class Heur2opt : public scip::ObjHeur
33 {
34  GRAPH* graph_; /**< the underlying graph of the TSP */
35  int ncalls_; /**< number of calls of the heuristic since the last solution was found */
36  SCIP_SOL* sol_; /**< current solution */
37  GRAPHEDGE** tour_; /**< tour induced by sol */
38 
39 public:
40 
41 
42  /** default constructor */
44  SCIP* scip
45  )
46  : ObjHeur(scip, "2opt", "2-Opt heuristic for TSPs", 'K',-1000000, 1, 0, -1, SCIP_HEURTIMING_AFTERNODE, FALSE),
47  graph_(0),
48  ncalls_(0),
49  sol_(NULL),
50  tour_(NULL)
51  {
52  }
53 
54 
55  /** destructor */
56  virtual ~Heur2opt()
57  {
58  } /*lint !e1540*/
59 
60  /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
61  virtual SCIP_DECL_HEURFREE(scip_free);
62 
63  /** initialization method of primal heuristic (called after problem was transformed) */
64  virtual SCIP_DECL_HEURINIT(scip_init);
65 
66  /** deinitialization method of primal heuristic (called before transformed problem is freed) */
67  virtual SCIP_DECL_HEUREXIT(scip_exit);
68 
69  /** solving process initialization method of primal heuristic (called when branch and bound process is about to begin)
70  *
71  * This method is called when the presolving was finished and the branch and bound process is about to begin.
72  * The primal heuristic may use this call to initialize its branch and bound specific data.
73  *
74  */
75  virtual SCIP_DECL_HEURINITSOL(scip_initsol);
76 
77  /** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed)
78  *
79  * This method is called before the branch and bound process is freed.
80  * The primal heuristic should use this call to clean up its branch and bound data.
81  */
82  virtual SCIP_DECL_HEUREXITSOL(scip_exitsol);
83 
84  /** execution method of primal heuristic
85  *
86  * Searches for feasible primal solutions. The method is called in the node processing loop.
87  *
88  * possible return values for *result:
89  * - SCIP_FOUNDSOL : at least one feasible primal solution was found
90  * - SCIP_DIDNOTFIND : the heuristic searched, but did not find a feasible solution
91  * - SCIP_DIDNOTRUN : the heuristic was skipped
92  * - SCIP_DELAYED : the heuristic was skipped, but should be called again as soon as possible, disregarding
93  * its frequency
94  */
95  virtual SCIP_DECL_HEUREXEC(scip_exec);
96 
97  /** clone method which will be used to copy a objective plugin */
98  virtual SCIP_DECL_HEURCLONE(ObjCloneable* clone); /*lint !e665*/
99 
100  /** returns whether the objective plugin is copyable */
101  virtual SCIP_DECL_HEURISCLONEABLE(iscloneable)
102  {
103  return true;
104  }
105 }; /*lint !e1712*/
106 
107 }
108 
109 #endif
virtual SCIP_DECL_HEUREXEC(scip_exec)
virtual SCIP_DECL_HEUREXIT(scip_exit)
C++ wrapper for primal heuristics.
Definition: objheur.h:43
virtual SCIP_DECL_HEURISCLONEABLE(iscloneable)
Definition: Heur2opt.h:101
#define FALSE
Definition: def.h:64
virtual SCIP_DECL_HEURINIT(scip_init)
#define SCIP_HEURTIMING_AFTERNODE
Definition: type_timing.h:92
virtual ~Heur2opt()
Definition: Heur2opt.h:56
C++ wrapper classes for SCIP.
virtual SCIP_DECL_HEURCLONE(ObjCloneable *clone)
Heur2opt(SCIP *scip)
Definition: Heur2opt.h:43
virtual SCIP_DECL_HEUREXITSOL(scip_exitsol)
virtual SCIP_DECL_HEURFREE(scip_free)
ObjHeur(SCIP *scip, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, SCIP_HEURTIMING timingmask, SCIP_Bool usessubscip)
Definition: objheur.h:79
virtual SCIP_DECL_HEURINITSOL(scip_initsol)