SCIP

Solving Constraint Integer Programs

reader_sto.c File Reference

Detailed Description

STO file reader - the stochastic information of an instance in SMPS format.

Author
Stephen J. Maher

Definition in file reader_sto.c.

#include "blockmemshell/memory.h"
#include "scip/benders_default.h"
#include "scip/cons_linear.h"
#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/pub_var.h"
#include "scip/reader_cor.h"
#include "scip/reader_sto.h"
#include "scip/reader_tim.h"
#include "scip/scip_cons.h"
#include "scip/scip_debug.h"
#include "scip/scipdefplugins.h"
#include "scip/scip_general.h"
#include "scip/scip_mem.h"
#include "scip/scip_message.h"
#include "scip/scip_numerics.h"
#include "scip/scip_param.h"
#include "scip/scip_prob.h"
#include "scip/scip_reader.h"
#include "scip/scip_var.h"
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  StoScenario
 
struct  StoInput
 

Macros

#define READER_NAME   "storeader"
 
#define READER_DESC   "file reader for stochastic information of stochastic programs in the SMPS file format"
 
#define READER_EXTENSION   "sto"
 
#define DEFAULT_USEBENDERS   FALSE
 
#define STO_MAX_LINELEN   1024
 
#define STO_MAX_NAMELEN   256
 
#define STO_DEFAULT_ARRAYSIZE   100
 
#define STO_DEFAULT_ENTRIESSIZE   20
 
#define STO_DEFAULT_BLOCKARRAYSIZE   5
 
#define STO_DEFAULT_CHILDRENSIZE   5
 
#define BLANK   ' '
 

Typedefs

typedef struct StoScenario STOSCENARIO
 
typedef enum StoSection STOSECTION
 
typedef enum StoStochInfo STOSTOCHINFO
 
typedef struct StoInput STOINPUT
 

Enumerations

enum  StoSection {
  STO_STOCH,
  STO_SCENARIOS,
  STO_BLOCKS,
  STO_INDEP,
  STO_ENDATA
}
 
enum  StoStochInfo {
  STO_STOCHINFO_NONE = -1,
  STO_STOCHINFO_DISCRETE = 0,
  STO_STOCHINFO_UNIFORM = 1,
  STO_STOCHINFO_NORMAL = 2,
  STO_STOCHINFO_SUB = 3,
  STO_STOCHINFO_LINTR = 4
}
 

Functions

static SCIP_RETCODE createScenarioData (SCIP *scip, STOSCENARIO **scenariodata)
 
static SCIP_RETCODE freeScenarioTree (SCIP *scip, STOSCENARIO **scenariotree)
 
static void setScenarioScip (STOSCENARIO *scenario, SCIP *scip)
 
static SCIP * getScenarioScip (STOSCENARIO *scenario)
 
static SCIP_RETCODE createScenarioSubproblemArray (SCIP *scip, STOSCENARIO *scenario)
 
static void addScenarioSubproblem (STOSCENARIO *scenario, SCIP *subproblem)
 
static SCIP ** getScenarioSubproblemArray (STOSCENARIO *scenario)
 
static int getScenarioNChildren (STOSCENARIO *scenario)
 
static STOSCENARIO * getScenarioChild (STOSCENARIO *scenario, int childnum)
 
static STOSCENARIO * getScenarioParent (STOSCENARIO *scenario)
 
static SCIP_RETCODE setScenarioStageName (SCIP *scip, STOSCENARIO *scenario, const char *stagename)
 
static const char * getScenarioStageName (SCIP *scip, STOSCENARIO *scenario)
 
static SCIP_RETCODE setScenarioStageNum (SCIP *scip, STOSCENARIO *scenario, int stagenum)
 
static int getScenarioStageNum (SCIP *scip, STOSCENARIO *scenario)
 
static SCIP_RETCODE setScenarioName (SCIP *scip, STOSCENARIO *scenario, const char *name)
 
static const char * getScenarioName (STOSCENARIO *scenario)
 
static SCIP_RETCODE setScenarioNum (SCIP *scip, STOSCENARIO *scenario, int scenarionum)
 
static int getScenarioNum (SCIP *scip, STOSCENARIO *scenario)
 
static SCIP_RETCODE setScenarioProbability (SCIP *scip, STOSCENARIO *scenario, SCIP_Real probability)
 
static SCIP_Real getScenarioProbability (SCIP *scip, STOSCENARIO *scenario)
 
static SCIP_RETCODE addScenarioEntry (SCIP *scip, STOSCENARIO *scenario, const char *rowname, const char *colname, SCIP_Real value)
 
static int getScenarioNEntries (STOSCENARIO *scenario)
 
static const char * getScenarioEntryRow (STOSCENARIO *scenario, int entry)
 
static const char * getScenarioEntryCol (STOSCENARIO *scenario, int entry)
 
static SCIP_Real getScenarioEntryValue (STOSCENARIO *scenario, int entry)
 
static SCIP_RETCODE copyScenario (SCIP *scip, STOSCENARIO *sourcescenario, STOSCENARIO **targetscenario, SCIP_Bool copyname)
 
static SCIP_RETCODE mergeScenarios (SCIP *scip, STOSCENARIO *scenario1, STOSCENARIO **mergedscenario)
 
static SCIP_RETCODE scenarioAddChild (SCIP *scip, STOSCENARIO **parent, STOSCENARIO *child)
 
static SCIP_RETCODE buildScenarioTree (SCIP *scip, STOSCENARIO **scenariotree, STOSCENARIO ***scenarios, int *numscenarios, int numstages, int stage)
 
static SCIP_RETCODE addScenariosToReaderdata (SCIP *scip, SCIP_READERDATA *readerdata, STOSCENARIO ***scenarios, int *numscenarios, int numscenariostages)
 
static STOSCENARIO * findScenarioInTree (STOSCENARIO *scenariotree, const char *scenname)
 
