Scippy

SCIP

Solving Constraint Integer Programs

ProbDataTSP.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-2019 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 scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file ProbDataTSP.h
17  * @brief C++ problem data for TSP
18  * @author Timo Berthold
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #ifndef __TSPPROBDATA_H__
24 #define __TSPPROBDATA_H__
25 
26 #include "objscip/objscip.h"
27 #include "GomoryHuTree.h"
28 
29 namespace tsp
30 {
31 
32 /** SCIP user problem data for TSP */
34 {
35  GRAPH* graph_; /**< graph data */
36 
37 public:
38 
39  /** default constructor */
41  GRAPH* g /**< graph data */
42  )
43  : graph_(g)
44  {
45  capture_graph(graph_);
46  }
47 
48  /** destructor */
49  virtual ~ProbDataTSP()
50  {
51  if( graph_ != NULL )
52  release_graph(&graph_); /*lint !e1551*/
53  }
54 
55  /** Copies user data if you want to copy it to a subscip */
56  virtual SCIP_RETCODE scip_copy(
57  SCIP* scip, /**< SCIP data structure */
58  SCIP* sourcescip, /**< source SCIP main data structure */
59  SCIP_HASHMAP* varmap, /**< a hashmap which stores the mapping of source variables to
60  * corresponding target variables */
61  SCIP_HASHMAP* consmap, /**< a hashmap which stores the mapping of source contraints to
62  * corresponding target constraints */
63  ObjProbData** objprobdata, /**< pointer to store the copied problem data object */
64  SCIP_Bool global, /**< create a global or a local copy? */
65  SCIP_RESULT* result /**< pointer to store the result of the call */
66  );
67 
68  /** destructor of user problem data to free original user data (called when original problem is freed)
69  *
70  * If the "deleteobject" flag in the SCIPcreateObjProb() method was set to TRUE, this method is not needed,
71  * because all the work to delete the user problem data can be done in the destructor of the user problem
72  * data object. If the "deleteobject" flag was set to FALSE, and the user problem data object stays alive
73  * after the SCIP problem is freed, this method should delete all the problem specific data that is no
74  * longer needed.
75  */
76  virtual SCIP_RETCODE scip_delorig(
77  SCIP* scip /**< SCIP data structure */
78  );
79 
80  /** destructor of user problem data to free transformed user data (called when transformed problem is freed)
81  *
82  * If the "*deleteobject" flag in the scip_trans() method was set to TRUE, this method is not needed,
83  * because all the work to delete the user problem data can be done in the destructor of the user problem
84  * data object. If the "*deleteobject" flag was set to FALSE, and the user problem data object stays alive
85  * after the SCIP problem is freed, this method should delete all the problem specific data that is no
86  * longer needed.
87  */
89  SCIP* scip /**< SCIP data structure */
90  );
91 
92  /** creates user data of transformed problem by transforming the original user problem data
93  * (called after problem was transformed)
94  *
95  * The user has two possibilities to implement this method:
96  * 1. Return the pointer to the original problem data object (this) as pointer to the transformed problem data
97  * object. The user may modify some internal attributes, but he has to make sure, that these modifications are
98  * reversed in the scip_deltrans() method, such that the original problem data is restored. In this case,
99  * he should set *deleteobject to FALSE, because the problem data must not be destructed by SCIP after the
100  * solving process is terminated.
101  * 2. Call the copy constructor of the problem data object and return the created copy as transformed problem
102  * data object. In this case, he probably wants to set *deleteobject to TRUE, thus letting SCIP call the
103  * destructor of the object if the transformed problem data is no longer needed.
104  */
105  virtual SCIP_RETCODE scip_trans(
106  SCIP* scip, /**< SCIP data structure */
107  ObjProbData** objprobdata, /**< pointer to store the transformed problem data object */
108  SCIP_Bool* deleteobject /**< pointer to store whether SCIP should delete the object after solving */
109  );
110 
112  {
113  return graph_;
114  }
115 
116 };/*lint !e1712*/
117 
118 } /* namespace tsp */
119 
120 #endif
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
#define NULL
Definition: def.h:246
Definition: grph.h:57
virtual SCIP_RETCODE scip_copy(SCIP *scip, SCIP *sourcescip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, ObjProbData **objprobdata, SCIP_Bool global, SCIP_RESULT *result)
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
generator for global cuts in undirected graphs
virtual SCIP_RETCODE scip_delorig(SCIP *scip)
C++ wrapper for user problem data.
Definition: objprobdata.h:43
C++ wrapper classes for SCIP.
GRAPH * getGraph()
Definition: ProbDataTSP.h:111
virtual SCIP_RETCODE scip_trans(SCIP *scip, ObjProbData **objprobdata, SCIP_Bool *deleteobject)
#define SCIP_Bool
Definition: def.h:69
virtual SCIP_RETCODE scip_deltrans(SCIP *scip)
ProbDataTSP(GRAPH *g)
Definition: ProbDataTSP.h:40
virtual ~ProbDataTSP()
Definition: ProbDataTSP.h:49
void capture_graph(GRAPH *gr)
void release_graph(GRAPH **gr)