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-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"
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
50using namespace scip;
51using namespace tsp;
52using namespace std;
53
54/** creates and runs a SCIP instance with default and TSP plugins */
55static
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 */
70
71 /* we explicitly enable the use of a debug solution for this main SCIP instance */
73
74 /* include TSP specific plugins */
81
82 /* include default SCIP plugins */
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
98
100
101 return SCIP_OKAY;
102}
103
104/** main method starting TSP code */
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}
C++ constraint handler for TSP subtour elimination constraints.
event handler for new solutions in TSP
2-Optimum - combinatorial improvement heuristic for TSP
farthest insert - combinatorial heuristic for TSP
fractional travelling salesman heuristic - Rounding heuristic for TSP
C++ file reader for TSP data files.
#define NULL
Definition: def.h:267
#define TRUE
Definition: def.h:93
#define SCIP_CALL(x)
Definition: def.h:374
static SCIP_RETCODE runSCIP(int argc, char **argv)
Definition: cppmain.cpp:56
void SCIPenableDebugSol(SCIP *scip)
Definition: scip_debug.c:57
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip_general.c:339
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip_general.c:307
void SCIPprintError(SCIP_RETCODE retcode)
Definition: scip_general.c:221
#define BMScheckEmptyMemory()
Definition: memory.h:155
Definition: pqueue.h:38
SCIP_RETCODE SCIPincludeObjConshdlr(SCIP *scip, scip::ObjConshdlr *objconshdlr, SCIP_Bool deleteobject)
SCIP_RETCODE SCIPincludeObjEventhdlr(SCIP *scip, scip::ObjEventhdlr *objeventhdlr, SCIP_Bool deleteobject)
SCIP_RETCODE SCIPincludeObjHeur(SCIP *scip, scip::ObjHeur *objheur, SCIP_Bool deleteobject)
Definition: objheur.cpp:204
SCIP_RETCODE SCIPincludeObjReader(SCIP *scip, scip::ObjReader *objreader, SCIP_Bool deleteobject)
Definition: objreader.cpp:155
C++ wrapper classes for SCIP.
C++ wrapper for default SCIP plugins.
SCIP_RETCODE SCIPincludeDefaultPlugins(SCIP *scip)
SCIP_RETCODE SCIPprocessShellArguments(SCIP *scip, int argc, char **argv, const char *defaultsetname)
Definition: scipshell.c:273
int main(int argc, char **argv)
Definition: cppmain.cpp:38
@ SCIP_OKAY
Definition: type_retcode.h:42
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63