SCIP Doxygen Documentation
Loading...
Searching...
No Matches

Detailed Description

TIM file reader - the stage information for a stochastic programming instance in SMPS format.

Author
Stephen J. Maher

Definition in file reader_tim.c.

#include "scip/pub_cons.h"
#include "scip/pub_fileio.h"
#include "scip/pub_message.h"
#include "scip/pub_misc.h"
#include "scip/pub_reader.h"
#include "scip/reader_cor.h"
#include "scip/reader_tim.h"
#include "scip/reader_sto.h"
#include "scip/scip_mem.h"
#include "scip/scip_message.h"
#include "scip/scip_numerics.h"
#include "scip/scip_prob.h"
#include "scip/scip_reader.h"

Go to the source code of this file.

Data Structures

struct  TimStage
struct  TimInput

Macros

#define READER_NAME   "timreader"
#define READER_DESC   "file reader for the TIME file of a stochastic program in SMPS format"
#define READER_EXTENSION   "tim"
#define TIM_MAX_LINELEN   1025
#define TIM_MAX_NAMELEN   256
#define TIM_DEFAULT_STAGESIZE   10
#define TIM_DEFAULT_ARRAYSIZE   100
#define BLANK   ' '

Functions

static SCIP_RETCODE addVariableToStage (SCIP *scip, TIMSTAGE *stage, const char *varname)
static SCIP_RETCODE addConstraintToStage (SCIP *scip, TIMSTAGE *stage, const char *consname)
static SCIP_RETCODE createStages (SCIP *scip, SCIP_READER *reader, SCIP_READER *correader)
static SCIP_RETCODE createReaderdata (SCIP *scip, SCIP_READER *reader, TIMINPUT *timi)
static void freeReaderdata (SCIP *scip, SCIP_READERDATA *readerdata)
static SCIP_RETCODE timinputCreate (SCIP *scip, TIMINPUT **timi, SCIP_FILE *fp)
static void timinputFree (SCIP *scip, TIMINPUT **timi)
static TIMSECTION timinputSection (const TIMINPUT *timi)
static const char * timinputField0 (const TIMINPUT *timi)
static const char * timinputField1 (const TIMINPUT *timi)
static const char * timinputField2 (const TIMINPUT *timi)
static const char * timinputField3 (const TIMINPUT *timi)
static SCIP_Bool timinputHasError (const TIMINPUT *timi)
static void timinputSetSection (TIMINPUT *timi, TIMSECTION section)
static void timinputSetProbname (TIMINPUT *timi, const char *probname)
static SCIP_RETCODE timinputSetStageStartVar (TIMINPUT *timi, SCIP *scip, const char *varname, int stagenum)
static SCIP_RETCODE timinputSetStageStartCons (TIMINPUT *timi, SCIP *scip, const char *consname, int stagenum)
static SCIP_RETCODE timinputSetStageName (TIMINPUT *timi, SCIP *scip, const char *stagename, int stagenum)
static void timinputSyntaxerror (TIMINPUT *timi)
static void clearFrom (char *buf, unsigned int pos)
static SCIP_Bool timinputReadLine (TIMINPUT *timi)
static SCIP_RETCODE readTime (SCIP *scip, TIMINPUT *timi)
static SCIP_RETCODE readPeriods (TIMINPUT *timi, SCIP *scip)
static SCIP_RETCODE readTim (SCIP *scip, SCIP_READER *reader, const char *filename)
static SCIP_DECL_READERCOPY (readerCopyTim)
static SCIP_DECL_READERFREE (readerFreeTim)
static SCIP_DECL_READERREAD (readerReadTim)
SCIP_RETCODE SCIPincludeReaderTim (SCIP *scip)
SCIP_RETCODE SCIPreadTim (SCIP *scip, const char *filename, SCIP_RESULT *result)
SCIP_RETCODE SCIPfreeReaderdataTim (SCIP *scip)
SCIP_Bool SCIPtimHasRead (SCIP_READER *reader)
int SCIPtimGetNStages (SCIP *scip)
const char * SCIPtimGetStageName (SCIP *scip, int stagenum)
const char * SCIPtimConsGetStageName (SCIP *scip, const char *consname)
int SCIPtimFindStage (SCIP *scip, const char *stage)
SCIP_VAR ** SCIPtimGetStageVars (SCIP *scip, int stagenum)
SCIP_CONS ** SCIPtimGetStageConss (SCIP *scip, int stagenum)
int SCIPtimGetStageNVars (SCIP *scip, int stagenum)
int SCIPtimGetStageNConss (SCIP *scip, int stagenum)

