Permalink
Browse files

VPSolver-1.0

  • Loading branch information...
fdabrandao committed Nov 6, 2013
1 parent 73ce9e6 commit a686e177bb9f95de8fa728da30f60a18c7170283
Showing with 294 additions and 39 deletions.
  1. +1 −1 LICENSE
  2. +17 −2 README
  3. +18 −18 example.sh
  4. +15 −0 src/afg2lp.cpp
  5. +15 −0 src/afg2mps.cpp
  6. +15 −15 src/arcflow.cpp
  7. +3 −3 src/arcflow.hpp
  8. +15 −0 src/arcflow_mkp.hpp
  9. +15 −0 src/arcflowsol.cpp
  10. +15 −0 src/arcflowsol.hpp
  11. +15 −0 src/common.hpp
  12. +15 −0 src/gg_afg.cpp
  13. +15 −0 src/graph.cpp
  14. +15 −0 src/graph.hpp
  15. +15 −0 src/instance.cpp
  16. +15 −0 src/instance.hpp
  17. +15 −0 src/solve_glpk.cpp
  18. +15 −0 src/solve_gurobi.cpp
  19. +15 −0 src/vbp2afg.cpp
  20. +15 −0 src/vbpsol.cpp
  21. +15 −0 src/vpsolver.cpp
  22. BIN vpsolver_poster.pdf
