Scippy

SCIP

Solving Constraint Integer Programs

cppmain.cpp
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-2021 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 examples/TSP/src/cppmain.cpp
17  * @brief main file for C++ TSP example using SCIP as a callable library
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  *
21  * This is an example of using SCIP to solve the TSP problem on undirected graphs. See the doxygen documentation for an
22  * explanation.
23  */
24 
25 /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
26 
27 #include <iostream>
28 
29 /* include SCIP components */
30 #include "objscip/objscip.h"
32 
33 /* include TSP specific components */
34 #include "ReaderTSP.h"
35 #include "ConshdlrSubtour.h"
36 #include "HeurFarthestInsert.h"
37 #include "Heur2opt.h"
38 #include "HeurFrats.h"
39 #include "EventhdlrNewSol.h"
40 
41 using namespace scip;
42 using namespace tsp;
43 using namespace std;
44 
45 /** creates and runs a SCIP instance with default and TSP plugins */
46 static
48  int argc, /**< number of arguments from the shell */
49  char** argv /**< array of shell arguments */
50  )
51 {
52  SCIP* scip = NULL;
53 
54 
55  /*********
56  * Setup *
57  *********/
58 
59  /* initialize SCIP */
60  SCIP_CALL( SCIPcreate(&scip) );
61 
62  /* we explicitly enable the use of a debug solution for this main SCIP instance */
63  SCIPenableDebugSol(scip);
64 
65  /* include TSP specific plugins */
66  SCIP_CALL( SCIPincludeObjReader(scip, new ReaderTSP(scip), TRUE) );
70  SCIP_CALL( SCIPincludeObjHeur(scip, new Heur2opt(scip), TRUE) );
71  SCIP_CALL( SCIPincludeObjHeur(scip, new HeurFrats(scip), TRUE) );
72 
73  /* include default SCIP plugins */
75 
76 
77  /**********************************
78  * Process command line arguments *
79  **********************************/
80 
81  SCIP_CALL( SCIPprocessShellArguments(scip, argc, argv, "sciptsp.set") );
82 
83 
84  /********************
85  * Deinitialization *
86  ********************/
87 
88  SCIP_CALL( SCIPfree(&scip) );
89 
91 
92  return SCIP_OKAY;
93 }
94 
95 /** main method starting TSP code */
96 int main(
97  int argc, /**< number of arguments from the shell */
98  char** argv /**< array of shell arguments */
99  )
100 {
101  SCIP_RETCODE retcode;
102 
103  retcode = runSCIP(argc, argv);
104  if( retcode != SCIP_OKAY )
105  {
106  SCIPprintError(retcode);
107  return -1;
108  }
109 
110  return 0;
111 }
void SCIPprintError(SCIP_RETCODE retcode)
Definition: scip_general.c:211
#define BMScheckEmptyMemory()
Definition: memory.h:147
SCIP_RETCODE SCIPincludeObjEventhdlr(SCIP *scip, scip::ObjEventhdlr *objeventhdlr, SCIP_Bool deleteobject)
2-Optimum - combinatorial improvement heuristic for TSP
#define TRUE
Definition: def.h:72
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
farthest insert - combinatorial heuristic for TSP
SCIP_RETCODE SCIPincludeObjHeur(SCIP *scip, scip::ObjHeur *objheur, SCIP_Bool deleteobject)
Definition: objheur.cpp:195
C++ wrapper for default SCIP plugins.
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip_general.c:283
SCIP_RETCODE SCIPincludeObjConshdlr(SCIP *scip, scip::ObjConshdlr *objconshdlr, SCIP_Bool deleteobject)
Definition: pqueue.h:28
void SCIPenableDebugSol(SCIP *scip)
Definition: scip_debug.c:48
#define NULL
Definition: lpi_spx1.cpp:155
C++ wrapper classes for SCIP.
#define SCIP_CALL(x)
Definition: def.h:370
event handler for new solutions in TSP
SCIP_RETCODE SCIPincludeDefaultPlugins(SCIP *scip)
C++ constraint handler for TSP subtour elimination constraints.
SCIP_RETCODE SCIPincludeObjReader(SCIP *scip, scip::ObjReader *objreader, SCIP_Bool deleteobject)
Definition: objreader.cpp:146
SCIP_RETCODE SCIPprocessShellArguments(SCIP *scip, int argc, char **argv, const char *defaultsetname)
Definition: scipshell.c:148
fractional travelling salesman heuristic - Rounding heuristic for TSP
C++ file reader for TSP data files.
int main(int argc, char **argv)
Definition: cppmain.cpp:29
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip_general.c:315
static SCIP_RETCODE runSCIP(int argc, char **argv)
Definition: cppmain.cpp:47