82 vector<vector<int> >& dist
85 static const string DIMENSION =
"DIMENSION";
89 static const string EUC_2D =
"EUC_2D";
90 static const string EXPLICIT =
"EXPLICIT";
95 static const string CAPACITY =
"CAPACITY";
101 cerr <<
"Cannot open file " << filename <<
endl;
124 demand.resize(num_nodes, 0);
125 dist.resize(num_nodes);
126 for (
int i = 0;
i < num_nodes; ++
i)
146 x.resize(num_nodes, 0);
147 y.resize(num_nodes, 0);
163 cerr <<
"Error. Unsupported edge length type." <<
endl;
166 for (
int i = 0;
i < num_nodes; ++
i)
168 for (
int j = 0;
j <
i; ++
j)
183 for (
int i = 0;
i < num_nodes; ++
i)
197 for (
int i = 0;
i < num_nodes; ++
i)
199 for (
int j = 0;
j <
i; ++
j)
209 for (
int i = 0;
i < num_nodes; ++
i)
224 for (
int i = 0;
i != -1 ;)
227 if (
i != -1 &&
i != 1 )
229 cerr <<
"Error: This file specifies other depots than 1." <<
endl;
250 cout <<
"Solving the vehicle routing problem using SCIP." <<
endl;
255 cerr <<
"Usage: vrp [-h] datafile" <<
endl;
257 cerr <<
" -h Uses hop limit instead of capacity limit for tours."<<
endl;
268 vector<vector<int> > dist;
279 cout <<
"Number of nodes: " << num_nodes <<
endl;
283 if (
string(
"-h") !=
argv[1] )
290 for (
int i = 1;
i< num_nodes; ++
i)
295 cerr <<
"Total demand is zero!" <<
endl;
300 demand.assign(num_nodes, 1);
302 cout <<
"Max customers per tour: " << capacity <<
endl <<
endl;
305 cout <<
"Max demand per tour: " << capacity <<
endl <<
endl;
333 vector< vector<SCIP_VAR*> > arc_var( num_nodes );
334 for (
int i = 0;
i < num_nodes; ++
i)
337 for (
int j = 0;
j <
i; ++
j)
359 vector< vector<SCIP_CONS*> > arc_con( num_nodes );
360 for (
int i = 0;
i < num_nodes; ++
i)
363 for (
int j = 0;
j <
i; ++
j)
368 SCIP_Real
coeff = -1;
388 for (
int i = 1;
i < num_nodes; ++
i)
406 for (
int j = 0;
j < num_nodes; ++
j)
418 for (
int i = 1;
i < num_nodes; ++
i)
441 arc_var, arc_con, part_con);
472 for (
int i = 0;
i < num_nodes; ++
i)
478 for (
int j = 0;
j <
i; ++
j)
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
SCIP_RETCODE SCIPcreateConsLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, 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 SCIPfree(SCIP **scip)
SCIP_RETCODE SCIPcreate(SCIP **scip)
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 SCIPprintVersion(SCIP *scip, FILE *file)
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
SCIP_PRICER * SCIPfindPricer(SCIP *scip, const char *name)
SCIP_RETCODE SCIPactivatePricer(SCIP *scip, SCIP_PRICER *pricer)
SCIP_RETCODE SCIPprintBestSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
SCIP_RETCODE SCIPsolve(SCIP *scip)
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
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)
int SCIPsnprintf(char *t, int len, const char *s,...)
int main(int argc, char **argv)
static SCIP_RETCODE execmain(int argc, char **argv)
static int read_problem(const char *filename, int &num_nodes, int &capacity, vector< int > &demand, vector< vector< int > > &dist)
#define BMScheckEmptyMemory()
SCIP_RETCODE SCIPincludeObjPricer(SCIP *scip, scip::ObjPricer *objpricer, SCIP_Bool deleteobject)
C++ wrapper classes for SCIP.
C++ wrapper for default SCIP plugins.
SCIP_RETCODE SCIPincludeDefaultPlugins(SCIP *scip)
enum SCIP_Retcode SCIP_RETCODE