static SCIP_RETCODE insertScenarioInReaderdata (SCIP *scip, SCIP_READERDATA *readerdata, STOSCENARIO *scenario, char *parentname)
 
static SCIP_RETCODE buildScenariosFromBlocks (SCIP *scip, STOSCENARIO ***blocks, STOSCENARIO ***scenarios, STOSCENARIO ***blocksforscen, int *numblocksforscen, int numblocks, int *numblocksperblock, int *numscenarios, int *scenariossize, const char *stage, int stagenum, int blocknum)
 
static SCIP_RETCODE createScenariosFromBlocks (SCIP *scip, SCIP_READERDATA *readerdata, STOSCENARIO ***blocks, int numblocks, int *numblocksperblock, int numstages)
 
static SCIP_RETCODE createReaderdata (SCIP *scip, SCIP_READERDATA *readerdata)
 
static SCIP_RETCODE freeReaderdata (SCIP *scip, SCIP_READERDATA *readerdata)
 
static SCIP_RETCODE stoinputCreate (SCIP *scip, STOINPUT **stoi, SCIP_FILE *fp)
 
static void stoinputFree (SCIP *scip, STOINPUT **stoi)
 
static STOSECTION stoinputSection (const STOINPUT *stoi)
 
static STOSTOCHINFO stoinputStochInfoType (const STOINPUT *stoi)
 
static const char * stoinputField0 (const STOINPUT *stoi)
 
static const char * stoinputField1 (const STOINPUT *stoi)
 
static const char * stoinputField2 (const STOINPUT *stoi)
 
static const char * stoinputField3 (const STOINPUT *stoi)
 
static const char * stoinputField4 (const STOINPUT *stoi)
 
static const char * stoinputField5 (const STOINPUT *stoi)
 
static SCIP_Bool stoinputHasError (const STOINPUT *stoi)
 
static void stoinputSetSection (STOINPUT *stoi, STOSECTION section)
 
static void stoinputSetStochInfoType (STOINPUT *stoi, STOSTOCHINFO stochinfotype)
 
static void stoinputSetProbname (STOINPUT *stoi, const char *probname)
 
static void stoinputSetStochtype (STOINPUT *stoi, const char *stochtype)
 
static void stoinputSyntaxerror (STOINPUT *stoi)
 
static void clearFrom (char *buf, unsigned int pos)
 
static SCIP_Bool stoinputReadLine (STOINPUT *stoi)
 
static SCIP_RETCODE readStoch (SCIP *scip, STOINPUT *stoi)
 
static SCIP_RETCODE readBlocks (STOINPUT *stoi, SCIP *scip, SCIP_READERDATA *readerdata)
 
static SCIP_RETCODE readScenarios (STOINPUT *stoi, SCIP *scip, SCIP_READERDATA *readerdata)
 
static SCIP_RETCODE readIndep (STOINPUT *stoi, SCIP *scip, SCIP_READERDATA *readerdata)
 
static SCIP_Real computeScenarioProbability (SCIP *scip, STOSCENARIO *scenario)
 
static void getScenarioEntityName (char *name, const char *varname, int stagenum, int scenarionum)
 
static SCIP_RETCODE addScenarioVarsToProb (SCIP *scip, STOSCENARIO *scenario, SCIP_VAR **vars, int nvars)
 
static SCIP_RETCODE findScenarioVar (SCIP *scip, STOSCENARIO *scenario, SCIP_VAR *consvar, SCIP_VAR **scenariovar)
 
static SCIP_RETCODE getScenarioDecompVar (SCIP *scip, STOSCENARIO *scenario, SCIP_VAR *consvar, SCIP_VAR **scenariovar, SCIP_Bool *varadded)
 
static SCIP_RETCODE addScenarioConsToProb (SCIP *scip, STOSCENARIO *scenario, SCIP_CONS **conss, int nconss, SCIP_Bool decomp)
 
static SCIP_RETCODE addScenarioVarsAndConsToProb (SCIP *scip, STOSCENARIO *scenario, SCIP_Bool decomp)
 
static SCIP_RETCODE removeCoreVariablesAndConstraints (SCIP *scip)
 
static SCIP_RETCODE buildFullProblem (SCIP *scip, SCIP_READERDATA *readerdata)
 
static SCIP_RETCODE buildDecompProblem (SCIP *scip, SCIP_READERDATA *readerdata)
 
static SCIP_RETCODE readSto (SCIP *scip, const char *filename, SCIP_READERDATA *readerdata)
 
static SCIP_DECL_READERCOPY (readerCopySto)
 
static SCIP_DECL_READERFREE (readerFreeSto)
 
static SCIP_DECL_READERREAD (readerReadSto)
 
SCIP_RETCODE SCIPincludeReaderSto (SCIP *scip)
 
SCIP_RETCODE SCIPreadSto (SCIP *scip, const char *filename, SCIP_RESULT *result)
 
int SCIPstoGetNScenarios (SCIP *scip)
 

Macro Definition Documentation

◆ READER_NAME

#define READER_NAME   "storeader"

◆ READER_DESC

#define READER_DESC   "file reader for stochastic information of stochastic programs in the SMPS file format"

Definition at line 51 of file reader_sto.c.

Referenced by SCIPincludeReaderSto().

◆ READER_EXTENSION

#define READER_EXTENSION   "sto"

Definition at line 52 of file reader_sto.c.

Referenced by SCIPincludeReaderSto().

◆ DEFAULT_USEBENDERS

#define DEFAULT_USEBENDERS   FALSE

should Benders' decomposition be used for the stochastic program?

Definition at line 54 of file reader_sto.c.

Referenced by SCIPincludeReaderSto().

◆ STO_MAX_LINELEN

#define STO_MAX_LINELEN   1024

Definition at line 60 of file reader_sto.c.

Referenced by stoinputReadLine().

◆ STO_MAX_NAMELEN