Macro Definition Documentation

◆ READER_NAME

#define READER_NAME   "timreader"

Definition at line 48 of file reader_tim.c.

◆ READER_DESC

#define READER_DESC   "file reader for the TIME file of a stochastic program in SMPS format"

Definition at line 49 of file reader_tim.c.

◆ READER_EXTENSION

#define READER_EXTENSION   "tim"

Definition at line 50 of file reader_tim.c.

◆ TIM_MAX_LINELEN

#define TIM_MAX_LINELEN   1025

Definition at line 56 of file reader_tim.c.

Referenced by timinputReadLine().

◆ TIM_MAX_NAMELEN

#define TIM_MAX_NAMELEN   256

Definition at line 57 of file reader_tim.c.

Referenced by timinputSetProbname().

◆ TIM_DEFAULT_STAGESIZE

#define TIM_DEFAULT_STAGESIZE   10

Definition at line 58 of file reader_tim.c.

Referenced by timinputCreate().

◆ TIM_DEFAULT_ARRAYSIZE

#define TIM_DEFAULT_ARRAYSIZE   100

Definition at line 59 of file reader_tim.c.

Referenced by createReaderdata().

◆ BLANK

#define BLANK   ' '

Definition at line 61 of file reader_tim.c.

Typedef Documentation

◆ TIMSTAGE

typedef struct TimStage TIMSTAGE

Definition at line 74 of file reader_tim.c.

◆ TIMSECTION

typedef enum TimSection TIMSECTION

Definition at line 94 of file reader_tim.c.

◆ TIMINPUT

typedef struct TimInput TIMINPUT

Definition at line 115 of file reader_tim.c.

Enumeration Type Documentation

◆ TimSection

enum TimSection

enum containing all tim sections

Enumerator
TIM_TIME 
TIM_PERIODS 
TIM_ENDATA 

Definition at line 88 of file reader_tim.c.

Function Documentation

◆ addVariableToStage()

SCIP_RETCODE addVariableToStage ( SCIP * scip,
TIMSTAGE * stage,
const char * varname )
static

adds the variable to the given stage

Parameters
scipSCIP data structure
stagethe stage structure
varnamethe name of the variable to add to the stage

Definition at line 119 of file reader_tim.c.

References addVariableToStage(), assert(), NULL, TimStage::nvars, SCIP_CALL, SCIP_OKAY, SCIPensureBlockMemoryArray, SCIPfindVar(), SCIPhashmapInsert(), SCIPwarningMessage(), var, TimStage::varnametovar, TimStage::vars, and TimStage::varssize.

Referenced by addVariableToStage(), and createStages().

◆ addConstraintToStage()

SCIP_RETCODE addConstraintToStage ( SCIP * scip,
TIMSTAGE * stage,
const char * consname )
static

adds the constraint to the given stage

Parameters
scipSCIP data structure
stagethe stage structure
consnamethe name of the constraint to add to the stage

Definition at line 151 of file reader_tim.c.

References addConstraintToStage(), assert(), TimStage::consnametocons, TimStage::conss, TimStage::conssize, TimStage::nconss, NULL, SCIP_CALL, SCIP_OKAY, SCIPensureBlockMemoryArray, SCIPfindCons(), SCIPhashmapInsert(), and SCIPwarningMessage().

Referenced by addConstraintToStage(), and createStages().

◆ createStages()

SCIP_RETCODE createStages ( SCIP * scip,
SCIP_READER * reader,
SCIP_READER * correader )
static

