reader_scflp.c
Go to the documentation of this file.
29 * This file implements the reader/parser used to read the CAP input data and builds a SCFLP instance. For more details
34 * In the <code>data</code> directory you find a few data files which contain each one CAP problem. These data
40 * - The next set of lines states the transportation cost from each facility to the customer. Each line contains 7
43 * For parsing that data, we implemented a reader plugin for \SCIP. A reader has several callback methods and at least
44 * one interface methods (the one including the reader into \SCIP). For our purpose we only implemented the \ref
49 * The interface method <code>SCIPincludeReaderScflp()</code> is called to add the reader plugin to \SCIP (see
50 * cmain.c). This means \SCIP gets informed that this reader is available for reading input files. Therefore, the
51 * function <code>SCIPincludeReader()</code> is called within this method which passes all necessary information of the
52 * reader to SCIP. This information includes the name of the reader, a description, and the file extension for which the
53 * file reader is in charge. In our case we selected the file extension "cap". This means that all files which have
55 * <code>SCIPincludeReader()</code> also passes for each callback of the reader a function pointers
57 * pointers are used by \SCIP to run the reader. For more information about all available reader callbacks we refer to
59 * we restrict ourself to the callback <code>READERREAD</code> which is the only one we implemented for the SCFLP
64 * The READERREAD callback is in charge of parsing a file and creating the problem. To see the list of arguments this
65 * functions gets see the file type_reader.h in the source of \SCIP. The following arguments are of interest in our
66 * case. First of all the \SCIP pointer, the file name, and the SCIP_RESULT pointer. The \SCIP pointer gives us the
67 * current environment. The file name states the file which we should open and parse. Last but not least, the SCIP_RESULT
69 * not. Note that in type_reader.h you also find a list of allowable result values for the SCIP_RESULT pointer and the
72 * In the READERREAD callback, the scenarios for the stochastic program are generated. A scenario represents a different
73 * realisation of demand for each customer. The scenarios are generated by sampling demands from a normal distribution
74 * with a mean given by the deterministic demand and the standard deviation sampled from a uniform distribution with the
79 * The file can be opened and parsed with your favorite methods. In this case we are using the functionality provided by
80 * \SCIP since this has some nice side effects. We are using the function SCIPfopen() which can besides standard
81 * files also handle files which are packed. To find all files related to the parsing of a file, we refer to the file pub_misc.h
82 * in the source of SCIP. Parsing the data out of the file is not that hard. Please look at the code and comments
87 * After parsing the file the final task for the reader is to create the problem. In our case, we pass the collected data
88 * to the \ref probdata_scflp.h "main problem data plugin". For this, we use the interface methods
90 * problem data plugin (see probdata_scflp.c). After that, the reader sets the result value for the SCIP_RESULT
94 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
291 SCIPwarningMessage(scip, "invalid input line %d in file <%s>: <%s>\n", lineno, filename, buffer);
295 SCIPdebugMsg(scip, "number of facilities = <%d> number of customers = <%d>\n", nfacilities, ncustomers);
324 SCIPwarningMessage(scip, "invalid input line %d in file <%s>: <%s>\n", lineno, filename, buffer);
329 SCIPdebugMsg(scip, "facility %d capacity = <%f>, fixed cost = <%f>\n", facility, facilitycap, facilitycost);
341 /* TODO: convert the 2D arrays into contiguous arrays. This has benefits from a memory management point of view. */
373 SCIPwarningMessage(scip, "invalid input line %d in file <%s>: <%s>\n", lineno, filename, buffer);
385 nread = sscanf(buffer, " %lf %lf %lf %lf %lf %lf %lf\n", &tmpcosts[0], &tmpcosts[1], &tmpcosts[2],
390 SCIPwarningMessage(scip, "invalid input line %d in file <%s>: <%s>\n", lineno, filename, buffer);
429 demands[i][j] = SCIPround(scip, generateGaussianNoise(randomgen, mean, stdDev, &spare, &hasspare));
436 SCIP_CALL( SCIPprobdataCreate(scip, name, costs, demands, capacity, fixedcost, ncustomers, nfacilities,
488 SCIP_CALL( SCIPincludeReaderBasic(scip, &reader, READER_NAME, READER_DESC, READER_EXTENSION, readerdata) );
495 "reading/" READER_NAME "/usebenders", "Should Benders' decomposition be used to solve the problem?",
void SCIPfreeRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen)
Definition: scip_randnumgen.c:79
Definition: type_result.h:42
Definition: struct_reader.h:45
Definition: struct_scip.h:69
Definition: type_result.h:58
static SCIP_Real generateGaussianNoise(SCIP_RANDNUMGEN *randomgen, SCIP_Real mean, SCIP_Real stdDev, SCIP_Real *spare, SCIP_Bool *hasspare)
Definition: reader_scflp.c:134
Definition: struct_misc.h:268
Definition: type_retcode.h:47
SCIP_RETCODE SCIPprobdataCreate(SCIP *scip, const char *probname, int *demands, SCIP_Real *rints, SCIP_Real *rexts, int ntypes, SCIP_Real width, SCIP_Real height)
Definition: probdata_rpa.c:1396
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:120
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:83
Definition: type_retcode.h:45
SCFLP problem reader file reader.
Definition: type_retcode.h:42
Problem data for Stochastic Capacitated Facility Location problem.
SCIP_RETCODE SCIPcreateRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen, unsigned int initialseed, SCIP_Bool useglobalseed)
Definition: scip_randnumgen.c:56
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
Definition: scip_reader.c:109
static SCIP_RETCODE readerdataFree(SCIP *scip, SCIP_READERDATA **readerdata)
Definition: reader_scflp.c:186
static SCIP_RETCODE readerdataCreate(SCIP *scip, SCIP_READERDATA **readerdata)
Definition: reader_scflp.c:170
SCIP_Real SCIPrandomGetReal(SCIP_RANDNUMGEN *randnumgen, SCIP_Real minrandval, SCIP_Real maxrandval)
Definition: misc.c:10130
SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
Definition: scip_reader.c:195
Definition: objbenders.h:43
SCIP_RETCODE SCIPsetReaderFree(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERFREE((*readerfree)))
Definition: scip_reader.c:171
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:57