Scippy

SCIP

Solving Constraint Integer Programs

cmain.c
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 GMI/src/cmain.c
17  * @brief main file for GMI cut example
18  * @author Marc Pfetsch
19  */
20 
21 /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #include <scip/scip.h>
24 #include <scip/scipdefplugins.h>
25 #include "sepa_gmi.h"
26 
27 /** reads parameters */
28 static
30  SCIP* scip, /**< SCIP data structure */
31  const char* filename /**< parameter file name, or NULL */
32  )
33 {
34  if ( filename != NULL )
35  {
36  if ( SCIPfileExists(filename) )
37  {
38  SCIPinfoMessage(scip, NULL, "reading parameter file <%s> ...\n", filename);
39  SCIP_CALL( SCIPreadParams(scip, filename) );
40  }
41  else
42  SCIPinfoMessage(scip, NULL, "parameter file <%s> not found - using default parameters.\n", filename);
43  }
44  else if ( SCIPfileExists("scipgmi.set") )
45  {
46  SCIPinfoMessage(scip, NULL, "reading parameter file <scipgmi.set> ...\n");
47  SCIP_CALL( SCIPreadParams(scip, "scipgmi.set") );
48  }
49 
50  return SCIP_OKAY;
51 }
52 
53 /** starts SCIP */
54 static
56  SCIP* scip, /**< SCIP data structure */
57  const char* filename /**< input file name */
58  )
59 {
60  /********************
61  * Problem Creation *
62  ********************/
63 
64  SCIPinfoMessage(scip, NULL, "read problem <%s> ...\n\n", filename);
65  SCIP_CALL( SCIPreadProb(scip, filename, NULL) );
66 
67  /*******************
68  * Problem Solving *
69  *******************/
70 
71  /* solve problem */
72  SCIPinfoMessage(scip, NULL, "solve problem ...\n\n");
73  SCIP_CALL( SCIPsolve(scip) );
74 
75  SCIPinfoMessage(scip, NULL, "primal solution:\n");
77 
78  /**************
79  * Statistics *
80  **************/
81 
82  SCIPinfoMessage(scip, NULL, "Statistics:\n");
84 
85  return SCIP_OKAY;
86 }
87 
88 /** starts user interactive mode */
89 static
91  SCIP* scip /**< SCIP data structure */
92  )
93 {
95 
96  return SCIP_OKAY;
97 }
98 
99 /** creates a SCIP instance with default plugins, evaluates command line parameters, runs SCIP appropriately,
100  * and frees the SCIP instance
101  */
102 static
104  int argc, /**< number of shell parameters */
105  char** argv /**< array with shell parameters */
106  )
107 {
108  SCIP* scip = NULL;
109 
110  /*********
111  * Setup *
112  *********/
113 
114  /* initialize SCIP */
115  SCIP_CALL( SCIPcreate(&scip) );
116 
117  /* we explicitly enable the use of a debug solution for this main SCIP instance */
118  SCIPenableDebugSol(scip);
119 
120  /***********************
121  * Version information *
122  ***********************/
123 
124  SCIPprintVersion(scip, NULL);
125  SCIPinfoMessage(scip, NULL, "\n");
126 
127  /* include default SCIP plugins */
129 
130  /* include GMI cut separator */
131  SCIP_CALL( SCIPincludeSepaGMI(scip) );
132 
133  /**************
134  * Parameters *
135  **************/
136 
137  if ( argc >= 3 )
138  {
139  SCIP_CALL( readParams(scip, argv[2]) );
140  }
141  else
142  {
143  SCIP_CALL( readParams(scip, NULL) );
144  }
145 
146  /**************
147  * Start SCIP *
148  **************/
149 
150  if ( argc >= 2 )
151  {
152  SCIP_CALL( fromCommandLine(scip, argv[1]) );
153  }
154  else
155  {
156  SCIPinfoMessage(scip, NULL, "\n");
157 
158  SCIP_CALL( interactive(scip) );
159  }
160 
161  /********************
162  * Deinitialization *
163  ********************/
164 
165  SCIP_CALL( SCIPfree(&scip) );
166 
168 
169  return SCIP_OKAY;
170 }
171 
172 /** main method starting SCIP */
173 int main(
174  int argc, /**< number of arguments from the shell */
175  char** argv /**< array of shell arguments */
176  )
177 {
178  SCIP_RETCODE retcode;
179 
180  retcode = runSCIP(argc, argv);
181  if ( retcode != SCIP_OKAY )
182  {
183  SCIPprintError(retcode);
184  return -1;
185  }
186 
187  return 0;
188 }
void SCIPprintError(SCIP_RETCODE retcode)
Definition: scip_general.c:211
#define BMScheckEmptyMemory()
Definition: memory.h:147
SCIP_Bool SCIPfileExists(const char *filename)
Definition: misc.c:10807
#define FALSE
Definition: def.h:73
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip_solve.c:2555
static SCIP_RETCODE runSCIP(int argc, char **argv)
Definition: cmain.c:103
int main(int argc, char **argv)
Definition: cmain.c:102
static SCIP_RETCODE interactive(SCIP *scip)
Definition: cmain.c:90
SCIP_RETCODE SCIPprintBestSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:2371
static SCIP_RETCODE readParams(SCIP *scip, const char *filename)
Definition: cmain.c:29
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip_general.c:283
SCIP_RETCODE SCIPreadProb(SCIP *scip, const char *filename, const char *extension)
Definition: scip_prob.c:329
void SCIPenableDebugSol(SCIP *scip)
Definition: scip_debug.c:48
#define NULL
Definition: lpi_spx1.cpp:155
void SCIPprintVersion(SCIP *scip, FILE *file)
Definition: scip_general.c:146
#define SCIP_CALL(x)
Definition: def.h:370
SCIP_RETCODE SCIPincludeSepaGMI(SCIP *scip)
Definition: sepa_gmi.c:817
SCIP_RETCODE SCIPincludeDefaultPlugins(SCIP *scip)
Gomory Mixed-Integer Cuts.
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
SCIP_RETCODE SCIPreadParams(SCIP *scip, const char *filename)
Definition: scip_param.c:767
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip_general.c:315
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:199
static SCIP_RETCODE fromCommandLine(SCIP *scip, const char *filename)
Definition: cmain.c:55
default SCIP plugins
SCIP_RETCODE SCIPstartInteraction(SCIP *scip)
Definition: scip_dialog.c:233
SCIP callable library.