#define STO_MAX_NAMELEN   256

Definition at line 61 of file reader_sto.c.

Referenced by stoinputSetProbname(), and stoinputSetStochtype().

◆ STO_DEFAULT_ARRAYSIZE

#define STO_DEFAULT_ARRAYSIZE   100

Definition at line 63 of file reader_sto.c.

Referenced by readBlocks(), and readIndep().

◆ STO_DEFAULT_ENTRIESSIZE

#define STO_DEFAULT_ENTRIESSIZE   20

Definition at line 64 of file reader_sto.c.

Referenced by createScenarioData().

◆ STO_DEFAULT_BLOCKARRAYSIZE

#define STO_DEFAULT_BLOCKARRAYSIZE   5

Definition at line 65 of file reader_sto.c.

Referenced by createScenariosFromBlocks(), readBlocks(), and readIndep().

◆ STO_DEFAULT_CHILDRENSIZE

#define STO_DEFAULT_CHILDRENSIZE   5

Definition at line 66 of file reader_sto.c.

Referenced by createScenarioData().

◆ BLANK

#define BLANK   ' '

Definition at line 68 of file reader_sto.c.

Referenced by clearFrom(), and stoinputReadLine().

Typedef Documentation

◆ STOSCENARIO

typedef struct StoScenario STOSCENARIO

Definition at line 70 of file reader_sto.c.

◆ STOSECTION

typedef enum StoSection STOSECTION

Definition at line 114 of file reader_sto.c.

◆ STOSTOCHINFO

typedef enum StoStochInfo STOSTOCHINFO

Definition at line 126 of file reader_sto.c.

◆ STOINPUT

typedef struct StoInput STOINPUT

Definition at line 146 of file reader_sto.c.

Enumeration Type Documentation

◆ StoSection

enum StoSection

enum containing all sto sections

Enumerator
STO_STOCH 
STO_SCENARIOS 
STO_BLOCKS 
STO_INDEP 
STO_ENDATA 

Definition at line 106 of file reader_sto.c.

◆ StoStochInfo

enum containing the types of stochastic information

Enumerator
STO_STOCHINFO_NONE 
STO_STOCHINFO_DISCRETE 
STO_STOCHINFO_UNIFORM 
STO_STOCHINFO_NORMAL 
STO_STOCHINFO_SUB 
STO_STOCHINFO_LINTR 

Definition at line 117 of file reader_sto.c.

Function Documentation

◆ createScenarioData()

static SCIP_RETCODE createScenarioData ( SCIP *  scip,
STOSCENARIO **  scenariodata 
)
static

creates a scenario structure

Parameters
scipSCIP data structure
scenariodatathe scenario to be created

Definition at line 150 of file reader_sto.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemory, SCIPallocBlockMemoryArray, SCIPdebugMessage, STO_DEFAULT_CHILDRENSIZE, and STO_DEFAULT_ENTRIESSIZE.

Referenced by buildScenariosFromBlocks(), createReaderdata(), readBlocks(), readIndep(), readScenarios(), and scenarioAddChild().

◆ freeScenarioTree()

static SCIP_RETCODE freeScenarioTree ( SCIP *  scip,
STOSCENARIO **  scenariotree 
)
static

frees the memory used for the scenario tree

Parameters
scipthe SCIP data structure
scenariotreethe scenario tree

Definition at line 185 of file reader_sto.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPdebugMessage, SCIPfree(), SCIPfreeBlockMemory, and SCIPfreeBlockMemoryArray.

Referenced by createScenariosFromBlocks(), freeReaderdata(), readBlocks(), readIndep(), and readScenarios().

◆ setScenarioScip()

static void setScenarioScip ( STOSCENARIO *  scenario,
SCIP *  scip 
)
static

sets the SCIP pointer to the scenario

Parameters
scenariothe scenario
scipthe SCIP data structure

Definition at line 230 of file reader_sto.c.

References NULL, and StoScenario::scip.

Referenced by addScenarioVarsAndConsToProb(), and buildDecompProblem().

◆ getScenarioScip()

static SCIP* getScenarioScip ( STOSCENARIO *  scenario)
static

returns the SCIP pointer to the scenario

Parameters
scenariothe scenario

Definition at line 243 of file reader_sto.c.

References NULL, and StoScenario::scip.

Referenced by addScenarioVarsAndConsToProb(), buildDecompProblem(), and getScenarioDecompVar().

◆ createScenarioSubproblemArray()

static SCIP_RETCODE createScenarioSubproblemArray ( SCIP *  scip,
STOSCENARIO *  scenario 
)
static

creates the subproblem array. This array will be the same size as the number of children

Parameters
scipthe SCIP data structure
scenariothe scenario

Definition at line 254 of file reader_sto.c.

References StoScenario::nchildren, NULL, SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemoryArray, and StoScenario::subproblems.

Referenced by addScenarioVarsAndConsToProb(), and buildDecompProblem().

◆ addScenarioSubproblem()

static void addScenarioSubproblem ( STOSCENARIO *  scenario,
SCIP *  subproblem 
)
static

adds a scenario to the subproblem array

Parameters
scenariothe scenario
subproblemthe subproblems data structure

Definition at line 269 of file reader_sto.c.

References StoScenario::nchildren, StoScenario::nsubproblems, NULL, and StoScenario::subproblems.

Referenced by addScenarioVarsAndConsToProb(), and buildDecompProblem().

◆ getScenarioSubproblemArray()

static SCIP** getScenarioSubproblemArray ( STOSCENARIO *  scenario)
static

returns the subproblem array for the scenario

Parameters
scenariothe scenario

Definition at line 285 of file reader_sto.c.

References NULL, and StoScenario::subproblems.

Referenced by addScenarioVarsAndConsToProb(), and buildDecompProblem().

◆ getScenarioNChildren()

static int getScenarioNChildren ( STOSCENARIO *  scenario)
static