creates the stage data

Parameters
scipSCIP data structure
readerthe reader structure
correaderthe reader structure for the core file

Definition at line 183 of file reader_tim.c.

References addConstraintToStage(), addVariableToStage(), assert(), createStages(), i, TimInput::nstages, NULL, SCIP_CALL, SCIP_OKAY, SCIPcorGetConsName(), SCIPcorGetNConsNames(), SCIPcorGetNVarNames(), SCIPcorGetVarName(), and SCIPreaderGetData().

Referenced by createStages(), and SCIPreadTim().

◆ createReaderdata()

SCIP_RETCODE createReaderdata ( SCIP * scip,
SCIP_READER * reader,
TIMINPUT * timi )
static

◆ freeReaderdata()

void freeReaderdata ( SCIP * scip,
SCIP_READERDATA * readerdata )
static

free the reader data

Parameters
scipSCIP data structure
readerdatathe reader data structure

Definition at line 295 of file reader_tim.c.

References assert(), FALSE, freeReaderdata(), i, NULL, SCIPfreeBlockMemory, SCIPfreeBlockMemoryArray, and SCIPhashmapFree().

◆ timinputCreate()

SCIP_RETCODE timinputCreate ( SCIP * scip,
TIMINPUT ** timi,
SCIP_FILE * fp )
static

creates the tim input structure

Parameters
scipSCIP data structure
timitim input structure
fpfile object for the input file

Definition at line 336 of file reader_tim.c.

References assert(), FALSE, TimInput::fp, NULL, SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemory, SCIPallocBlockMemoryArray, TIM_DEFAULT_STAGESIZE, TIM_TIME, and timinputCreate().

Referenced by readTim(), and timinputCreate().

◆ timinputFree()

void timinputFree ( SCIP * scip,
TIMINPUT ** timi )
static

free the tim input structure

Parameters
scipSCIP data structure
timitim input structure

Definition at line 369 of file reader_tim.c.

References i, SCIPfreeBlockMemory, SCIPfreeBlockMemoryArray, and timinputFree().

Referenced by readTim(), and timinputFree().

◆ timinputSection()

TIMSECTION timinputSection ( const TIMINPUT * timi)
static

returns the current section

Parameters
timitim input structure

Definition at line 392 of file reader_tim.c.

References assert(), NULL, TimInput::section, and timinputSection().

Referenced by readTim(), and timinputSection().

◆ timinputField0()

const char * timinputField0 ( const TIMINPUT * timi)
static

return the current value of field 0

Parameters
timitim input structure

Definition at line 403 of file reader_tim.c.

References assert(), TimInput::f0, NULL, and timinputField0().

Referenced by readPeriods(), readTime(), and timinputField0().

◆ timinputField1()

const char * timinputField1 ( const TIMINPUT * timi)
static

return the current value of field 1

Parameters
timitim input structure

Definition at line 414 of file reader_tim.c.

References assert(), TimInput::f1, NULL, and timinputField1().

Referenced by readPeriods(), readTime(), and timinputField1().

◆ timinputField2()

const char * timinputField2 ( const TIMINPUT * timi)
static

return the current value of field 2

Parameters
timitim input structure

Definition at line 425 of file reader_tim.c.

References assert(), TimInput::f2, NULL, and timinputField2().

Referenced by readPeriods(), and timinputField2().

◆ timinputField3()

const char * timinputField3 ( const TIMINPUT * timi)
static

return the current value of field 3

Parameters
timitim input structure

Definition at line 436 of file reader_tim.c.

References assert(), TimInput::f3, NULL, and timinputField3().

Referenced by readPeriods(), and timinputField3().

◆ timinputHasError()

SCIP_Bool timinputHasError ( const TIMINPUT * timi)
static

returns if an error was detected

Parameters
timitim input structure

Definition at line 447 of file reader_tim.c.

References assert(), TimInput::haserror, NULL, SCIP_Bool, and timinputHasError().

Referenced by readTim(), and timinputHasError().