View
@@ -1,4 +1,4 @@
Arc-flow vector packing solver (VPSolver)
Arc-flow Vector Packing Solver (VPSolver)
Copyright (C) 2013, Filipe Brandao
Faculdade de Ciencias, Universidade do Porto
View
19 README
@@ -1,9 +1,24 @@
Arc-flow vector packing Solver (VPSolver)
Copyright (C) 2013, Filipe Brandao
Faculdade de Ciencias, Universidade do Porto
Porto, Portugal. All rights reserved. E-mail: <fdabrandao@dcc.fc.up.pt>.
Arc-flow Vector Packing Solver (VPSolver)
--
VPSolver is a vector packing solver based on an arc-flow formulation with graph
compression. VPSolver can generate .mps and .lp files that can be solved using
general-purpose mixed-integer programming solvers such as Gurobi and GLPK.
For more details, please refer to the manual.
--
Proposed in:
Brandão, F. and Pedroso, J. P. (2013).
Bin Packing and Related Problems: General Arc-flow Formulation with Graph Compression.
Technical Report DCC-2013-08, Faculdade de Ciências da Universidade do Porto, Universidade do Porto, Portugal.
--
Requires Gurobi and/or GLPK to solve MIP models.
For more details, please refer to the manual.
--
Filipe Brandao's Homepage: http://www.dcc.fc.up.pt/~fdabrandao/
View
@@ -1,32 +1,32 @@
#!/bin/sh
echo "***************************************"
echo "* Example 1: *"
echp "* > bin/vpsolver example.vbp *"
echo "***************************************"
echo "******************************"
echo "* Example 1: *"
echp "* > bin/vpsolver example.vbp *"
echo "******************************"
bin/vpsolver example.vbp
echo "\n\n"
echo "************************************************"
echo "* Example 2: *"
echo "* > bin/vbp2afg example.vbp graph.afg *"
echo "* > bin/afg2mps graph.afg model.mps *"
echo "* > bin/solve_gurobi model.mps vars.sol *"
echo "* > bin/vbpsol graph.afg vars.sol *"
echo "************************************************"
echo "*****************************************"
echo "* Example 2: *"
echo "* > bin/vbp2afg example.vbp graph.afg *"
echo "* > bin/afg2mps graph.afg model.mps *"
echo "* > bin/solve_gurobi model.mps vars.sol *"
echo "* > bin/vbpsol graph.afg vars.sol *"
echo "*****************************************"
bin/vbp2afg example.vbp graph.afg
bin/afg2mps graph.afg model.mps
bin/solve_gurobi model.mps vars.sol
bin/vbpsol graph.afg vars.sol
echo "\n\n"
echo "************************************************"
echo "* Example 3: *"
echo "* > bin/vbp2afg example.vbp graph.afg *"
echo "* > bin/afg2lp graph.afg model.lp *"
echo "* > bin/solve_glpk model.lp vars.sol *"
echo "* > bin/vbpsol graph.afg vars.sol *"
echo "************************************************"
echo "***************************************"
echo "* Example 3: *"
echo "* > bin/vbp2afg example.vbp graph.afg *"
echo "* > bin/afg2lp graph.afg model.lp *"
echo "* > bin/solve_glpk model.lp vars.sol *"
echo "* > bin/vbpsol graph.afg vars.sol *"
echo "***************************************"
bin/vbp2afg example.vbp graph.afg
bin/afg2lp graph.afg model.lp
bin/solve_glpk model.lp vars.sol
View
@@ -1,7 +1,22 @@
/**
This code is part of the Arc-flow Vector Packing Solver (VPSolver).
Copyright (C) 2013, Filipe Brandao
Faculdade de Ciencias, Universidade do Porto
Porto, Portugal. All rights reserved. E-mail: <fdabrandao@dcc.fc.up.pt>.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#include <cstdio>
#include <cassert>
View
@@ -1,7 +1,22 @@
/**
This code is part of the Arc-flow Vector Packing Solver (VPSolver).
Copyright (C) 2013, Filipe Brandao
Faculdade de Ciencias, Universidade do Porto
Porto, Portugal. All rights reserved. E-mail: <fdabrandao@dcc.fc.up.pt>.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#include <cstdio>
#include <cassert>
View
@@ -1,5 +1,5 @@
/**
This code is part of the Arc-flow vector packing solver.
This code is part of the Arc-flow Vector Packing Solver (VPSolver).
Copyright (C) 2013, Filipe Brandao
Faculdade de Ciencias, Universidade do Porto
@@ -42,14 +42,14 @@ Arcflow::Arcflow(const Instance &inst){
binary = inst.binary;
int method = inst.method;
st_mat.assign(m+1, vector<int>(ndims, 0));
ls_mat.assign(m+1, vector<int>(ndims, 0));
const vector<int> &r = max_rep(vector<int>(ndims, 0), 0, 0);
for(int i = 0; i < m; i++){
int next = binary ? i+1 : i;
for(int j = next; j < m; j++){
if(is_compatible(items[i], items[j])){
for(int d = 0; d < ndims; d++)
st_mat[i][d] = min(st_mat[i][d]+r[j]*items[j][d], W[d]);
ls_mat[i][d] = min(ls_mat[i][d]+r[j]*items[j][d], W[d]);
}
}
}
@@ -212,7 +212,7 @@ void Arcflow::build(){
for(int d = 0; d < ndims; d++) lv[d] += items[i][d];
if(binary) lv[ndims] = i;
if(!is_valid(lv)) break;
lift_node(lv, i, c+1);
lift_state(lv, i, c+1);
int v = NS.get_index(lv);
assert(u != v);
A.push_back(Arc(u, v, i));
@@ -230,26 +230,26 @@ void Arcflow::build(){
NS.sort();
}
void Arcflow::lift_node(vector<int> &u, int it, int ic) const{
void Arcflow::lift_state(vector<int> &u, int it, int ic) const{
for(int d = 0; d < ndims; d++){
// stretch 1
// lift method 1
if(ic > 0)
u[d] = max(u[d], W[d]-st_mat[it][d]);
u[d] = max(u[d], W[d]-ls_mat[it][d]);
else if(it > 0)
u[d] = max(u[d], W[d]-st_mat[it-1][d]);
}
u[d] = max(u[d], W[d]-ls_mat[it-1][d]);
}
const vector<int> &r = max_rep(u, it, ic);
for(int d = 0; d < ndims; d++){
if(u[d] < W[d]){
// stretch 2
// lift method 2
int val = W[d];
for(int t = it; t < m && val >= u[d]; t++)
val -= r[t]*items[t][d];
if(val >= u[d]){
u[d] = val;
}else if(W[d]-u[d] > 0){
// stretch 3
// lift method 3
u[d] = W[d]-knapsack(r, it, d, W[d]-u[d]);
}
}
@@ -322,17 +322,17 @@ int Arcflow::go(const vector<int> &su){
if(binary){
sv[ndims] = it+1;
if(it+1 < m)
lift_node(sv, it+1, 0);
lift_state(sv, it+1, 0);
iv = go(sv);
}else{
if(ic+1 < dem){
sv[ndims] = it;
sv[ndims+1] = ic+1;
lift_node(sv, it, ic+1);
lift_state(sv, it, ic+1);
}else{
sv[ndims] = it+1;
sv[ndims+1] = 0;
lift_node(sv, it+1, 0);
lift_state(sv, it+1, 0);
}
iv = go(sv);
}
@@ -355,7 +355,7 @@ int Arcflow::go(const vector<int> &su){
void Arcflow::build_dp(){
dp.clear();
A.clear();
NS.clear();
NS.clear();
if(binary)
go(vector<int>(lsize, 0));
View
@@ -1,5 +1,5 @@
/**
This code is part of the Arc-flow vector packing solver.
This code is part of the Arc-flow Vector Packing Solver (VPSolver).
Copyright (C) 2013, Filipe Brandao
Faculdade de Ciencias, Universidade do Porto
@@ -46,7 +46,7 @@ class Arcflow{
vector<int> stretch2;
vector<int> stretch3;
bool bstretch;
vector<vector<int> > st_mat;
vector<vector<int> > ls_mat;
int lsize;
protected:
bool ready;
@@ -59,7 +59,7 @@ class Arcflow{
vector<Arc> A;
vector<int> max_rep(const vector<int> &u, int i0, int sub_i0) const;
void lift_node(vector<int> &u, int it, int ic) const;
void lift_state(vector<int> &u, int it, int ic) const;
int knapsack(const vector<int> &b, int i0, int d, int C) const;
bool is_valid(const vector<int> &u) const;
bool is_compatible(const Item &a, const Item &b) const;
View
@@ -1,7 +1,22 @@
/**
This code is part of the Arc-flow Vector Packing Solver (VPSolver).
Copyright (C) 2013, Filipe Brandao
Faculdade de Ciencias, Universidade do Porto
Porto, Portugal. All rights reserved. E-mail: <fdabrandao@dcc.fc.up.pt>.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef _ARCFLOW_MKP_HPP_
#define _ARCFLOW_MKP_HPP_
View
@@ -1,7 +1,22 @@
/**
This code is part of the Arc-flow Vector Packing Solver (VPSolver).
Copyright (C) 2013, Filipe Brandao
Faculdade de Ciencias, Universidade do Porto
Porto, Portugal. All rights reserved. E-mail: <fdabrandao@dcc.fc.up.pt>.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#include <set>
#include <climits>
View
@@ -1,7 +1,22 @@
/**
This code is part of the Arc-flow Vector Packing Solver (VPSolver).
Copyright (C) 2013, Filipe Brandao
Faculdade de Ciencias, Universidade do Porto
Porto, Portugal. All rights reserved. E-mail: <fdabrandao@dcc.fc.up.pt>.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef _ARCFLOWSOL_HPP_
#define _ARCFLOWSOL_HPP_
View
@@ -1,7 +1,22 @@
/**
This code is part of the Arc-flow Vector Packing Solver (VPSolver).
Copyright (C) 2013, Filipe Brandao
Faculdade de Ciencias, Universidade do Porto
Porto, Portugal. All rights reserved. E-mail: <fdabrandao@dcc.fc.up.pt>.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef _COMMON_HPP_
#define _COMMON_HPP_
View
@@ -1,7 +1,22 @@
/**
This code is part of the Arc-flow Vector Packing Solver (VPSolver).
Copyright (C) 2013, Filipe Brandao
Faculdade de Ciencias, Universidade do Porto
Porto, Portugal. All rights reserved. E-mail: <fdabrandao@dcc.fc.up.pt>.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#include <cstdio>
#include <cassert>
View
@@ -1,7 +1,22 @@
/**
This code is part of the Arc-flow Vector Packing Solver (VPSolver).
Copyright (C) 2013, Filipe Brandao
Faculdade de Ciencias, Universidade do Porto
Porto, Portugal. All rights reserved. E-mail: <fdabrandao@dcc.fc.up.pt>.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#include <set>
#include <climits>
Oops, something went wrong.

0 comments on commit a686e17

Please sign in to comment.