returns the number of children for a given scenario

Parameters
scenariothe scenario

Definition at line 296 of file reader_sto.c.

References StoScenario::nchildren, and NULL.

Referenced by addScenarioVarsAndConsToProb(), buildDecompProblem(), buildFullProblem(), buildScenarioTree(), and findScenarioInTree().

◆ getScenarioChild()

static STOSCENARIO* getScenarioChild ( STOSCENARIO *  scenario,
int  childnum 
)
static

returns a given child for a given scenario

Parameters
scenariothe scenario
childnumthe number of the desired child

Definition at line 307 of file reader_sto.c.

References StoScenario::children, and NULL.

Referenced by addScenarioVarsAndConsToProb(), buildDecompProblem(), buildFullProblem(), and buildScenarioTree().

◆ getScenarioParent()

static STOSCENARIO* getScenarioParent ( STOSCENARIO *  scenario)
static

returns the parent of a scenario

Parameters
scenariothe scenario

Definition at line 320 of file reader_sto.c.

References NULL, and StoScenario::parent.

Referenced by computeScenarioProbability(), findScenarioVar(), and getScenarioDecompVar().

◆ setScenarioStageName()

static SCIP_RETCODE setScenarioStageName ( SCIP *  scip,
STOSCENARIO *  scenario,
const char *  stagename 
)
static

sets the stage name

Parameters
scipthe SCIP data structure
scenariothe scenario
stagenamethe stage name

Definition at line 331 of file reader_sto.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPduplicateBlockMemoryArray, and StoScenario::stagename.

Referenced by buildScenariosFromBlocks(), copyScenario(), createReaderdata(), readBlocks(), readIndep(), and readScenarios().

◆ getScenarioStageName()

static const char* getScenarioStageName ( SCIP *  scip,
STOSCENARIO *  scenario 
)
static

returns the stage name

Parameters
scipthe SCIP data structure
scenariothe scenario

Definition at line 347 of file reader_sto.c.

References NULL, and StoScenario::stagename.

Referenced by addScenarioVarsAndConsToProb(), buildScenariosFromBlocks(), buildScenarioTree(), and createScenariosFromBlocks().

◆ setScenarioStageNum()

static SCIP_RETCODE setScenarioStageNum ( SCIP *  scip,
STOSCENARIO *  scenario,
int  stagenum 
)
static

sets the stage num

Parameters
scipthe SCIP data structure
scenariothe scenario
stagenumthe stage num

Definition at line 360 of file reader_sto.c.

References NULL, SCIP_OKAY, and StoScenario::stagenum.

Referenced by buildScenariosFromBlocks(), copyScenario(), createScenariosFromBlocks(), and readScenarios().

◆ getScenarioStageNum()

static int getScenarioStageNum ( SCIP *  scip,
STOSCENARIO *  scenario 
)
static

returns the stage num

Parameters
scipthe SCIP data structure
scenariothe scenario

Definition at line 376 of file reader_sto.c.

References NULL, and StoScenario::stagenum.

Referenced by addScenarioConsToProb(), addScenarioVarsAndConsToProb(), addScenarioVarsToProb(), findScenarioVar(), and getScenarioDecompVar().

◆ setScenarioName()

static SCIP_RETCODE setScenarioName ( SCIP *  scip,
STOSCENARIO *  scenario,
const char *  name 
)
static

sets the scenario name

Parameters
scipthe SCIP data structure
scenariothe scenario
namethe scenario name

Definition at line 389 of file reader_sto.c.

References StoScenario::name, NULL, SCIP_CALL, SCIP_OKAY, and SCIPduplicateBlockMemoryArray.

Referenced by buildScenariosFromBlocks(), copyScenario(), createReaderdata(), readBlocks(), readIndep(), and readScenarios().

◆ getScenarioName()

static const char* getScenarioName ( STOSCENARIO *  scenario)
static

returns the scenario name

Parameters
scenariothe scenario

Definition at line 405 of file reader_sto.c.

References StoScenario::name, and NULL.

Referenced by findScenarioInTree(), readBlocks(), and readIndep().

◆ setScenarioNum()

static SCIP_RETCODE setScenarioNum ( SCIP *  scip,
STOSCENARIO *  scenario,
int  scenarionum 
)
static

sets the scenario num

Parameters
scipthe SCIP data structure
scenariothe scenario
scenarionumthe scenario num

Definition at line 416 of file reader_sto.c.

References NULL, StoScenario::scenarionum, and SCIP_OKAY.

Referenced by buildScenariosFromBlocks(), copyScenario(), createScenariosFromBlocks(), and readScenarios().

◆ getScenarioNum()

static int getScenarioNum ( SCIP *  scip,
STOSCENARIO *  scenario 
)
static

returns the scenario num

Parameters
scipthe SCIP data structure
scenariothe scenario

Definition at line 432 of file reader_sto.c.

References NULL, and StoScenario::scenarionum.

Referenced by addScenarioConsToProb(), addScenarioVarsAndConsToProb(), addScenarioVarsToProb(), findScenarioVar(), and getScenarioDecompVar().

◆ setScenarioProbability()

static SCIP_RETCODE setScenarioProbability ( SCIP *  scip,
STOSCENARIO *  scenario,
SCIP_Real  probability 
)
static

sets the scenario probability

Parameters
scipthe SCIP data structure
scenariothe scenario
probabilitythe scenario probability

Definition at line 445 of file reader_sto.c.

References NULL, StoScenario::probability, and SCIP_OKAY.

Referenced by copyScenario(), mergeScenarios(), readBlocks(), readIndep(), and readScenarios().

◆ getScenarioProbability()

static SCIP_Real getScenarioProbability ( SCIP *  scip,
STOSCENARIO *  scenario 
)
static

returns the scenario probability

Parameters
scipthe SCIP data structure
scenariothe scenario

Definition at line 461 of file reader_sto.c.