◆ timinputSetSection()

void timinputSetSection ( TIMINPUT * timi,
TIMSECTION section )
static

set the section in the tim input structure to given section

Parameters
timitim input structure
sectionsection that is set

Definition at line 458 of file reader_tim.c.

References assert(), NULL, TimInput::section, and timinputSetSection().

Referenced by readPeriods(), readTime(), and timinputSetSection().

◆ timinputSetProbname()

void timinputSetProbname ( TIMINPUT * timi,
const char * probname )
static

set the problem name in the tim input structure to given problem name

Parameters
timitim input structure
probnamename of the problem to set

Definition at line 470 of file reader_tim.c.

References assert(), NULL, TimInput::probname, SCIPmemccpy(), TIM_MAX_NAMELEN, and timinputSetProbname().

Referenced by readTime(), and timinputSetProbname().

◆ timinputSetStageStartVar()

SCIP_RETCODE timinputSetStageStartVar ( TIMINPUT * timi,
SCIP * scip,
const char * varname,
int stagenum )
static

set the problem var name that starts a stage in the tim input structure to given objective name

Parameters
timitim input structure
scipSCIP data structure
varnamename of the variable that starts the stage
stagenumthe stage number the variable starts

Definition at line 484 of file reader_tim.c.

References assert(), NULL, SCIP_CALL, SCIP_OKAY, SCIPduplicateBlockMemoryArray, TimInput::stagestartvars, and timinputSetStageStartVar().

Referenced by readPeriods(), and timinputSetStageStartVar().

◆ timinputSetStageStartCons()

SCIP_RETCODE timinputSetStageStartCons ( TIMINPUT * timi,
SCIP * scip,
const char * consname,
int stagenum )
static

set the problem constraint name that starts a stage in the tim input structure to given objective name

Parameters
timitim input structure
scipSCIP data structure
consnamename of the constraint that starts the stage
stagenumthe stage number the constraint starts

Definition at line 501 of file reader_tim.c.

References assert(), NULL, SCIP_CALL, SCIP_OKAY, SCIPduplicateBlockMemoryArray, TimInput::stagestartcons, and timinputSetStageStartCons().

Referenced by readPeriods(), and timinputSetStageStartCons().

◆ timinputSetStageName()

SCIP_RETCODE timinputSetStageName ( TIMINPUT * timi,
SCIP * scip,
const char * stagename,
int stagenum )
static

set the stage name in the tim input structure to given objective name

Parameters
timitim input structure
scipSCIP data structure
stagenamename of the stage
stagenumthe stage number the constraint starts

Definition at line 518 of file reader_tim.c.

References assert(), NULL, SCIP_CALL, SCIP_OKAY, SCIPduplicateBlockMemoryArray, TimInput::stagenames, and timinputSetStageName().

Referenced by readPeriods(), and timinputSetStageName().

◆ timinputSyntaxerror()

void timinputSyntaxerror ( TIMINPUT * timi)
static
Parameters
timitim input structure

Definition at line 534 of file reader_tim.c.

References assert(), TimInput::haserror, TimInput::lineno, NULL, SCIPerrorMessage, TimInput::section, TIM_ENDATA, timinputSyntaxerror(), and TRUE.

Referenced by readPeriods(), readTim(), readTime(), and timinputSyntaxerror().

◆ clearFrom()

void clearFrom ( char * buf,
unsigned int pos )
static

fill the line from pos up to column 80 with blanks.

Parameters
bufbuffer to clear
posposition to start the clearing process

Definition at line 547 of file reader_tim.c.

References BLANK, TimInput::buf, clearFrom(), and i.

◆ timinputReadLine()

SCIP_Bool timinputReadLine ( TIMINPUT * timi)
static

read a tim format data line and parse the fields.

Parameters
timitim input structure

Definition at line 561 of file reader_tim.c.

