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-2023 Zuse Institute Berlin (ZIB) */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 
25 /**@file Heur2opt.h
26  * @brief 2-Optimum - combinatorial improvement heuristic for TSP
27  * @author Timo Berthold
28  */
29 
30 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
31 
32 #ifndef __HEUR2OPT_H__
33 #define __HEUR2OPT_H__
34 
35 #include "objscip/objscip.h"
36 
37 namespace tsp
38 {
39 
40 /** C++ wrapper */
41 class Heur2opt : public scip::ObjHeur
42 {
43  GRAPH* graph_; /**< the underlying graph of the TSP */
44  int ncalls_; /**< number of calls of the heuristic since the last solution was found */
45  SCIP_SOL* sol_; /**< current solution */
46  GRAPHEDGE** tour_; /**< tour induced by sol */
47 
48 public:
49 
50  /** default constructor */
52  SCIP* scip
53  )
54  : ObjHeur(scip, "2opt", "2-Opt heuristic for TSPs", 'K',-1000000, 1, 0, -1, SCIP_HEURTIMING_AFTERNODE, FALSE),
55  graph_(0),
56  ncalls_(0),
57  sol_(NULL),
58  tour_(NULL)
59  {
60  }
61 
62  /** destructor */
63  virtual ~Heur2opt()
64  {
65  } /*lint !e1540*/
66 
67  /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
68  virtual SCIP_DECL_HEURFREE(scip_free);
69 
70  /** initialization method of primal heuristic (called after problem was transformed) */
71  virtual SCIP_DECL_HEURINIT(scip_init);
72 
73  /** deinitialization method of primal heuristic (called before transformed problem is freed) */
74  virtual SCIP_DECL_HEUREXIT(scip_exit);
75 
76  /** solving process initialization method of primal heuristic (called when branch and bound process is about to begin)
77  *
78  * This method is called when the presolving was finished and the branch and bound process is about to begin.
79  * The primal heuristic may use this call to initialize its branch and bound specific data.
80  *
81  */
82  virtual SCIP_DECL_HEURINITSOL(scip_initsol);
83 
84  /** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed)
85  *
86  * This method is called before the branch and bound process is freed.
87  * The primal heuristic should use this call to clean up its branch and bound data.
88  */
89  virtual SCIP_DECL_HEUREXITSOL(scip_exitsol);
90 
91  /** execution method of primal heuristic
92  *
93  * Searches for feasible primal solutions. The method is called in the node processing loop.
94  *
95  * possible return values for *result:
96  * - SCIP_FOUNDSOL : at least one feasible primal solution was found
97  * - SCIP_DIDNOTFIND : the heuristic searched, but did not find a feasible solution
98  * - SCIP_DIDNOTRUN : the heuristic was skipped
99  * - SCIP_DELAYED : the heuristic was skipped, but should be called again as soon as possible, disregarding
100  * its frequency
101  */
102  virtual SCIP_DECL_HEUREXEC(scip_exec);
103 
104  /** clone method which will be used to copy a objective plugin */
105  virtual SCIP_DECL_HEURCLONE(ObjCloneable* clone); /*lint !e665*/
106 
107  /** returns whether the objective plugin is copyable */
108  virtual SCIP_DECL_HEURISCLONEABLE(iscloneable)
109  {
110  return TRUE;
111  }
112 }; /*lint !e1712*/
113 
114 }
115 
116 #endif
virtual SCIP_DECL_HEUREXEC(scip_exec)
virtual SCIP_DECL_HEUREXIT(scip_exit)
C++ wrapper for primal heuristics.
Definition: objheur.h:53
virtual SCIP_DECL_HEURISCLONEABLE(iscloneable)
Definition: Heur2opt.h:108
#define FALSE
Definition: def.h:96
virtual SCIP_DECL_HEURINIT(scip_init)
#define TRUE
Definition: def.h:95
#define SCIP_HEURTIMING_AFTERNODE
Definition: type_timing.h:101
virtual ~Heur2opt()
Definition: Heur2opt.h:63
#define NULL
Definition: lpi_spx1.cpp:164
C++ wrapper classes for SCIP.
virtual SCIP_DECL_HEURCLONE(ObjCloneable *clone)
Heur2opt(SCIP *scip)
Definition: Heur2opt.h:51
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:89
virtual SCIP_DECL_HEURINITSOL(scip_initsol)