References NULL, and StoScenario::probability.

Referenced by computeScenarioProbability(), copyScenario(), and mergeScenarios().

◆ addScenarioEntry()

static SCIP_RETCODE addScenarioEntry ( SCIP *  scip,
STOSCENARIO *  scenario,
const char *  rowname,
const char *  colname,
SCIP_Real  value 
)
static

add scenario entry

Parameters
scipthe SCIP data structure
scenariothe scenario
rownamethe row name for the entry
colnamethe col name for the entry
valuethe value for the entry

Definition at line 474 of file reader_sto.c.

References StoScenario::colnames, StoScenario::entriessize, StoScenario::nentries, NULL, StoScenario::rownames, SCIP_CALL, SCIP_OKAY, SCIPcalcMemGrowSize(), SCIPduplicateBlockMemoryArray, SCIPreallocBlockMemoryArray, and StoScenario::values.

Referenced by copyScenario(), mergeScenarios(), readBlocks(), readIndep(), and readScenarios().

◆ getScenarioNEntries()

static int getScenarioNEntries ( STOSCENARIO *  scenario)
static

returns the number of entries for a scenario

Parameters
scenariothe scenario

Definition at line 506 of file reader_sto.c.

References StoScenario::nentries, and NULL.

Referenced by addScenarioVarsAndConsToProb().

◆ getScenarioEntryRow()

static const char* getScenarioEntryRow ( STOSCENARIO *  scenario,
int  entry 
)
static

returns an entry row for a scenario

Parameters
scenariothe scenario
entrythe entry number

Definition at line 517 of file reader_sto.c.

References NULL, and StoScenario::rownames.

Referenced by addScenarioVarsAndConsToProb().

◆ getScenarioEntryCol()

static const char* getScenarioEntryCol ( STOSCENARIO *  scenario,
int  entry 
)
static

returns an entry column for a scenario

Parameters
scenariothe scenario
entrythe entry number

Definition at line 530 of file reader_sto.c.

References StoScenario::colnames, and NULL.

Referenced by addScenarioVarsAndConsToProb().

◆ getScenarioEntryValue()

static SCIP_Real getScenarioEntryValue ( STOSCENARIO *  scenario,
int  entry 
)
static

returns an entry value for a scenario

Parameters
scenariothe scenario
entrythe entry number

Definition at line 543 of file reader_sto.c.

References NULL, and StoScenario::values.

Referenced by addScenarioVarsAndConsToProb().

◆ copyScenario()

static SCIP_RETCODE copyScenario ( SCIP *  scip,
STOSCENARIO *  sourcescenario,
STOSCENARIO **  targetscenario,
SCIP_Bool  copyname 
)
static

copies a scenario. In the case of blocks, the scenarios must be combined

Parameters
scipthe SCIP data structure
sourcescenariothe source scenario
targetscenariothe target scenario
copynameshould the name be copied?

Definition at line 558 of file reader_sto.c.

References addScenarioEntry(), StoScenario::colnames, getScenarioProbability(), StoScenario::name, StoScenario::nentries, NULL, StoScenario::rownames, StoScenario::scenarionum, SCIP_CALL, SCIP_OKAY, SCIP_Real, setScenarioName(), setScenarioNum(), setScenarioProbability(), setScenarioStageName(), setScenarioStageNum(), StoScenario::stagename, StoScenario::stagenum, and StoScenario::values.

Referenced by buildScenariosFromBlocks(), and scenarioAddChild().

◆ mergeScenarios()

static SCIP_RETCODE mergeScenarios ( SCIP *  scip,
STOSCENARIO *  scenario1,
STOSCENARIO **  mergedscenario 
)
static

merge scenarios. In the case of blocks, the scenarios must be combined

Parameters
scipthe SCIP data structure
scenario1the first scenario
mergedscenariothe merged scenario

Definition at line 597 of file reader_sto.c.

References addScenarioEntry(), StoScenario::colnames, getScenarioProbability(), StoScenario::nentries, NULL, StoScenario::rownames, SCIP_CALL, SCIP_OKAY, SCIP_Real, setScenarioProbability(), and StoScenario::values.

Referenced by buildScenariosFromBlocks().

◆ scenarioAddChild()

static SCIP_RETCODE scenarioAddChild ( SCIP *  scip,
STOSCENARIO **  parent,
STOSCENARIO *  child 
)
static

adds a child to a given scenario

Parameters
scipthe SCIP data structure
parentthe parent scenario
childthe child scenario

Definition at line 624 of file reader_sto.c.

References StoScenario::children, copyScenario(), createScenarioData(), StoScenario::nchildren, NULL, StoScenario::parent, SCIP_CALL, SCIP_OKAY, SCIPensureBlockMemoryArray, and TRUE.

Referenced by buildScenarioTree(), and insertScenarioInReaderdata().

◆ buildScenarioTree()

static SCIP_RETCODE buildScenarioTree ( SCIP *  scip,
STOSCENARIO **  scenariotree,
STOSCENARIO ***  scenarios,
int *  numscenarios,
int  numstages,
int  stage 
)
static

recursively adds the scenarios to the reader data

Parameters
scipthe SCIP data structure
scenariotreethe scenario tree
scenariosthe array of scenarios
numscenariosthe number of scenarios per stage
numstagesthe number of stages
stagethe number of the stage. Also the depth of the tree

Definition at line 652 of file reader_sto.c.

References getScenarioChild(), getScenarioNChildren(), getScenarioStageName(), NULL, scenarioAddChild(), SCIP_CALL, SCIP_OKAY, and SCIPtimGetStageName().

Referenced by addScenariosToReaderdata().

◆ addScenariosToReaderdata()