References assert(), BLANK, TimInput::buf, clearFrom(), TimInput::f0, TimInput::f1, TimInput::f2, TimInput::f3, FALSE, TimInput::fp, i, TimInput::lineno, NULL, SCIP_Bool, SCIPdebugMessage, SCIPfgets(), SCIPstrtok(), TIM_MAX_LINELEN, timinputReadLine(), and TRUE.

Referenced by readPeriods(), readTime(), and timinputReadLine().

◆ readTime()

SCIP_RETCODE readTime ( SCIP * scip,
TIMINPUT * timi )
static

Process TIME section.

Parameters
scipSCIP data structure
timitim input structure

Definition at line 651 of file reader_tim.c.

References NULL, readTime(), SCIP_OKAY, SCIPdebugMsg, TIM_PERIODS, timinputField0(), timinputField1(), timinputReadLine(), timinputSetProbname(), timinputSetSection(), and timinputSyntaxerror().

Referenced by readTim(), and readTime().

◆ readPeriods()

◆ readTim()

SCIP_RETCODE readTim ( SCIP * scip,
SCIP_READER * reader,
const char * filename )
static

Read time data for the SMPS file format.

Parameters
scipSCIP data structure
readerthe file reader itself
filenamename of the input file

Definition at line 733 of file reader_tim.c.

References assert(), createReaderdata(), TimInput::fp, NULL, readPeriods(), readTim(), readTime(), SCIP_Bool, SCIP_CALL_FINALLY, SCIP_CALL_TERMINATE, SCIP_NOFILE, SCIP_OKAY, SCIP_READERROR, SCIPerrorMessage, SCIPfclose(), SCIPfopen(), SCIPprintSysError(), TIM_ENDATA, TIM_PERIODS, timinputCreate(), timinputFree(), timinputHasError(), timinputSection(), timinputSyntaxerror(), and TRUE.

Referenced by readTim(), and SCIPreadTim().

◆ SCIP_DECL_READERCOPY()

SCIP_DECL_READERCOPY ( readerCopyTim )
static

copy method for reader plugins (called when SCIP copies plugins)

Definition at line 791 of file reader_tim.c.

References assert(), NULL, READER_NAME, SCIP_CALL, SCIP_DECL_READERCOPY, SCIP_INVALIDCALL, SCIP_OKAY, SCIP_STRINGEQ, SCIPincludeReaderTim(), and SCIPreaderGetName().

◆ SCIP_DECL_READERFREE()

SCIP_DECL_READERFREE ( readerFreeTim )
static

destructor of reader to free user data (called when SCIP is exiting)

Definition at line 806 of file reader_tim.c.

References assert(), freeReaderdata(), NULL, SCIP_DECL_READERFREE, SCIP_OKAY, SCIPfreeBlockMemory, and SCIPreaderGetData().

◆ SCIP_DECL_READERREAD()

SCIP_DECL_READERREAD ( readerReadTim )
static

◆ SCIPfreeReaderdataTim()

SCIP_RETCODE SCIPfreeReaderdataTim ( SCIP * scip)

frees the reader data for the tim file

Parameters
scipthe SCIP data structure

Definition at line 934 of file reader_tim.c.

References assert(), freeReaderdata(), NULL, READER_NAME, SCIP_OKAY, SCIPfindReader(), SCIPfreeReaderdataTim(), and SCIPreaderGetData().

Referenced by SCIP_DECL_READERREAD(), SCIPfreeReaderdataTim(), and SCIPreadCor().

◆ SCIPtimHasRead()

SCIP_Bool SCIPtimHasRead ( SCIP_READER * reader)
Parameters
readerthe file reader itself

Definition at line 960 of file reader_tim.c.

References assert(), FALSE, NULL, READER_NAME, SCIP_Bool, SCIP_STRINGEQ, SCIPreaderGetData(), SCIPreaderGetName(), and SCIPtimHasRead().

Referenced by SCIP_DECL_READERREAD(), and SCIPtimHasRead().

◆ SCIPtimGetNStages()

◆ SCIPtimGetStageName()

const char * SCIPtimGetStageName ( SCIP * scip,
int stagenum )
Parameters
scipSCIP data structure
stagenumthe number of the requested stage

