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