static SCIP_RETCODE addScenariosToReaderdata ( SCIP *  scip,
SCIP_READERDATA *  readerdata,
STOSCENARIO ***  scenarios,
int *  numscenarios,
int  numscenariostages 
)
static
Parameters
scipthe SCIP data structure
readerdatathe reader data
scenariosthe array of scenarios
numscenariosthe number of scenarios per stage
numscenariostagesthe number of stages for which scenarios were collected

Definition at line 698 of file reader_sto.c.

References buildScenarioTree(), FALSE, NULL, SCIP_CALL, SCIP_OKAY, and SCIPtimGetNStages().

Referenced by createScenariosFromBlocks().

◆ findScenarioInTree()

static STOSCENARIO* findScenarioInTree ( STOSCENARIO *  scenariotree,
const char *  scenname 
)
static

finds a scenario with a given name

Parameters
scenariotreethe scenario tree to search
scennamethe name of the scenario to search

Definition at line 729 of file reader_sto.c.

References StoScenario::children, getScenarioName(), getScenarioNChildren(), and NULL.

Referenced by insertScenarioInReaderdata().

◆ insertScenarioInReaderdata()

static SCIP_RETCODE insertScenarioInReaderdata ( SCIP *  scip,
SCIP_READERDATA *  readerdata,
STOSCENARIO *  scenario,
char *  parentname 
)
static

inserts a scenario into the reader data scenario tree

Parameters
scipthe SCIP data structure
readerdatathe reader data
scenariothe scenario to insert in the scenario tree
parentnamethe parent scenario for the inserting scenario

Definition at line 756 of file reader_sto.c.

References findScenarioInTree(), NULL, scenarioAddChild(), SCIP_CALL, and SCIP_OKAY.

Referenced by readScenarios().

◆ buildScenariosFromBlocks()

static SCIP_RETCODE buildScenariosFromBlocks ( SCIP *  scip,
STOSCENARIO ***  blocks,
STOSCENARIO ***  scenarios,
STOSCENARIO ***  blocksforscen,
int *  numblocksforscen,
int  numblocks,
int *  numblocksperblock,
int *  numscenarios,
int *  scenariossize,
const char *  stage,
int  stagenum,
int  blocknum 
)
static
Parameters
scipthe SCIP data structure
blocksthe block that form the scenarios
scenariosthe array to store the scenarios
blocksforscenthe blocks that will form the scenario
numblocksforscenthe number of blocks that form the scenario
numblocksthe number of blocks
numblocksperblockthe number of blocks for a given block
numscenariosthe number of scenarios
scenariossizethe size of scenarios array
stagethe stage for this scenario
stagenumthe number of the stage
blocknumthe block number

Definition at line 783 of file reader_sto.c.

References copyScenario(), createScenarioData(), FALSE, getScenarioStageName(), mergeScenarios(), NULL, SCIP_Bool, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIPcalcMemGrowSize(), SCIPreallocBlockMemoryArray, SCIPsnprintf(), setScenarioName(), setScenarioNum(), setScenarioStageName(), setScenarioStageNum(), and TRUE.

Referenced by createScenariosFromBlocks().

◆ createScenariosFromBlocks()

static SCIP_RETCODE createScenariosFromBlocks ( SCIP *  scip,
SCIP_READERDATA *  readerdata,
STOSCENARIO ***  blocks,
int  numblocks,
int *  numblocksperblock,
int  numstages 
)
static
Parameters
scipthe SCIP data structure
readerdatathe reader data
blocksthe block that form the scenarios
numblocksthe number of blocks
numblocksperblockthe number of blocks for each block type
numstagesthe number of stages

Definition at line 880 of file reader_sto.c.

References addScenariosToReaderdata(), buildScenariosFromBlocks(), freeScenarioTree(), getScenarioStageName(), NULL, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIPallocBlockMemoryArray, SCIPallocBufferArray, SCIPfreeBlockMemoryArray, SCIPfreeBufferArray, SCIPsnprintf(), setScenarioNum(), setScenarioStageNum(), and STO_DEFAULT_BLOCKARRAYSIZE.

Referenced by readBlocks(), and readIndep().

◆ createReaderdata()

static SCIP_RETCODE createReaderdata ( SCIP *  scip,
SCIP_READERDATA *  readerdata 
)
static

creates the reader data

Parameters
scipSCIP data structure
readerdatathe reader data

Definition at line 956 of file reader_sto.c.

References createScenarioData(), NULL, SCIP_CALL, SCIP_OKAY, SCIPtimGetStageName(), setScenarioName(), and setScenarioStageName().

Referenced by readSto().

◆ freeReaderdata()

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

frees the reader data

Parameters
scipthe SCIP data structure
readerdatathe reader data

Definition at line 976 of file reader_sto.c.

References freeScenarioTree(), NULL, SCIP_CALL, SCIP_OKAY, and SCIPfreeBlockMemory.

Referenced by SCIP_DECL_READERFREE().

◆ stoinputCreate()

static SCIP_RETCODE stoinputCreate ( SCIP *  scip,
STOINPUT **  stoi,
SCIP_FILE *  fp 
)
static

creates the sto input structure

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

Definition at line 995 of file reader_sto.c.

References FALSE, StoInput::fp, NULL, SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemory, STO_STOCH, and STO_STOCHINFO_NONE.

Referenced by readSto().

◆ stoinputFree()

static void stoinputFree ( SCIP *  scip,
STOINPUT **  stoi 
)
static

free the sto input structure

Parameters
scipSCIP data structure
stoisto input structure

Definition at line 1026 of file reader_sto.c.

References SCIPfreeBlockMemory.

Referenced by readSto().

◆ stoinputSection()

static STOSECTION stoinputSection ( const STOINPUT *  stoi)
static

returns the current section

Parameters
stoisto input structure

Definition at line 1036 of file reader_sto.c.

References NULL, and StoInput::section.

Referenced by readSto().

◆ stoinputStochInfoType()

static STOSTOCHINFO stoinputStochInfoType ( const STOINPUT *  stoi)
static

