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-2018 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 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  /*******************
69  * Problem Solving *
70  *******************/
71 
72  /* solve problem */
73  SCIPinfoMessage(scip, NULL, "solve problem ...\n\n");
74  SCIP_CALL( SCIPsolve(scip) );
75 
76  SCIPinfoMessage(scip, NULL, "primal solution:\n");
78 
79 
80  /**************
81  * Statistics *
82  **************/
83 
84  SCIPinfoMessage(scip, NULL, "Statistics:\n");
86 
87  return SCIP_OKAY;
88 }
89 
90 /** starts user interactive mode */
91 static
93  SCIP* scip /**< SCIP data structure */
94  )
95 {
97 
98  return SCIP_OKAY;
99 }
100 
101 /** creates a SCIP instance with default plugins, evaluates command line parameters, runs SCIP appropriately,
102  * and frees the SCIP instance
103  */
104 static
106  int argc, /**< number of shell parameters */
107  char** argv /**< array with shell parameters */
108  )
109 {
110  SCIP* scip = NULL;
111 
112  /*********
113  * Setup *
114  *********/
115 
116  /* initialize SCIP */
117  SCIP_CALL( SCIPcreate(&scip) );
118 
119  /* we explicitly enable the use of a debug solution for this main SCIP instance */
120  SCIPenableDebugSol(scip);
121 
122  /***********************
123  * Version information *
124  ***********************/
125 
126  SCIPprintVersion(scip, NULL);
127  SCIPinfoMessage(scip, NULL, "\n");
128 
129 
130  /* include default SCIP plugins */
132 
133  /* include GMI cut separator */
134  SCIP_CALL( SCIPincludeSepaGMI(scip) );
135 
136  /**************
137  * Parameters *
138  **************/
139 
140  if ( argc >= 3 )
141  {
142  SCIP_CALL( readParams(scip, argv[2]) );
143  }
144  else
145  {
146  SCIP_CALL( readParams(scip, NULL) );
147  }
148 
149 
150  /**************
151  * Start SCIP *
152  **************/
153 
154  if ( argc >= 2 )
155  {
156  SCIP_CALL( fromCommandLine(scip, argv[1]) );
157  }
158  else
159  {
160  SCIPinfoMessage(scip, NULL, "\n");
161 
162  SCIP_CALL( interactive(scip) );
163  }
164 
165 
166  /********************
167  * Deinitialization *
168  ********************/
169 
170  SCIP_CALL( SCIPfree(&scip) );
171 
173 
174  return SCIP_OKAY;
175 }
176 
177 /** main method starting SCIP */
178 int main(
179  int argc, /**< number of arguments from the shell */
180  char** argv /**< array of shell arguments */
181  )
182 {
183  SCIP_RETCODE retcode;
184 
185  retcode = runSCIP(argc, argv);
186  if ( retcode != SCIP_OKAY )
187  {
188  SCIPprintError(retcode);
189  return -1;
190  }
191 
192  return 0;
193 }
SCIP_RETCODE SCIPprintBestSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:2445
#define NULL
Definition: def.h:239
#define BMScheckEmptyMemory()
Definition: memory.h:137
#define FALSE
Definition: def.h:65
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
static SCIP_RETCODE runSCIP(int argc, char **argv)
Definition: cmain.c:105
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip_general.c:339
int main(int argc, char **argv)
Definition: cmain.c:102
static SCIP_RETCODE interactive(SCIP *scip)
Definition: cmain.c:92
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:279
SCIP_Bool SCIPfileExists(const char *filename)
Definition: misc.c:10220
static SCIP_RETCODE readParams(SCIP *scip, const char *filename)
Definition: cmain.c:29
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip_solve.c:2577
SCIP_RETCODE SCIPreadProb(SCIP *scip, const char *filename, const char *extension)
Definition: scip_prob.c:382
#define SCIP_CALL(x)
Definition: def.h:351
SCIP_RETCODE SCIPincludeSepaGMI(SCIP *scip)
Definition: sepa_gmi.c:818
SCIP_RETCODE SCIPincludeDefaultPlugins(SCIP *scip)
void SCIPprintVersion(SCIP *scip, FILE *file)
Definition: scip_general.c:202
Gomory Mixed-Integer Cuts.
SCIP_RETCODE SCIPstartInteraction(SCIP *scip)
Definition: scip_dialog.c:313
SCIP_RETCODE SCIPreadParams(SCIP *scip, const char *filename)
Definition: scip_param.c:842
void SCIPprintError(SCIP_RETCODE retcode)
Definition: scip_general.c:267
static SCIP_RETCODE fromCommandLine(SCIP *scip, const char *filename)
Definition: cmain.c:55
default SCIP plugins
SCIP callable library.
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip_general.c:371
void SCIPenableDebugSol(SCIP *scip)
Definition: scip_debug.c:132