49#define READER_NAME "smreader"
50#define READER_DESC "scheduling file reader for sm files (RCPSP format)"
51#define READER_EXTENSION "sm"
59#define DEFAULT_FILENAME "-"
65#define SM_MAX_LINELEN 65536
85 const char** jobnames;
86 const char** resourcenames;
113 for(
i = 0;
i < rcpspdata->njobs ; ++
i )
119 for(
r = 0;
r < rcpspdata->nresources; ++
r )
130 for(
r = 0;
r < rcpspdata->nresources; ++
r )
162 if( erritem !=
NULL )
184 if( strncmp(linestr,
"jobs", 4) == 0 )
186 else if( strncmp(linestr,
"RESOURCES", 9) == 0 )
188 else if( strncmp(linestr,
"PRECEDENCE", 4) == 0 )
190 else if( strncmp(linestr,
"REQUESTS", 4) == 0 )
192 else if( strncmp(linestr,
"RESOURCEAVAILABILITIES", 10) == 0 )
206 SCIP_Real nresources;
213 if( strncmp(linestr,
"RESOURCES", 4) == 0 )
222 parseError(
scip, lineno,
"expexted number of resources", linestr, state);
226 rcpspdata->nresources = (int)(nresources + 0.5);
259 parseError(
scip, lineno,
"expexted number of jobs", linestr, state);
263 rcpspdata->njobs = (int)(njobs + 0.5);
290 if( strncmp(linestr,
"RESOURCEAVAILABILITIES", 10) == 0 )
299 while(isspace(*name))
328 for(
r = 0;
r < rcpspdata->nresources; ++
r )
331 rcpspdata->capacities[
r] = (int)(value + 0.5);
357 if ( (!strncmp(linestr,
"REQUESTS", 4) ) || ( !strncmp(linestr,
"jobnr", 3) ) || ( !strncmp(linestr,
"-", 1) ) )
383 rcpspdata->durations[jobid] = value;
388 for(
r = 0;
r < rcpspdata->nresources; ++
r )
393 rcpspdata->demands[jobid][
r] = value;
397 if( jobid == rcpspdata->njobs - 1 )
420 if( ( !strncmp(s,
"PRECEDENCES", 3) ) || ( !strncmp(s,
"jobnr", 4) ) )
427 if( rcpspdata->precedencegraph ==
NULL )
447 for( p = 0; p < nsuccessors; ++p )
460 if(pred == rcpspdata->njobs-1)
479 for( j = 0; j < njobs; ++j )
489 duration = durations[j];
491 for(
i = 0;
i < nsuccessors; ++
i )
495 distance = (int)(
size_t)distances[
i];
497 if( distance != INT_MAX )
498 duration =
MAX(duration, distance);
511 const char* filename,
535 if(
NULL != (s = strpbrk(buf,
"*\r\n")) )
602 if( state !=
END && state !=
ERROR )
638 rcpspdata.precedencegraph =
NULL;
639 rcpspdata.jobnames =
NULL;
640 rcpspdata.durations =
NULL;
641 rcpspdata.demands =
NULL;
642 rcpspdata.capacities =
NULL;
644 rcpspdata.nresources = 0;
654 if( strncmp(predfilename,
"-", 1) != 0 )
658 file = fopen(predfilename,
"w");
674 rcpspdata.precedencegraph, rcpspdata.durations, rcpspdata.capacities, rcpspdata.njobs, rcpspdata.nresources,
TRUE) );
679 if( rcpspdata.njobs > 0 )
681 for( j = 0; j < rcpspdata.njobs; ++j )
692 if( rcpspdata.nresources > 0 )
696 for(
r = 0;
r < rcpspdata.nresources; ++
r )
703 if( rcpspdata.precedencegraph !=
NULL )
735 "reading/"READER_NAME"/mipmodel",
"create MIP model?",
740 "file name of precedence graph output file (in GML format), or - if no output should be created",
749 const char* problemname,
750 const char** jobnames,
751 const char** resourcenames,
793 for( j = 0; j < njobs - 1; ++j )
796 if( jobnames !=
NULL )
822 for( j = 0; j < njobs - 1; ++j )
832 if( nsuccessors > 0 )
840 for(
i = 0;
i < nsuccessors; ++
i )
845 succvar = jobs[successors[
i]];
850 distance = (int)(
size_t)distances[
i];
852 if( distance == INT_MAX )
853 distance = durations[j];
880 for(
r = 0;
r < nresources; ++
r )
883 for( j = 0; j < njobs; ++j )
885 if( demands[j][
r] > 0 )
888 consdemands[
nvars] = demands[j][
r];
889 consdurations[
nvars] = durations[j];
897 if( resourcenames !=
NULL )
903 nvars,
vars, consdurations, consdemands, capacities[
r],
914 durations, demands, capacities, njobs, nresources) );
constraint handler for cumulative constraints
Constraint handler for linear constraints in their most general form, .
Constraint handler for variable bound constraints .
SCIP_FILE * SCIPfopen(const char *path, const char *mode)
int SCIPfclose(SCIP_FILE *fp)
char * SCIPfgets(char *s, int size, SCIP_FILE *stream)
SCIP_RETCODE SCIPcreateConsVarbound(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *var, SCIP_VAR *vbdvar, SCIP_Real vbdcoef, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_RETCODE SCIPcreateConsCumulative(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, int *durations, int *demands, int capacity, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
void ** SCIPdigraphGetSuccessorsData(SCIP_DIGRAPH *digraph, int node)
int SCIPdigraphGetNSuccessors(SCIP_DIGRAPH *digraph, int node)
void SCIPdigraphPrintGml(SCIP_DIGRAPH *digraph, FILE *file)
SCIP_RETCODE SCIPdigraphAddArc(SCIP_DIGRAPH *digraph, int startnode, int endnode, void *data)
void SCIPdigraphFree(SCIP_DIGRAPH **digraph)
void SCIPdigraphPrint(SCIP_DIGRAPH *digraph, SCIP_MESSAGEHDLR *messagehdlr, FILE *file)
int * SCIPdigraphGetSuccessors(SCIP_DIGRAPH *digraph, int node)
SCIP_RETCODE SCIPcreateDigraph(SCIP *scip, SCIP_DIGRAPH **digraph, int nnodes)
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPcreateProb(SCIP *scip, const char *name, SCIP_DECL_PROBDELORIG((*probdelorig)), SCIP_DECL_PROBTRANS((*probtrans)), SCIP_DECL_PROBDELTRANS((*probdeltrans)), SCIP_DECL_PROBINITSOL((*probinitsol)), SCIP_DECL_PROBEXITSOL((*probexitsol)), SCIP_DECL_PROBCOPY((*probcopy)), SCIP_PROBDATA *probdata)
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
SCIP_MESSAGEHDLR * SCIPgetMessagehdlr(SCIP *scip)
SCIP_RETCODE SCIPaddStringParam(SCIP *scip, const char *name, const char *desc, char **valueptr, SCIP_Bool isadvanced, const char *defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPgetStringParam(SCIP *scip, const char *name, char **value)
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)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPfreeBufferArray(scip, ptr)
#define SCIPduplicateBufferArray(scip, ptr, source, num)
SCIP_RETCODE SCIPsetReaderCopy(SCIP *scip, SCIP_READER *reader,)
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader,)
const char * SCIPreaderGetName(SCIP_READER *reader)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
SCIP_RETCODE SCIPcreateVar(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_DECL_VARCOPY((*varcopy)), SCIP_VARDATA *vardata)
SCIP_RETCODE SCIPmarkDoNotMultaggrVar(SCIP *scip, SCIP_VAR *var)
SCIP_Bool SCIPstrToIntValue(const char *str, int *value, char **endptr)
int SCIPsnprintf(char *t, int len, const char *s,...)
SCIP_Bool SCIPstrToRealValue(const char *str, SCIP_Real *value, char **endptr)
void SCIPprintSysError(const char *message)
char * SCIPstrtok(char *s, const char *delim, char **ptrptr)
assert(minobj< SCIPgetCutoffbound(scip))
SCIP_RETCODE SCIPinitializeHeurListScheduling(SCIP *scip, SCIP_DIGRAPH *precedencegraph, SCIP_VAR **vars, int *durations, int **resourcedemands, int *capacities, int njobs, int nresources)
scheduling specific primal heuristic which is based on bidirectional serial generation scheme.
struct SCIP_File SCIP_FILE
static void checkForNewSection(char *linestr, STATE *state)
static void parseError(SCIP *scip, int lineno, const char *msg, const char *erritem, STATE *state)
SCIP_RETCODE SCIPcreateSchedulingProblem(SCIP *scip, const char *problemname, const char **jobnames, const char **resourcenames, int **demands, SCIP_DIGRAPH *precedencegraph, int *durations, int *capacities, int njobs, int nresources, SCIP_Bool initialize)
SCIP_RETCODE SCIPincludeReaderSm(SCIP *scip)
static int computeUbmakespan(int *durations, int njobs, SCIP_DIGRAPH *precedencegraph)
struct SCIP_RcpspData SCIP_RCPSPDATA
static SCIP_RETCODE getResourcesNames(SCIP *scip, char *linestr, STATE *state, SCIP_RCPSPDATA *rcpspdata)
static SCIP_RETCODE getNJobs(SCIP *scip, int lineno, char *linestr, STATE *state, SCIP_RCPSPDATA *rcpspdata)
static SCIP_RETCODE getNResources(SCIP *scip, int lineno, char *linestr, STATE *state, SCIP_RCPSPDATA *rcpspdata)
static SCIP_RETCODE getPrecedence(SCIP *scip, char *s, STATE *state, SCIP_RCPSPDATA *rcpspdata)
static SCIP_RETCODE readFile(SCIP *scip, const char *filename, SCIP_RCPSPDATA *rcpspdata)
static SCIP_RETCODE getResourcesCapacities(SCIP *scip, char *linestr, STATE *state, SCIP_RCPSPDATA *rcpspdata)
enum reading_states STATE
static SCIP_RETCODE getJobs(SCIP *scip, char *linestr, STATE *state, SCIP_RCPSPDATA *rcpspdata)
scheduling problem file reader for RCPSP format
struct SCIP_ReaderData SCIP_READERDATA
#define SCIP_DECL_READERREAD(x)
#define SCIP_DECL_READERCOPY(x)
enum SCIP_Retcode SCIP_RETCODE