returns the stochastic information type

Parameters
stoisto input structure

Definition at line 1047 of file reader_sto.c.

References NULL, and StoInput::stochinfotype.

Referenced by readSto().

◆ stoinputField0()

static const char* stoinputField0 ( const STOINPUT *  stoi)
static

return the current value of field 0

Parameters
stoisto input structure

Definition at line 1058 of file reader_sto.c.

References StoInput::f0, and NULL.

Referenced by readBlocks(), readIndep(), readScenarios(), and readStoch().

◆ stoinputField1()

static const char* stoinputField1 ( const STOINPUT *  stoi)
static

return the current value of field 1

Parameters
stoisto input structure

Definition at line 1069 of file reader_sto.c.

References StoInput::f1, and NULL.

Referenced by readBlocks(), readIndep(), readScenarios(), and readStoch().

◆ stoinputField2()

static const char* stoinputField2 ( const STOINPUT *  stoi)
static

return the current value of field 2

Parameters
stoisto input structure

Definition at line 1080 of file reader_sto.c.

References StoInput::f2, and NULL.

Referenced by readBlocks(), readIndep(), and readScenarios().

◆ stoinputField3()

static const char* stoinputField3 ( const STOINPUT *  stoi)
static

return the current value of field 3

Parameters
stoisto input structure

Definition at line 1091 of file reader_sto.c.

References StoInput::f3, and NULL.

Referenced by readBlocks(), readIndep(), and readScenarios().

◆ stoinputField4()

static const char* stoinputField4 ( const STOINPUT *  stoi)
static

return the current value of field 4

Parameters
stoisto input structure

Definition at line 1102 of file reader_sto.c.

References StoInput::f4, and NULL.

Referenced by readBlocks(), readIndep(), and readScenarios().

◆ stoinputField5()

static const char* stoinputField5 ( const STOINPUT *  stoi)
static

return the current value of field 5

Parameters
stoisto input structure

Definition at line 1113 of file reader_sto.c.

References StoInput::f5, and NULL.

Referenced by readIndep(), and readScenarios().

◆ stoinputHasError()

static SCIP_Bool stoinputHasError ( const STOINPUT *  stoi)
static

returns if an error was detected

Parameters
stoisto input structure

Definition at line 1124 of file reader_sto.c.

References StoInput::haserror, and NULL.

Referenced by readSto().

◆ stoinputSetSection()

static void stoinputSetSection ( STOINPUT *  stoi,
STOSECTION  section 
)
static

set the section in the sto input structure to given section

Parameters
stoisto input structure
sectionsection that is set

Definition at line 1135 of file reader_sto.c.

References NULL, and StoInput::section.

Referenced by readBlocks(), readIndep(), readScenarios(), and readStoch().

◆ stoinputSetStochInfoType()

static void stoinputSetStochInfoType ( STOINPUT *  stoi,
STOSTOCHINFO  stochinfotype 
)
static

set the stochastic info type in the sto input structure

Parameters
stoisto input structure
stochinfotypethe stochastic infomation type

Definition at line 1147 of file reader_sto.c.

References NULL, and StoInput::stochinfotype.

Referenced by readStoch().

◆ stoinputSetProbname()

static void stoinputSetProbname ( STOINPUT *  stoi,
const char *  probname 
)
static

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

Parameters
stoisto input structure
probnamename of the problem to set

Definition at line 1159 of file reader_sto.c.

References NULL, StoInput::probname, SCIPmemccpy(), and STO_MAX_NAMELEN.

Referenced by readStoch().

◆ stoinputSetStochtype()

static void stoinputSetStochtype ( STOINPUT *  stoi,
const char *  stochtype 
)
static

set the type name in the sto input structure to given objective name

Parameters
stoisto input structure
stochtypename of the scenario type

Definition at line 1173 of file reader_sto.c.

References NULL, SCIPmemccpy(), STO_MAX_NAMELEN, and StoInput::stochtype.

Referenced by readBlocks(), readIndep(), and readScenarios().

◆ stoinputSyntaxerror()

static void stoinputSyntaxerror ( STOINPUT *  stoi)
static
Parameters
stoisto input structure

Definition at line 1186 of file reader_sto.c.

References StoInput::haserror, StoInput::lineno, NULL, SCIPerrorMessage, StoInput::section, STO_ENDATA, and TRUE.

Referenced by readBlocks(), readIndep(), readScenarios(), readSto(), and readStoch().

◆ 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 1199 of file reader_sto.c.

References BLANK.

Referenced by stoinputReadLine().

◆ stoinputReadLine()

static SCIP_Bool stoinputReadLine ( STOINPUT *  stoi)
static

read a sto format data line and parse the fields.

Parameters
stoisto input structure

Definition at line 1213 of file reader_sto.c.

References BLANK, StoInput::buf, clearFrom(), StoInput::f0, StoInput::f1, StoInput::f2, StoInput::f3, StoInput::f4, StoInput::f5, FALSE, StoInput::fp, StoInput::lineno, NULL, SCIP_Bool, SCIPdebugMessage, SCIPfgets(), SCIPstrtok(), STO_MAX_LINELEN, and TRUE.

Referenced by readBlocks(), readIndep(), readScenarios(), and readStoch().

◆ readStoch()

static SCIP_RETCODE readStoch ( SCIP *  scip,
STOINPUT *  stoi 
)
static

◆ readBlocks()

◆ readScenarios()

◆ readIndep()

◆ computeScenarioProbability()

static SCIP_Real computeScenarioProbability ( SCIP *  scip,
STOSCENARIO *  scenario 
)
static

computes the probability of a scenario

Parameters
scipthe SCIP data structure
scenariothe current scenario

Definition at line 1838 of file reader_sto.c.

References getScenarioParent(), getScenarioProbability(), NULL, and SCIP_Real.

Referenced by addScenarioVarsAndConsToProb(), and addScenarioVarsToProb().

