Scippy

SCIP

Solving Constraint Integer Programs

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/scip_mem.h"
#include "scip/scip_message.h"
#include "scip/scip_numerics.h"
#include "scip/scip_prob.h"
#include "scip/scip_reader.h"
#include <string.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   ' '
 

Typedefs

typedef struct TimStage TIMSTAGE
 
typedef enum TimSection TIMSECTION
 
typedef struct TimInput TIMINPUT
 

Enumerations

enum  TimSection {
  TIM_TIME,
  TIM_PERIODS,
  TIM_ENDATA
}
 

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_READER *reader)
 
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_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

◆ READER_DESC

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

Definition at line 39 of file reader_tim.c.

Referenced by SCIPincludeReaderTim().

◆ READER_EXTENSION

#define READER_EXTENSION   "tim"

Definition at line 40 of file reader_tim.c.

Referenced by SCIPincludeReaderTim().

◆ TIM_MAX_LINELEN

#define TIM_MAX_LINELEN   1025

Definition at line 46 of file reader_tim.c.

Referenced by timinputReadLine().

◆ TIM_MAX_NAMELEN

#define TIM_MAX_NAMELEN   256

Definition at line 47 of file reader_tim.c.

Referenced by timinputSetProbname().

◆ TIM_DEFAULT_STAGESIZE

#define TIM_DEFAULT_STAGESIZE   10

Definition at line 48 of file reader_tim.c.

Referenced by timinputCreate().

◆ TIM_DEFAULT_ARRAYSIZE

#define TIM_DEFAULT_ARRAYSIZE   100

Definition at line 49 of file reader_tim.c.

Referenced by createReaderdata().

◆ BLANK

#define BLANK   ' '

Definition at line 51 of file reader_tim.c.

Referenced by clearFrom(), and timinputReadLine().

Typedef Documentation

◆ TIMSTAGE

typedef struct TimStage TIMSTAGE

Definition at line 64 of file reader_tim.c.

◆ TIMSECTION

typedef enum TimSection TIMSECTION

Definition at line 84 of file reader_tim.c.

◆ TIMINPUT

typedef struct TimInput TIMINPUT

Definition at line 105 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 78 of file reader_tim.c.

Function Documentation

◆ addVariableToStage()

static 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 109 of file reader_tim.c.

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

Referenced by createStages().

◆ addConstraintToStage()

static 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 141 of file reader_tim.c.

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

Referenced by createStages().

◆ createStages()

static 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 173 of file reader_tim.c.

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

Referenced by SCIPreadTim().

◆ createReaderdata()

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

creates the reader data for the time input data

Parameters
scipSCIP data structure
readerthe reader structure
timitim input structure

Definition at line 226 of file reader_tim.c.

References TimInput::nstages, NULL, TimStage::nvars, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBlockMemory(), SCIPallocBlockMemoryArray, SCIPblkmem(), SCIPceil(), SCIPduplicateBlockMemoryArray, SCIPgetNVars(), SCIPhashmapCreate(), SCIPreaderGetData(), TimInput::stagenames, TimInput::stagestartcons, TimInput::stagestartvars, TIM_DEFAULT_ARRAYSIZE, and TRUE.

Referenced by readTim().

◆ freeReaderdata()

static void freeReaderdata ( SCIP scip,
SCIP_READER reader 
)
static

free the reader data

Parameters
scipSCIP data structure
readerthe reader structure

Definition at line 285 of file reader_tim.c.

References NULL, SCIPfreeBlockMemory, SCIPfreeBlockMemoryArray, SCIPhashmapFree(), and SCIPreaderGetData().

Referenced by SCIP_DECL_READERFREE().

◆ timinputCreate()

static 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 331 of file reader_tim.c.

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

Referenced by readTim().

◆ timinputFree()

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

free the tim input structure

Parameters
scipSCIP data structure
timitim input structure

Definition at line 364 of file reader_tim.c.

References SCIPfreeBlockMemory, and SCIPfreeBlockMemoryArray.

Referenced by readTim().

◆ timinputSection()

static TIMSECTION timinputSection ( const TIMINPUT timi)
static

returns the current section

Parameters
timitim input structure

Definition at line 387 of file reader_tim.c.

References NULL, and TimInput::section.

Referenced by readTim().

◆ timinputField0()

static const char* timinputField0 ( const TIMINPUT timi)
static

return the current value of field 0

Parameters
timitim input structure

Definition at line 398 of file reader_tim.c.

References TimInput::f0, and NULL.

Referenced by readPeriods(), and readTime().

◆ timinputField1()

static const char* timinputField1 ( const TIMINPUT timi)
static

return the current value of field 1

Parameters
timitim input structure

Definition at line 409 of file reader_tim.c.

References TimInput::f1, and NULL.

Referenced by readPeriods(), and readTime().

◆ timinputField2()

static const char* timinputField2 ( const TIMINPUT timi)
static

return the current value of field 2

Parameters
timitim input structure

Definition at line 420 of file reader_tim.c.

References TimInput::f2, and NULL.

Referenced by readPeriods().

◆ timinputField3()

static const char* timinputField3 ( const TIMINPUT timi)
static

return the current value of field 3

Parameters
timitim input structure

Definition at line 431 of file reader_tim.c.

