reader_scflp.c
Go to the documentation of this file.
20 * This file implements the reader/parser used to read the CAP input data and builds a SCFLP instance. For more details
25 * In the <code>data</code> directory you find a few data files which contain each one CAP problem. These data
31 * - The next set of lines states the transportation cost from each facility to the customer. Each line contains 7
34 * For parsing that data, we implemented a reader plugin for \SCIP. A reader has several callback methods and at least
35 * one interface methods (the one including the reader into \SCIP). For our purpose we only implemented the \ref
40 * The interface method <code>SCIPincludeReaderScflp()</code> is called to add the reader plugin to \SCIP (see
41 * cmain.c). This means \SCIP gets informed that this reader is available for reading input files. Therefore, the
42 * function <code>SCIPincludeReader()</code> is called within this method which passes all necessary information of the
43 * reader to SCIP. This information includes the name of the reader, a description, and the file extension for which the
44 * file reader is in charge. In our case we selected the file extension "cap". This means that all files which have
46 * <code>SCIPincludeReader()</code> also passes for each callback of the reader a function pointers
48 * pointers are used by \SCIP to run the reader. For more information about all available reader callbacks we refer to
50 * we restrict ourself to the callback <code>READERREAD</code> which is the only one we implemented for the SCFLP
55 * The READERREAD callback is in charge of parsing a file and creating the problem. To see the list of arguments this
56 * functions gets see the file type_reader.h in the source of \SCIP. The following arguments are of interest in our
57 * case. First of all the \SCIP pointer, the file name, and the SCIP_RESULT pointer. The \SCIP pointer gives us the
58 * current environment. The file name states the file which we should open and parse. Last but not least, the SCIP_RESULT
60 * not. Note that in type_reader.h you also find a list of allowable result values for the SCIP_RESULT pointer and the
63 * In the READERREAD callback, the scenarios for the stochastic program are generated. A scenario represents a different
64 * realisation of demand for each customer. The scenarios are generated by sampling demands from a normal distribution
65 * with a mean given by the deterministic demand and the standard deviation sampled from a uniform distribution with the
70 * The file can be opened and parsed with your favorite methods. In this case we are using the functionality provided by
71 * \SCIP since this has some nice side effects. We are using the function SCIPfopen() which can besides standard
72 * 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
73 * in the source of SCIP. Parsing the data out of the file is not that hard. Please look at the code and comments
78 * After parsing the file the final task for the reader is to create the problem. In our case, we pass the collected data
79 * to the \ref probdata_scflp.h "main problem data plugin". For this, we use the interface methods
81 * problem data plugin (see probdata_scflp.c). After that, the reader sets the result value for the SCIP_RESULT
85 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
282 SCIPwarningMessage(scip, "invalid input line %d in file <%s>: <%s>\n", lineno, filename, buffer);
286 SCIPdebugMsg(scip, "number of facilities = <%d> number of customers = <%d>\n", nfacilities, ncustomers);
315 SCIPwarningMessage(scip, "invalid input line %d in file <%s>: <%s>\n", lineno, filename, buffer);
320 SCIPdebugMsg(scip, "facility %d capacity = <%f>, fixed cost = <%f>\n", facility, facilitycap, facilitycost);
332 /* TODO: convert the 2D arrays into contiguous arrays. This has benefits from a memory management point of view. */
364 SCIPwarningMessage(scip, "invalid input line %d in file <%s>: <%s>\n", lineno, filename, buffer);
376 nread = sscanf(buffer, " %lf %lf %lf %lf %lf %lf %lf\n", &tmpcosts[0], &tmpcosts[1], &tmpcosts[2],
381 SCIPwarningMessage(scip, "invalid input line %d in file <%s>: <%s>\n", lineno, filename, buffer);
420 demands[i][j] = SCIPround(scip, generateGaussianNoise(randomgen, mean, stdDev, &spare, &hasspare));
427 SCIP_CALL( SCIPprobdataCreate(scip, name, costs, demands, capacity, fixedcost, ncustomers, nfacilities,
479 SCIP_CALL( SCIPincludeReaderBasic(scip, &reader, READER_NAME, READER_DESC, READER_EXTENSION, readerdata) );
486 "reading/" READER_NAME "/usebenders", "Should Benders' decomposition be used to solve the problem?",
Definition: type_result.h:33
Definition: struct_reader.h:36
void SCIPfreeRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen)
Definition: scip_randnumgen.c:70
Definition: struct_scip.h:59
SCIP_EXPORT SCIP_READERDATA * SCIPreaderGetData(SCIP_READER *reader)
Definition: reader.c:483
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:123
Definition: type_result.h:49
SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
Definition: scip_reader.c:186
SCIP_Real SCIPrandomGetReal(SCIP_RANDNUMGEN *randnumgen, SCIP_Real minrandval, SCIP_Real maxrandval)
Definition: misc.c:9967
static SCIP_Real generateGaussianNoise(SCIP_RANDNUMGEN *randomgen, SCIP_Real mean, SCIP_Real stdDev, SCIP_Real *spare, SCIP_Bool *hasspare)
Definition: reader_scflp.c:125
Definition: struct_misc.h:259
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:48
Definition: type_retcode.h:38
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:1387
SCIP_RETCODE SCIPcreateRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen, unsigned int initialseed, SCIP_Bool useglobalseed)
Definition: scip_randnumgen.c:47
Definition: type_retcode.h:36
SCFLP problem reader file reader.
SCIP_RETCODE SCIPsetReaderFree(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERFREE((*readerfree)))
Definition: scip_reader.c:162
Definition: type_retcode.h:33
Problem data for Stochastic Capacitated Facility Location problem.
static SCIP_RETCODE readerdataFree(SCIP *scip, SCIP_READERDATA **readerdata)
Definition: reader_scflp.c:177
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
Definition: scip_reader.c:100
static SCIP_RETCODE readerdataCreate(SCIP *scip, SCIP_READERDATA **readerdata)
Definition: reader_scflp.c:161
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:74
Definition: objbenders.h:33