◆ getScenarioEntityName()

static void getScenarioEntityName ( char *  name,
const char *  varname,
int  stagenum,
int  scenarionum 
)
static

gets the variable name

Parameters
namethe name to be returned
varnamethe root of the variable name
stagenumthe stage number
scenarionumthe scenario number

Definition at line 1863 of file reader_sto.c.

References SCIP_MAXSTRLEN, and SCIPsnprintf().

Referenced by addScenarioConsToProb(), addScenarioVarsAndConsToProb(), addScenarioVarsToProb(), findScenarioVar(), and getScenarioDecompVar().

◆ addScenarioVarsToProb()

static SCIP_RETCODE addScenarioVarsToProb ( SCIP *  scip,
STOSCENARIO *  scenario,
SCIP_VAR **  vars,
int  nvars 
)
static

add variables to the scenario

Parameters
scipthe SCIP data structure
scenariothe current scenario
varsthe variables of the core problem associated with this scenario
nvarsthe number of variables for this scenario

Definition at line 1879 of file reader_sto.c.

References computeScenarioProbability(), getScenarioEntityName(), getScenarioNum(), getScenarioStageNum(), NULL, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIP_VARTYPE_CONTINUOUS, SCIPaddVar(), SCIPcreateVar(), SCIPdebugMessage, SCIPreleaseVar(), SCIPvarGetLbOriginal(), SCIPvarGetName(), SCIPvarGetObj(), SCIPvarGetType(), SCIPvarGetUbOriginal(), SCIPvarIsDeleted(), SCIPvarIsInitial(), and SCIPvarIsRemovable().

Referenced by addScenarioVarsAndConsToProb().

◆ findScenarioVar()

static SCIP_RETCODE findScenarioVar ( SCIP *  scip,
STOSCENARIO *  scenario,
SCIP_VAR *  consvar,
SCIP_VAR **  scenariovar 
)
static

finds the scenario variable to add to a constraint

Parameters
scipthe SCIP data structure
scenariothe current scenario
consvarthe variable in the constraint that is being searched for
scenariovarpointer to return the variable to be added to the constraint

Definition at line 1937 of file reader_sto.c.

References getScenarioEntityName(), getScenarioNum(), getScenarioParent(), getScenarioStageNum(), NULL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIPfindVar(), SCIPsnprintf(), and SCIPvarGetName().

Referenced by addScenarioConsToProb().

◆ getScenarioDecompVar()

static SCIP_RETCODE getScenarioDecompVar ( SCIP *  scip,
STOSCENARIO *  scenario,
SCIP_VAR *  consvar,
SCIP_VAR **  scenariovar,
SCIP_Bool *  varadded 
)
static

create variable for the decomposed scenario

Parameters
scipthe SCIP data structure
scenariothe current scenario
consvarthe variable in the constraint that is being searched for
scenariovarpointer to return the variable to be added to the constraint
varaddedpointer to indicate whether a variable has been added

Definition at line 1980 of file reader_sto.c.

References FALSE, getScenarioEntityName(), getScenarioNum(), getScenarioParent(), getScenarioScip(), getScenarioStageNum(), NULL, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIPaddVar(), SCIPcreateVar(), SCIPfindVar(), SCIPsnprintf(), SCIPvarGetLbOriginal(), SCIPvarGetName(), SCIPvarGetType(), SCIPvarGetUbOriginal(), SCIPvarIsInitial(), SCIPvarIsRemovable(), and TRUE.

Referenced by addScenarioConsToProb().

◆ addScenarioConsToProb()

static SCIP_RETCODE addScenarioConsToProb ( SCIP *  scip,
STOSCENARIO *  scenario,
SCIP_CONS **  conss,
int  nconss,
SCIP_Bool  decomp 
)
static

◆ addScenarioVarsAndConsToProb()

◆ removeCoreVariablesAndConstraints()

static SCIP_RETCODE removeCoreVariablesAndConstraints ( SCIP *  scip)
static

removes the core variables and constriants for stage 2 and lower

Parameters
scipthe SCIP data structure

Definition at line 2266 of file reader_sto.c.

References NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIPconsIsDeleted(), SCIPdelCons(), SCIPdelVar(), SCIPtimGetNStages(), SCIPtimGetStageConss(), SCIPtimGetStageNConss(), SCIPtimGetStageNVars(), SCIPtimGetStageVars(), and SCIPvarIsDeleted().

Referenced by buildDecompProblem(), and buildFullProblem().

◆ buildFullProblem()

static SCIP_RETCODE buildFullProblem ( SCIP *  scip,
SCIP_READERDATA *  readerdata 
)
static
Parameters
scipthe SCIP data structure
readerdatathe reader data

Definition at line 2316 of file reader_sto.c.

References addScenarioVarsAndConsToProb(), FALSE, getScenarioChild(), getScenarioNChildren(), NULL, removeCoreVariablesAndConstraints(), SCIP_CALL, and SCIP_OKAY.

Referenced by readSto().

◆ buildDecompProblem()

static SCIP_RETCODE buildDecompProblem ( SCIP *  scip,
SCIP_READERDATA *  readerdata 
)
static

◆ readSto()

static SCIP_RETCODE readSto ( SCIP *  scip,
const char *  filename,
SCIP_READERDATA *  readerdata 
)
static

◆ SCIP_DECL_READERCOPY()

static SCIP_DECL_READERCOPY ( readerCopySto  )
static

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

Definition at line 2489 of file reader_sto.c.

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

◆ SCIP_DECL_READERFREE()

static SCIP_DECL_READERFREE ( readerFreeSto  )
static

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

Definition at line 2503 of file reader_sto.c.

References freeReaderdata(), NULL, READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPreaderGetData(), and SCIPreaderGetName().

◆ SCIP_DECL_READERREAD()

static SCIP_DECL_READERREAD ( readerReadSto  )
static