Definition at line 998 of file reader_tim.c.

References assert(), TimInput::nstages, NULL, READER_NAME, SCIP_STRINGEQ, SCIPfindReader(), SCIPreaderGetData(), SCIPreaderGetName(), and SCIPtimGetStageName().

Referenced by buildScenarioTree(), createReaderdata(), and SCIPtimGetStageName().

◆ SCIPtimConsGetStageName()

const char * SCIPtimConsGetStageName ( SCIP * scip,
const char * consname )
Parameters
scipSCIP data structure
consnamethe constraint to search for

Definition at line 1020 of file reader_tim.c.

References assert(), i, TimInput::nstages, NULL, READER_NAME, SCIP_STRINGEQ, SCIPconsGetName(), SCIPfindReader(), SCIPreaderGetData(), SCIPreaderGetName(), and SCIPtimConsGetStageName().

Referenced by readIndep(), and SCIPtimConsGetStageName().

◆ SCIPtimFindStage()

int SCIPtimFindStage ( SCIP * scip,
const char * stage )
Parameters
scipSCIP data structure
stagethe name of the requested stage

Definition at line 1062 of file reader_tim.c.

References assert(), i, NULL, READER_NAME, SCIP_STRINGEQ, SCIPABORT, SCIPerrorMessage, SCIPfindReader(), SCIPreaderGetData(), SCIPreaderGetName(), and SCIPtimFindStage().

Referenced by addScenarioVarsAndConsToProb(), readScenarios(), and SCIPtimFindStage().

◆ SCIPtimGetStageVars()

SCIP_VAR ** SCIPtimGetStageVars ( SCIP * scip,
int stagenum )
Parameters
scipSCIP data structure
stagenumthe number of the requested stage

Definition at line 1101 of file reader_tim.c.

References assert(), TimInput::nstages, NULL, READER_NAME, SCIP_STRINGEQ, SCIPfindReader(), SCIPreaderGetData(), SCIPreaderGetName(), and SCIPtimGetStageVars().

Referenced by addScenarioVarsAndConsToProb(), removeCoreVariablesAndConstraints(), and SCIPtimGetStageVars().

◆ SCIPtimGetStageConss()

SCIP_CONS ** SCIPtimGetStageConss ( SCIP * scip,
int stagenum )
Parameters
scipSCIP data structure
stagenumthe number of the requested stage

Definition at line 1123 of file reader_tim.c.

References assert(), TimInput::nstages, NULL, READER_NAME, SCIP_STRINGEQ, SCIPfindReader(), SCIPreaderGetData(), SCIPreaderGetName(), and SCIPtimGetStageConss().

Referenced by addScenarioVarsAndConsToProb(), removeCoreVariablesAndConstraints(), and SCIPtimGetStageConss().

◆ SCIPtimGetStageNVars()

int SCIPtimGetStageNVars ( SCIP * scip,
int stagenum )
Parameters
scipSCIP data structure
stagenumthe number of the requested stage

Definition at line 1145 of file reader_tim.c.

References assert(), TimInput::nstages, NULL, READER_NAME, SCIP_STRINGEQ, SCIPfindReader(), SCIPreaderGetData(), SCIPreaderGetName(), and SCIPtimGetStageNVars().

Referenced by addScenarioVarsAndConsToProb(), removeCoreVariablesAndConstraints(), and SCIPtimGetStageNVars().

◆ SCIPtimGetStageNConss()

int SCIPtimGetStageNConss ( SCIP * scip,
int stagenum )
Parameters
scipSCIP data structure
stagenumthe number of the requested stage

Definition at line 1167 of file reader_tim.c.

References assert(), TimInput::nstages, NULL, READER_NAME, SCIP_STRINGEQ, SCIPfindReader(), SCIPreaderGetData(), SCIPreaderGetName(), and SCIPtimGetStageNConss().

Referenced by addScenarioVarsAndConsToProb(), removeCoreVariablesAndConstraints(), and SCIPtimGetStageNConss().