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-2022 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 visit scipopt.org. */
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  /** default constructor */
43  SCIP* scip
44  )
45  : ObjHeur(scip, "2opt", "2-Opt heuristic for TSPs", 'K',-1000000, 1, 0, -1, SCIP_HEURTIMING_AFTERNODE, FALSE),
46  graph_(0),
47  ncalls_(0),
48  sol_(NULL),
49  tour_(NULL)
50  {
51  }
52 
53  /** destructor */
54  virtual ~Heur2opt()
55  {
56  } /*lint !e1540*/
57 
58  /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
59  virtual SCIP_DECL_HEURFREE(scip_free);
60 
61  /** initialization method of primal heuristic (called after problem was transformed) */
62  virtual SCIP_DECL_HEURINIT(scip_init);
63 
64  /** deinitialization method of primal heuristic (called before transformed problem is freed) */
65  virtual SCIP_DECL_HEUREXIT(scip_exit);
66 
67  /** solving process initialization method of primal heuristic (called when branch and bound process is about to begin)
68  *
69  * This method is called when the presolving was finished and the branch and bound process is about to begin.
70  * The primal heuristic may use this call to initialize its branch and bound specific data.
71  *
72  */
73  virtual SCIP_DECL_HEURINITSOL(scip_initsol);
74 
75  /** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed)
76  *
77  * This method is called before the branch and bound process is freed.
78  * The primal heuristic should use this call to clean up its branch and bound data.
79  */
80  virtual SCIP_DECL_HEUREXITSOL(scip_exitsol);
81 
82  /** execution method of primal heuristic
83  *
84  * Searches for feasible primal solutions. The method is called in the node processing loop.
85  *
86  * possible return values for *result:
87  * - SCIP_FOUNDSOL : at least one feasible primal solution was found
88  * - SCIP_DIDNOTFIND : the heuristic searched, but did not find a feasible solution
89  * - SCIP_DIDNOTRUN : the heuristic was skipped
90  * - SCIP_DELAYED : the heuristic was skipped, but should be called again as soon as possible, disregarding
91  * its frequency
92  */
93  virtual SCIP_DECL_HEUREXEC(scip_exec);
94 
95  /** clone method which will be used to copy a objective plugin */
96  virtual SCIP_DECL_HEURCLONE(ObjCloneable* clone); /*lint !e665*/
97 
98  /** returns whether the objective plugin is copyable */
99  virtual SCIP_DECL_HEURISCLONEABLE(iscloneable)
100  {
101  return TRUE;
102  }
103 }; /*lint !e1712*/
104 
105 }
106 
107 #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:99
#define FALSE
Definition: def.h:87
virtual SCIP_DECL_HEURINIT(scip_init)
#define TRUE
Definition: def.h:86
#define SCIP_HEURTIMING_AFTERNODE
Definition: type_timing.h:92
virtual ~Heur2opt()
Definition: Heur2opt.h:54
#define NULL
Definition: lpi_spx1.cpp:155
C++ wrapper classes for SCIP.
virtual SCIP_DECL_HEURCLONE(ObjCloneable *clone)
Heur2opt(SCIP *scip)
Definition: Heur2opt.h:42
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)