References TimInput::f3, and NULL.

Referenced by readPeriods().

◆ timinputHasError()

static SCIP_Bool timinputHasError ( const TIMINPUT timi)
static

returns if an error was detected

Parameters
timitim input structure

Definition at line 442 of file reader_tim.c.

References TimInput::haserror, and NULL.

Referenced by readTim().

◆ timinputSetSection()

static 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 453 of file reader_tim.c.

References NULL, and TimInput::section.

Referenced by readPeriods(), and readTime().

◆ timinputSetProbname()

static 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 465 of file reader_tim.c.

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

Referenced by readTime().

◆ timinputSetStageStartVar()

static 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 479 of file reader_tim.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPduplicateBlockMemoryArray, and TimInput::stagestartvars.

Referenced by readPeriods().

◆ timinputSetStageStartCons()

static 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 496 of file reader_tim.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPduplicateBlockMemoryArray, and TimInput::stagestartcons.

Referenced by readPeriods().

◆ timinputSetStageName()

static 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 513 of file reader_tim.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPduplicateBlockMemoryArray, and TimInput::stagenames.

Referenced by readPeriods().

◆ timinputSyntaxerror()

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

Definition at line 529 of file reader_tim.c.

References TimInput::haserror, TimInput::lineno, NULL, SCIPerrorMessage, TimInput::section, TIM_ENDATA, and TRUE.

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

◆ clearFrom()

static 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 542 of file reader_tim.c.

References BLANK.

Referenced by timinputReadLine().

◆ timinputReadLine()

static SCIP_Bool timinputReadLine ( TIMINPUT timi)
static

read a tim format data line and parse the fields.

Parameters
timitim input structure

Definition at line 556 of file reader_tim.c.

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

Referenced by readPeriods(), and readTime().

◆ readTime()

static SCIP_RETCODE readTime ( SCIP scip,
TIMINPUT timi 
)
static

Process TIME section.

Parameters
scipSCIP data structure
timitim input structure

Definition at line 646 of file reader_tim.c.

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

Referenced by readTim().

◆ readPeriods()

◆ readTim()

static 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 728 of file reader_tim.c.

References createReaderdata(), TimInput::fp, NULL, readPeriods(), 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 SCIPreadTim().

◆ SCIP_DECL_READERCOPY()

static SCIP_DECL_READERCOPY ( readerCopyTim  )
static

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

Definition at line 787 of file reader_tim.c.

References NULL, READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPincludeReaderTim(), and SCIPreaderGetName().

◆ SCIP_DECL_READERFREE()

static SCIP_DECL_READERFREE ( readerFreeTim  )
static

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

Definition at line 801 of file reader_tim.c.

References freeReaderdata(), and SCIP_OKAY.

◆ SCIP_DECL_READERREAD()

static SCIP_DECL_READERREAD ( readerReadTim  )
static

reads the stage information for a stochastic programming instance in SMPS format

Definition at line 810 of file reader_tim.c.

References NULL, READER_NAME, SCIP_CALL, SCIP_DIDNOTRUN, SCIP_OKAY, SCIPcorHasRead(), SCIPfindReader(), SCIPreaderGetName(), SCIPreadTim(), and SCIPwarningMessage().

◆ SCIPtimHasRead()

SCIP_Bool SCIPtimHasRead ( SCIP_READER reader)
Parameters
readerthe file reader itself

Definition at line 912 of file reader_tim.c.

References NULL, READER_NAME, SCIPreaderGetData(), and SCIPreaderGetName().

Referenced by SCIP_DECL_READERREAD().

◆ SCIPtimGetNStages()

int SCIPtimGetNStages ( SCIP scip)

◆ SCIPtimGetStageName()

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

Definition at line 948 of file reader_tim.c.

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

Referenced by buildScenarioTree(), and createReaderdata().

◆ SCIPtimConsGetStageName()

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

Definition at line 969 of file reader_tim.c.

References TimInput::nstages, NULL, READER_NAME, SCIPconsGetName(), SCIPfindReader(), SCIPreaderGetData(), and SCIPreaderGetName().

Referenced by readIndep().

◆ SCIPtimFindStage()

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

Definition at line 1010 of file reader_tim.c.

References NULL, READER_NAME, SCIPABORT, SCIPerrorMessage, SCIPfindReader(), SCIPreaderGetData(), and SCIPreaderGetName().

Referenced by addScenarioVarsAndConsToProb(), and readScenarios().

◆ SCIPtimGetStageVars()

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

Definition at line 1048 of file reader_tim.c.

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

Referenced by addScenarioVarsAndConsToProb(), and removeCoreVariablesAndConstraints().

◆ SCIPtimGetStageConss()

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

Definition at line 1069 of file reader_tim.c.

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

Referenced by addScenarioVarsAndConsToProb(), and removeCoreVariablesAndConstraints().

◆ SCIPtimGetStageNVars()

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

Definition at line 1090 of file reader_tim.c.

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

Referenced by addScenarioVarsAndConsToProb(), and removeCoreVariablesAndConstraints().

◆ SCIPtimGetStageNConss()

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

Definition at line 1111 of file reader_tim.c.

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

Referenced by addScenarioVarsAndConsToProb(), and removeCoreVariablesAndConstraints().