From d91b9bafc15ec695ee1138706048720a31f01374 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Tue, 31 Dec 2013 14:37:02 +0100 Subject: [PATCH 01/16] Really, really simple test instance added --- data/t01.dat | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 data/t01.dat diff --git a/data/t01.dat b/data/t01.dat new file mode 100644 index 0000000..aa8dfdd --- /dev/null +++ b/data/t01.dat @@ -0,0 +1,14 @@ +6 +12 +0 0 1 0 +1 0 2 0 +2 0 3 0 +3 0 4 0 +4 0 5 0 +5 1 2 1 +6 1 4 1 +7 1 5 100 +8 2 3 100 +9 2 5 1 +10 3 4 100 +11 3 5 1 From 153e18131e70c77c372c746364c9dcdc7d78f6c8 Mon Sep 17 00:00:00 2001 From: Dino Rossegger Date: Tue, 31 Dec 2013 16:22:39 +0100 Subject: [PATCH 02/16] mcf --- doc/document.tex | 19 +++- src/kMST_ILP.cpp | 219 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 232 insertions(+), 6 deletions(-) diff --git a/doc/document.tex b/doc/document.tex index d72abd7..5192a7f 100644 --- a/doc/document.tex +++ b/doc/document.tex @@ -73,6 +73,23 @@ \section{SCF Formulation} f_{i,j}\leq kx_{i,j} \end{align} -\end{document} +\section{MCF Formulation} +\begin{equation} + \min \sum_{i>0}{ \sum_{j>0,j\not =i}{x_{ij}c_{ij}}} +\end{equation} +\begin{align} + \sum_{(i,j)} x_{ij} = k\\ + \sum_{i>0}v_i =k \\ + \sum_{j>0} x_{0j}=1\\ + x_{ij} \leq v_i\\ + x_{ij} \leq v_i\\ + v_i + x_{ij} + x_{ji} \leq v_j + 1\\ + \sum_{j>0} f_{0j}^l \leq 1 \quad \forall l\in N\setminus\{0\}\\ + \sum_{i,i\not =l} f_{il}^l \leq 1 \quad \forall l\in N\setminus\{0\}\\ + 0\leq f_{ij}^l \leq x_{i,j}\\ + \sum_{i,i\not = j}f_{ij}^l - \sum_{i,i\not = j} f_{ji}^l =0 \quad \forall j, l\in N\setminus\{0\}, j\not =l \\ + \sum_{l=1}^N \sum_{(i,l)} f_{i,l}^l =k +\end{align} +\end{document} diff --git a/src/kMST_ILP.cpp b/src/kMST_ILP.cpp index 5386a98..1790c83 100644 --- a/src/kMST_ILP.cpp +++ b/src/kMST_ILP.cpp @@ -27,7 +27,7 @@ void kMST_ILP::solve() // build model cplex = IloCplex( model ); // export model to a text file - //cplex.exportModel( "model.lp" ); + cplex.exportModel( "model.lp" ); // set parameters setCPLEXParameters(); @@ -129,7 +129,7 @@ void kMST_ILP::modelSCF() //(4) IloExpr co4(env); for (int i=0;i f(env,n-1); + //IloIntVar f[n][2*m]; + for(int l=0;l::iterator it=instance.incidentEdges.at(j).begin();it!=instance.incidentEdges.at(j).end();it++){ + if(instance.edges.at(*it).v1==j){ + co33+=f[l][*it+m]; + co33-=f[l][*it]; + } + else if(instance.edges.at(*it).v2==j){ + co33+=f[l][*it]; + co33-=f[l][*it +m ]; + } + + } + model.add(co33==0); + co33.end(); + + } + } + + + //34 + IloExpr co34(env); + for (int l=0;l Date: Wed, 8 Jan 2014 15:22:06 +0100 Subject: [PATCH 03/16] mcf infeasible --- doc/document.tex | 12 ++-- src/kMST_ILP.cpp | 155 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 125 insertions(+), 42 deletions(-) diff --git a/doc/document.tex b/doc/document.tex index 5192a7f..7076245 100644 --- a/doc/document.tex +++ b/doc/document.tex @@ -6,14 +6,14 @@ \usepackage{amsmath} \usepackage{amsthm} \usepackage{amssymb} - +\numberwithin{equation}{section} \title{Algorithmics WS13/14, Programming Exercise} \author{Dino Rossegger, Markus Scherer} \date{\today} \begin{document} \maketitle \section{MTZ Formulation} -Let $x_{ij}=1$ if $e_{ij}\in E$ is in the Spanning Tree, else $x_{ij}=0$. Since the graph is undirected, for every edge there are to $x$, $x_ij$ and $x_ji$. The objective function is the same as in the other formulations +Let $x_{ij}=1$ if $e_{ij}\in E$ is in the Spanning Tree, else $x_{ij}=0$. Since the graph is undirected, for every edge there are to $x$, $x_{ij}$ and $x_{ji}$. The objective function is the same as in the other formulations \begin{equation} \min{\sum_i \sum_{j\not=i} c_{ij}x_{ij}} \end{equation} @@ -81,14 +81,18 @@ \section{MCF Formulation} \sum_{(i,j)} x_{ij} = k\\ \sum_{i>0}v_i =k \\ \sum_{j>0} x_{0j}=1\\ + \sum_{i>0} x_{i0}=0\\ x_{ij} \leq v_i\\ - x_{ij} \leq v_i\\ + x_{ij} \leq v_j\\ v_i + x_{ij} + x_{ji} \leq v_j + 1\\ \sum_{j>0} f_{0j}^l \leq 1 \quad \forall l\in N\setminus\{0\}\\ \sum_{i,i\not =l} f_{il}^l \leq 1 \quad \forall l\in N\setminus\{0\}\\ 0\leq f_{ij}^l \leq x_{i,j}\\ \sum_{i,i\not = j}f_{ij}^l - \sum_{i,i\not = j} f_{ji}^l =0 \quad \forall j, l\in N\setminus\{0\}, j\not =l \\ - \sum_{l=1}^N \sum_{(i,l)} f_{i,l}^l =k + \sum_{j\not=l} f_{l,j}^l =0\\ + \sum_{(i,l)} f_{i,l}^l - v_l=0 \quad \forall l\in N\setminus\{0\} \\ + \sum_{l=1}^N \sum_{(0,j)} f_{0,j}^l = k\\ + \sum_{(0,j)} f_{0,j}^l -v_l = 0 \quad \forall l\in N\setminus\{0\} \end{align} \end{document} diff --git a/src/kMST_ILP.cpp b/src/kMST_ILP.cpp index 1790c83..2d052f7 100644 --- a/src/kMST_ILP.cpp +++ b/src/kMST_ILP.cpp @@ -41,6 +41,7 @@ void kMST_ILP::solve() cout << "CPU time: " << Tools::CPUtime() << "\n\n"; printX(); cout << "Solution is " << (isTree() ? "valid" : "invalid") << "\n\n"; + cplex.writeSolution("solution.lp"); } catch( IloException& e ) { cerr << "kMST_ILP: exception " << e << "\n"; @@ -234,7 +235,19 @@ void kMST_ILP::modelSCF() co11_2.end(); } - cout << model << endl; + // add + /* + for (int i=0;i f(env,n-1); + IloArray f(env,n); //IloIntVar f[n][2*m]; - for(int l=0;l::iterator it=instance.incidentEdges.at(j).begin();it!=instance.incidentEdges.at(j).end();it++){ - if(instance.edges.at(*it).v1==j){ + if(instance.edges.at(*it).v1==j && j!=l){ co33+=f[l][*it+m]; co33-=f[l][*it]; } - else if(instance.edges.at(*it).v2==j){ + else if(instance.edges.at(*it).v2==j && j!=l){ co33+=f[l][*it]; co33-=f[l][*it +m ]; } + else + dontadd=true; } - model.add(co33==0); + if(!dontadd)model.add(co33==0); co33.end(); } } + //(3.13) + for (int l=1;l::iterator it=instance.incidentEdges.at(l).begin();it!=instance.incidentEdges.at(l).end();it++){ + if(instance.edges.at(*it).v1==l){ + co34+=f[l][*it]; + } + else if(instance.edges.at(*it).v2==l){ + co34+=f[l][*it+m]; + } + } + model.add(co34 ==0); + co34.end(); + } + - //34 - IloExpr co34(env); - for (int l=0;l::iterator it=instance.incidentEdges.at(0).begin();it!=instance.incidentEdges.at(0).end();it++){ + co+=f[l][*it]; + } + model.add(co - v[l]==0); + co.end(); + } + + cout << model << endl; } void kMST_ILP::modelMTZ() @@ -474,11 +547,11 @@ void kMST_ILP::modelMTZ() c[i+m]=instance.edges.at(i).weight; } //u - IloIntVarArray u(env, n); + IloNumVarArray u(env, n); for(int i=0;i Date: Thu, 9 Jan 2014 15:00:24 +0100 Subject: [PATCH 04/16] commenting 3.13 makes it feasible for 1 --- doc/document.tex | 4 +++- src/kMST_ILP.cpp | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/doc/document.tex b/doc/document.tex index 7076245..acd09db 100644 --- a/doc/document.tex +++ b/doc/document.tex @@ -91,8 +91,10 @@ \section{MCF Formulation} \sum_{i,i\not = j}f_{ij}^l - \sum_{i,i\not = j} f_{ji}^l =0 \quad \forall j, l\in N\setminus\{0\}, j\not =l \\ \sum_{j\not=l} f_{l,j}^l =0\\ \sum_{(i,l)} f_{i,l}^l - v_l=0 \quad \forall l\in N\setminus\{0\} \\ + \sum_{l=1}^N \sum_{(i,l)} f_{i,l}^l = k\\ \sum_{l=1}^N \sum_{(0,j)} f_{0,j}^l = k\\ - \sum_{(0,j)} f_{0,j}^l -v_l = 0 \quad \forall l\in N\setminus\{0\} + \sum_{(0,j)} f_{0,j}^l -v_l = 0 \quad \forall l\in N\setminus\{0\}\\ + x_{ij} \leq \sum_{l=1}^N f_{ij}^l \end{align} \end{document} diff --git a/src/kMST_ILP.cpp b/src/kMST_ILP.cpp index 2d052f7..35975b4 100644 --- a/src/kMST_ILP.cpp +++ b/src/kMST_ILP.cpp @@ -335,6 +335,7 @@ void kMST_ILP::modelMCF() co4.end(); co5.end(); + //(3.6),(3.7) for (int k=0;k::iterator it=instance.incidentEdges.at(l).begin();it!=instance.incidentEdges.at(l).end();it++){ + if(instance.edges.at(*it).v1==l && instance.edges.at(*it).v2!=l){ + co+=f[l][*it+m]; + } + else if(instance.edges.at(*it).v2==l && instance.edges.at(*it).v1!=l){ + co+=f[l][*it]; + } + + } + } + model.add(co==k); + co.end(); + //(3.16) IloExpr co_35(env); for (int l=1;l::iterator it=instance.incidentEdges.at(0).begin();it!=instance.incidentEdges.at(0).end();it++){ @@ -521,9 +536,20 @@ void kMST_ILP::modelMCF() model.add(co - v[l]==0); co.end(); } + //(3.18) + for(int k=0;k=x[k]); + model.add(co_1>=x[k+m]); + co_0.end(); + co_1.end(); + } - - cout << model << endl; } void kMST_ILP::modelMTZ() From 24aa0082c1de7128abba1b5e6fa8cf1d44c5cc82 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Sat, 11 Jan 2014 14:52:10 +0100 Subject: [PATCH 05/16] Fixed mcf --- src/kMST_ILP.cpp | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/kMST_ILP.cpp b/src/kMST_ILP.cpp index 35975b4..856c6a1 100644 --- a/src/kMST_ILP.cpp +++ b/src/kMST_ILP.cpp @@ -403,23 +403,26 @@ void kMST_ILP::modelMCF() for(int i=0;i::iterator it=instance.incidentEdges.at(j).begin();it!=instance.incidentEdges.at(j).end();it++){ @@ -435,7 +438,9 @@ void kMST_ILP::modelMCF() dontadd=true; } - if(!dontadd)model.add(co33==0); + if(!dontadd) { + model.add(co33==0); + } co33.end(); } @@ -537,19 +542,29 @@ void kMST_ILP::modelMCF() co.end(); } //(3.18) - for(int k=0;k=x[k]); - model.add(co_1>=x[k+m]); + for(int l=1;l=x_ij); + model.add(co_1>=x_ji); co_0.end(); co_1.end(); + + x_ij.end(); + x_ji.end(); } + //cout << model; } void kMST_ILP::modelMTZ() From f225c6fee292220903a132a5ebb65e2227a9ce40 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Sun, 12 Jan 2014 15:48:21 +0100 Subject: [PATCH 06/16] Fixed tree checker --- src/kMST_ILP.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kMST_ILP.cpp b/src/kMST_ILP.cpp index 856c6a1..2894344 100644 --- a/src/kMST_ILP.cpp +++ b/src/kMST_ILP.cpp @@ -740,8 +740,8 @@ bool kMST_ILP::isTree() { for(int i=0;i Date: Thu, 16 Jan 2014 10:39:13 +0100 Subject: [PATCH 07/16] blabla merge, ole --- src/kMST_ILP.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/kMST_ILP.cpp b/src/kMST_ILP.cpp index 856c6a1..148c2d7 100644 --- a/src/kMST_ILP.cpp +++ b/src/kMST_ILP.cpp @@ -39,7 +39,7 @@ void kMST_ILP::solve() cout << "Branch-and-Bound nodes: " << cplex.getNnodes() << "\n"; cout << "Objective value: " << cplex.getObjValue() << "\n"; cout << "CPU time: " << Tools::CPUtime() << "\n\n"; - printX(); + //printX(); cout << "Solution is " << (isTree() ? "valid" : "invalid") << "\n\n"; cplex.writeSolution("solution.lp"); } @@ -84,15 +84,15 @@ void kMST_ILP::modelSCF() c[i+m]=instance.edges.at(i).weight; } //f - IloIntVarArray f(env,2*m); + IloNumVarArray f(env,2*m); for(int i=0;i Date: Thu, 16 Jan 2014 13:26:54 +0100 Subject: [PATCH 08/16] Somehow it runs faster now --- src/kMST_ILP.cpp | 78 +++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/src/kMST_ILP.cpp b/src/kMST_ILP.cpp index 71584f6..122fc3f 100644 --- a/src/kMST_ILP.cpp +++ b/src/kMST_ILP.cpp @@ -337,7 +337,7 @@ void kMST_ILP::modelMCF() - //(3.6),(3.7) + //(3.6),(3.7) for (int k=0;k Date: Fri, 17 Jan 2014 16:02:04 +0100 Subject: [PATCH 09/16] Made scf faster --- src/kMST_ILP.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kMST_ILP.cpp b/src/kMST_ILP.cpp index 122fc3f..31a51ce 100644 --- a/src/kMST_ILP.cpp +++ b/src/kMST_ILP.cpp @@ -213,7 +213,7 @@ void kMST_ILP::modelSCF() co10_2 += f[*it]; } } - model.add(co10_1 == IloMin(1,co10_2)); + model.add(co10_1 == v[i]); co10_1.end(); co10_2.end(); From b713f94edfadcf6cf77a707b59fa104166b3bdc1 Mon Sep 17 00:00:00 2001 From: Dino Rossegger Date: Sat, 18 Jan 2014 13:19:55 +0100 Subject: [PATCH 10/16] document --- doc/document.tex | 99 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 75 insertions(+), 24 deletions(-) diff --git a/doc/document.tex b/doc/document.tex index acd09db..624e707 100644 --- a/doc/document.tex +++ b/doc/document.tex @@ -12,14 +12,25 @@ \date{\today} \begin{document} \maketitle -\section{MTZ Formulation} -Let $x_{ij}=1$ if $e_{ij}\in E$ is in the Spanning Tree, else $x_{ij}=0$. Since the graph is undirected, for every edge there are to $x$, $x_{ij}$ and $x_{ji}$. The objective function is the same as in the other formulations +\section{General} +A artificial root vertex $0$ was introduced in the graphs which edges going to all other nodes and the cost function $c_{0j}=0\quad \forall j\in V$. Since the formulations work with directed graphs for every undirected edge $e$, two new edges where introduced, $e_{ij}$ and $e_{ji}$ denoting the corresponding arcs. +For all Formulations the same objective function was used. $c_{ij}$ denoting the cost function of the arc and $x_{ij}$ being $1$ if the arc is chosen or $0$ otherwise. \begin{equation} \min{\sum_i \sum_{j\not=i} c_{ij}x_{ij}} +\end{equation} +$c_{ij}$ denoting the cost function of the arc and $x_{ij}$ being $1$ if the arc is chosen or $0$ otherwise. Therefore a constraint limiting the values $x$ can take was used. +\begin{equation} + x_{ij} \in \{0,1\} \qquad \forall (i,j) +\end{equation} +To tighten the constraints, an additional variable $v_i$ was introduced, being $1$ if vertex $i$ is selected and $0$ otherwise. +\begin{equation} + v_i \in\{0,1\} \qquad \forall i=0,\dots,n \end{equation} + +\section{MTZ Formulation} For the Miller-Tucker-Zemlin formulation an order $u_i$ is introduced, it ensures that there is no cycle. \begin{equation} -x_{ij} + u_i \leq u_j + k*(1-x_{ij}) \quad \forall i,j=0,\dots,n +x_{ij} + u_i \leq u_j + k*(1-x_{ij}) \qquad \forall (i,j) \end{equation} The start vertex must be the artificial vertex $0$. \begin{equation} @@ -35,13 +46,12 @@ \section{MTZ Formulation} \end{equation} By the tree property $n=m+1$ the number of edges in the tree must be $k$. \begin{equation} - \sum_{i\geq0} \sum_{j\geq0,j\not =i} x_{ij} = k + \sum_{(i,j)} x_{ij} = k \end{equation} Since there is an order, we are talking about arcs and for every vertex there must be at most one incoming arc. \begin{equation} - \sum_{i>0} x_{ij}\leq 1 \quad \forall j=1,\dots,n + \sum_{i>0} x_{ij}\leq 1 \qquad \forall j=1,\dots,n \end{equation} -Let $v_i=1$ if vertex $i \in k-MST$ and $0$ otherwise. The number of vertices in the tree must be $k$. \begin{equation} \sum_{i>0}v_i=k @@ -56,27 +66,43 @@ \section{MTZ Formulation} x_{ij} &\leq u_j \end{align} \section{SCF Formulation} -For every edge $e \in E$ two arcs are introduced. $x_ij$ is $1$ if it is in the MST, $0$ otherwise. +There must be $k$ arcs in the tree (including arc from $0$) \begin{equation} - \min \sum_{i>0}{ \sum_{j>0,j\not =i}{x_{ij}c_{ij}}} + \sum_{(i,j)} x_{ij} = k \end{equation} -\begin{align} - \sum_{(i,j)} x_{ij} = k\\ +The number of vertices in the tree must be $k$ ($0$ not included) +\begin{equation} \sum_{i>0}v_i =k \\ +\end{equation} +There must be exactly $1$ arc goint out of $0$ in the solution +\begin{equation} \sum_{j>0} x_{0j}=1\\ +\end{equation} +If an arc is selected, vertices incident to it must be selected too +\begin{equation} x_{ij} \leq v_i\\ x_{ij} \leq v_j\\ +\end{equation} +There can be either a forward or a backward arc in the solution, not both. +\begin{equation} v_i + x_{ij} + x_{ji} \leq v_j + 1\\ +\end{equation} +The flow must be at most $k$, and at least $0$ +\begin{equation} 0 \leq f_{ij} \leq k\\ \sum_{j>0} f_{0j}=k \\ +\end{equation} +Every vertex in the solution consumes $1$ flow. +\begin{equation} \sum_{(i,j)} f_{ij} - \sum_{(j,i)} f_{ji} = 1\\ +\end{equation} +The flow going through an arc can be at most $k$. +\begin{equation} f_{i,j}\leq kx_{i,j} -\end{align} +\end{equation} \section{MCF Formulation} -\begin{equation} - \min \sum_{i>0}{ \sum_{j>0,j\not =i}{x_{ij}c_{ij}}} -\end{equation} +Most of the constraints are the same as in the single commodity flow formulation. \begin{align} \sum_{(i,j)} x_{ij} = k\\ \sum_{i>0}v_i =k \\ @@ -85,17 +111,42 @@ \section{MCF Formulation} x_{ij} \leq v_i\\ x_{ij} \leq v_j\\ v_i + x_{ij} + x_{ji} \leq v_j + 1\\ - \sum_{j>0} f_{0j}^l \leq 1 \quad \forall l\in N\setminus\{0\}\\ - \sum_{i,i\not =l} f_{il}^l \leq 1 \quad \forall l\in N\setminus\{0\}\\ - 0\leq f_{ij}^l \leq x_{i,j}\\ - \sum_{i,i\not = j}f_{ij}^l - \sum_{i,i\not = j} f_{ji}^l =0 \quad \forall j, l\in N\setminus\{0\}, j\not =l \\ - \sum_{j\not=l} f_{l,j}^l =0\\ - \sum_{(i,l)} f_{i,l}^l - v_l=0 \quad \forall l\in N\setminus\{0\} \\ - \sum_{l=1}^N \sum_{(i,l)} f_{i,l}^l = k\\ - \sum_{l=1}^N \sum_{(0,j)} f_{0,j}^l = k\\ - \sum_{(0,j)} f_{0,j}^l -v_l = 0 \quad \forall l\in N\setminus\{0\}\\ - x_{ij} \leq \sum_{l=1}^N f_{ij}^l \end{align} +The commodities going out of vertex $0$ can be at most $1$ each and the sum of all commodities must be $k$. +\begin{equation} + \sum_{j>0} f_{0j}^l \leq 1 \qquad \forall l\in [1,n]\\ + \sum_{l=1}^n \sum_{(0,j)} f_{0,j}^l = k\\ +\end{equation} +The sum of flows on commodity $l$ flowing into vertex $l$ is at most $1$. +\begin{equation} +\sum_{i,i\not =l} f_{il}^l \leq 1 \qquad \forall l\in [1,n]\\ +\end{equation} +If there is a flow on an arc, the arc must be selected. +\begin{equation} +0\leq f_{ij}^l \leq x_{i,j} \qquad \forall (i,j), \forall l \in [0,n] +\end{equation} +All vertices which are not the target of the commodity can not consume a flow. +\begin{equation} +\sum_{i,i\not = j}f_{ij}^l - \sum_{i,i\not = j} f_{ji}^l =0 \qquad \forall j, l\in [1,n], j\not =l \\ +\end{equation} +If $l$ is target of some flow, the outgoing flow on its commodity must be $0$ +\begin{equation} +\sum_{j\not=l} f_{l,j}^l =0\\ +\end{equation} +If there is flow incoming to vertex $l$ on its commodity, the vertex must be selected +\begin{equation} +\sum_{(i,l)} f_{i,l}^l - v_l=0 \qquad \forall l\in [1,n], i\in[0,n]\\ +\end{equation} +The sum of flows on all commodities must be $k$ +\begin{equation} + \sum_{l=1}^n \sum_{(i,l)} f_{i,l}^l = k\\ +\end{equation} + +% \sum_{(0,j)} f_{0,j}^l -v_l = 0 \quad \forall l\in N\setminus\{0\}\\ +If an arc is selected, there must be a flow on the arc. +\begin{equation} +x_{ij} \leq \sum_{l=1}^n f_{ij}^l +\end{equation} \end{document} From a4c3fcf2471eb42225c2016c1bf2ddf89f8d7f04 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Sat, 18 Jan 2014 13:47:20 +0100 Subject: [PATCH 11/16] Changes to document and MCF Formulation --- doc/document.tex | 4 ++++ doc/results.tex | 30 ++++++++++++++++++++++++++++++ src/kMST_ILP.cpp | 7 +++++-- 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 doc/results.tex diff --git a/doc/document.tex b/doc/document.tex index 624e707..708cc30 100644 --- a/doc/document.tex +++ b/doc/document.tex @@ -6,6 +6,7 @@ \usepackage{amsmath} \usepackage{amsthm} \usepackage{amssymb} +\usepackage{multirow} \numberwithin{equation}{section} \title{Algorithmics WS13/14, Programming Exercise} \author{Dino Rossegger, Markus Scherer} @@ -148,5 +149,8 @@ \section{MCF Formulation} x_{ij} \leq \sum_{l=1}^n f_{ij}^l \end{equation} +\section{Results} +\input{results.tex} + \end{document} diff --git a/doc/results.tex b/doc/results.tex new file mode 100644 index 0000000..bda4478 --- /dev/null +++ b/doc/results.tex @@ -0,0 +1,30 @@ + +\begin{tabular}{ l l l l l l l l l} + \multicolumn{2}{c}{} & \multicolumn{2}{c}{\textbf{MTZ}} & \multicolumn{2}{c}{\textbf{SCF}} & \multicolumn{2}{c}{\textbf{MCF}} & \textbf{Optimal Value}\\ + & k & time [s] & nodes & times [s] & nodes & time [s] & nodes & \\ + \hline + \multirow{2}{*}{g01} & 2 & & & & & & & \\ + & 5 & & & & & & & \\ + \hline + \multirow{2}{*}{g02} & 4 & & & & & & & \\ + & 10 & & & & & & & \\ + \hline + \multirow{2}{*}{g03} & 10 & & & & & & & \\ + & 25 & & & & & & & \\ + \hline + \multirow{2}{*}{g04} & 14 & & & & & & & \\ + & 35 & & & & & & & \\ + \hline + \multirow{2}{*}{g05} & 20 & & & & & & & \\ + & 50 & & & & & & & \\ + \hline + \multirow{2}{*}{g06} & 40 & & & & & & & \\ + & 100 & & & & & & & \\ + \hline + \multirow{2}{*}{g07} & 60 & & & & & & & \\ + & 150 & & & & & & & \\ + \hline + \multirow{2}{*}{g08} & 80 & & & & & & & \\ + & 200 & & & & & & & \\ + \hline +\end{tabular} diff --git a/src/kMST_ILP.cpp b/src/kMST_ILP.cpp index 31a51ce..bbbfeb1 100644 --- a/src/kMST_ILP.cpp +++ b/src/kMST_ILP.cpp @@ -388,9 +388,9 @@ void kMST_ILP::modelMCF() co3_10+=f[l][i+m]; } } - model.add(co3_9 <= 1); + model.add(co3_9 <= v[l]); //model.add(co3_10==co3_9); - model.add(co3_10<=1); + model.add(co3_10<=v[l]); co3_9.end(); co3_10.end(); } @@ -496,6 +496,7 @@ void kMST_ILP::modelMCF() co35_1.end(); }*/ //(3.15) + IloExpr co(env); for (int l=1;l::iterator it=instance.incidentEdges.at(l).begin();it!=instance.incidentEdges.at(l).end();it++){ @@ -510,6 +511,7 @@ void kMST_ILP::modelMCF() } model.add(co==k); co.end(); + //(3.16) IloExpr co_35(env); for (int l=1;l Date: Sat, 18 Jan 2014 15:59:08 +0100 Subject: [PATCH 12/16] reconciled SCF formulation in document with the one the program --- doc/document.tex | 11 ++++++++--- src/kMST_ILP.cpp | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/doc/document.tex b/doc/document.tex index 708cc30..46db5c2 100644 --- a/doc/document.tex +++ b/doc/document.tex @@ -73,15 +73,17 @@ \section{SCF Formulation} \end{equation} The number of vertices in the tree must be $k$ ($0$ not included) \begin{equation} - \sum_{i>0}v_i =k \\ + \sum_{i \geq 1}v_i =k \\ \end{equation} There must be exactly $1$ arc goint out of $0$ in the solution \begin{equation} - \sum_{j>0} x_{0j}=1\\ + \sum_{j \geq 1} x_{0j}=1\\ \end{equation} If an arc is selected, vertices incident to it must be selected too \begin{equation} x_{ij} \leq v_i\\ +\end{equation} +\begin{equation} x_{ij} \leq v_j\\ \end{equation} There can be either a forward or a backward arc in the solution, not both. @@ -91,11 +93,14 @@ \section{SCF Formulation} The flow must be at most $k$, and at least $0$ \begin{equation} 0 \leq f_{ij} \leq k\\ +\end{equation} +Exactly $k$ units of flow are sent out from node $0$. +\begin{equation} \sum_{j>0} f_{0j}=k \\ \end{equation} Every vertex in the solution consumes $1$ flow. \begin{equation} - \sum_{(i,j)} f_{ij} - \sum_{(j,i)} f_{ji} = 1\\ + \forall j \in V \hspace{30pt} \sum_{(i,j)} f_{ij} - \sum_{(j,i)} f_{ji} = v_j\\ \end{equation} The flow going through an arc can be at most $k$. \begin{equation} diff --git a/src/kMST_ILP.cpp b/src/kMST_ILP.cpp index bbbfeb1..5f7805c 100644 --- a/src/kMST_ILP.cpp +++ b/src/kMST_ILP.cpp @@ -102,7 +102,7 @@ void kMST_ILP::modelSCF() v[i] = IloBoolVar(env, myname.str().c_str()); } - //objective function (1) + //objective function (1.1) IloExpr objfunc(env); for (int i=0;i Date: Sun, 19 Jan 2014 10:41:52 +0100 Subject: [PATCH 13/16] reconciled MTZ formulation in document with the one the program --- doc/document.tex | 18 ++++++++++++++---- src/kMST_ILP.cpp | 24 ++++++++++++------------ 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/doc/document.tex b/doc/document.tex index 46db5c2..31af36d 100644 --- a/doc/document.tex +++ b/doc/document.tex @@ -51,11 +51,11 @@ \section{MTZ Formulation} \end{equation} Since there is an order, we are talking about arcs and for every vertex there must be at most one incoming arc. \begin{equation} - \sum_{i>0} x_{ij}\leq 1 \qquad \forall j=1,\dots,n + \sum_{i\geq 1} x_{ij}\leq 1 \qquad \forall j=1,\dots,n \end{equation} -The number of vertices in the tree must be $k$. +The number of vertices in the tree (excluding the start node) must be $k$. \begin{equation} - \sum_{i>0}v_i=k + \sum_{i\geq 1}v_i=k \end{equation} Only $v_i \in k-MST$ must have $u_i>0$. \begin{equation} @@ -66,6 +66,16 @@ \section{MTZ Formulation} x_{ij} &\leq u_i \\ x_{ij} &\leq u_j \end{align} +The sum of orders $u$ must be exactly $\frac{k(k+1)}{2}$. +\begin{equation} + \sum_{j \geq 0} u_{j}=\frac{k(k+1)}{2} \\ +\end{equation} +Whenever an arc is chosen, the corresponding arc in the other direction cannot be chosen. +\begin{equation} + x_{ij} + x_{ij}\leq 1 \\ +\end{equation} + + \section{SCF Formulation} There must be $k$ arcs in the tree (including arc from $0$) \begin{equation} @@ -75,7 +85,7 @@ \section{SCF Formulation} \begin{equation} \sum_{i \geq 1}v_i =k \\ \end{equation} -There must be exactly $1$ arc goint out of $0$ in the solution +There must be exactly $1$ arc going out of $0$ in the solution \begin{equation} \sum_{j \geq 1} x_{0j}=1\\ \end{equation} diff --git a/src/kMST_ILP.cpp b/src/kMST_ILP.cpp index 5f7805c..d646018 100644 --- a/src/kMST_ILP.cpp +++ b/src/kMST_ILP.cpp @@ -602,7 +602,7 @@ void kMST_ILP::modelMTZ() v[i] = IloBoolVar(env, myname.str().c_str()); } - //objective function (1) + //objective function (1.1) IloExpr objfunc(env); for (int i=0;i::iterator it=instance.incidentEdges.at(i).begin();it != instance.incidentEdges.at(i).end();++it){ @@ -657,21 +657,21 @@ void kMST_ILP::modelMTZ() model.add(co7 <= 1); co7.end(); } - //(8) + //(2.7) IloExpr co8(env); for(int i=0;i Date: Sun, 19 Jan 2014 10:51:55 +0100 Subject: [PATCH 14/16] Added results. --- doc/results.tex | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/doc/results.tex b/doc/results.tex index bda4478..47e1fdc 100644 --- a/doc/results.tex +++ b/doc/results.tex @@ -1,30 +1,30 @@ -\begin{tabular}{ l l l l l l l l l} +\begin{tabular}{ l l r r r r r r r} \multicolumn{2}{c}{} & \multicolumn{2}{c}{\textbf{MTZ}} & \multicolumn{2}{c}{\textbf{SCF}} & \multicolumn{2}{c}{\textbf{MCF}} & \textbf{Optimal Value}\\ - & k & time [s] & nodes & times [s] & nodes & time [s] & nodes & \\ + & k & time [s] & nodes & times [s] & nodes & time [s] & nodes & \\ \hline - \multirow{2}{*}{g01} & 2 & & & & & & & \\ - & 5 & & & & & & & \\ + \multirow{2}{*}{g01} & 2 & 0.01 & 0 & 0.00 & 0 & 0.03 & 0 & 46 \\ + & 5 & 0.02 & 0 & 0.02 & 0 & 0.03 & 0 & 477 \\ \hline - \multirow{2}{*}{g02} & 4 & & & & & & & \\ - & 10 & & & & & & & \\ + \multirow{2}{*}{g02} & 4 & 0.05 & 0 & 0.03 & 0 & 0.22 & 0 & 373 \\ + & 10 & 0.07 & 0 & 0.05 & 0 & 0.16 & 0 & 1390 \\ \hline - \multirow{2}{*}{g03} & 10 & & & & & & & \\ - & 25 & & & & & & & \\ + \multirow{2}{*}{g03} & 10 & 0.18 & 36 & 1.59 & 1725 & 1.08 & 0 & 725 \\ + & 25 & 1.55 & 1896 & 0.13 & 0 & 2.00 & 0 & 3074 \\ \hline - \multirow{2}{*}{g04} & 14 & & & & & & & \\ - & 35 & & & & & & & \\ + \multirow{2}{*}{g04} & 14 & 0.53 & 68 & 2.55 & 478 & 12.62 & 0 & 909 \\ + & 35 & 2.70 & 604 & 0.36 & 0 & 11.21 & 0 & 3292 \\ \hline - \multirow{2}{*}{g05} & 20 & & & & & & & \\ - & 50 & & & & & & & \\ + \multirow{2}{*}{g05} & 20 & 1.86 & 621 & 0.35 & 0 & 23.87 & 0 & 1235 \\ + & 50 & 7.79 & 6681 & 0.52 & 0 & 25.19 & 0 & 4898 \\ \hline - \multirow{2}{*}{g06} & 40 & & & & & & & \\ - & 100 & & & & & & & \\ + \multirow{2}{*}{g06} & 40 & 80.06 & 24464 & 43.21 & 1074 & \textemdash & \textemdash & 2068 \\ + & 100 & 163.29 & 122401 & 7.84 & 2825 & \textemdash & \textemdash & 6705 \\ \hline - \multirow{2}{*}{g07} & 60 & & & & & & & \\ - & 150 & & & & & & & \\ + \multirow{2}{*}{g07} & 60 & 25.35 & 2035 & 23.96 & 0 & \textemdash & \textemdash & 1335 \\ + & 150 & 93.56 & 4237 & 26.60 & 98 & \textemdash & \textemdash & 4534 \\ \hline - \multirow{2}{*}{g08} & 80 & & & & & & & \\ - & 200 & & & & & & & \\ + \multirow{2}{*}{g08} & 80 & 16.93 & 760 & 75.47 & 477 & \textemdash & \textemdash & 1620 \\ + & 200 & \textemdash & \textemdash & 117.59 & 477 & \textemdash & \textemdash & 5787 \\ \hline \end{tabular} From f219eb6c0acd04f1b137213444ce7940f918ec17 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Sun, 19 Jan 2014 10:58:34 +0100 Subject: [PATCH 15/16] Minor formatting --- doc/document.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/document.tex b/doc/document.tex index 31af36d..750ce39 100644 --- a/doc/document.tex +++ b/doc/document.tex @@ -39,7 +39,7 @@ \section{MTZ Formulation} \end{equation} There must be exactly one arc from the artificial vertex $0$ to any other vertex in the tree. \begin{equation} - \sum_{j>0} x_{0j} = 1 + \sum_{j\geq1} x_{0j} = 1 \end{equation} $u_i$ must be between $0$ and $k$ since $k$ vertices are in the tree. \begin{equation} @@ -110,7 +110,7 @@ \section{SCF Formulation} \end{equation} Every vertex in the solution consumes $1$ flow. \begin{equation} - \forall j \in V \hspace{30pt} \sum_{(i,j)} f_{ij} - \sum_{(j,i)} f_{ji} = v_j\\ + \sum_{(i,j)} f_{ij} - \sum_{(j,i)} f_{ji} = v_j \qquad \forall j=1,\dots,n\\ \end{equation} The flow going through an arc can be at most $k$. \begin{equation} From e68a84cb8bce5d9920755af08b23812741f45f13 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Sun, 19 Jan 2014 14:58:39 +0100 Subject: [PATCH 16/16] final version of everything (probably) --- doc/document.tex | 63 +++++++++++++++++++++---------- doc/results.tex | 18 ++++----- src/kMST_ILP.cpp | 97 +++++++++++++++++++++++------------------------- 3 files changed, 100 insertions(+), 78 deletions(-) diff --git a/doc/document.tex b/doc/document.tex index 750ce39..e9051ea 100644 --- a/doc/document.tex +++ b/doc/document.tex @@ -9,17 +9,18 @@ \usepackage{multirow} \numberwithin{equation}{section} \title{Algorithmics WS13/14, Programming Exercise} -\author{Dino Rossegger, Markus Scherer} +\author{Dino Rossegger \emph{0926471}\\ Markus Scherer \emph{1028046}} \date{\today} \begin{document} \maketitle \section{General} A artificial root vertex $0$ was introduced in the graphs which edges going to all other nodes and the cost function $c_{0j}=0\quad \forall j\in V$. Since the formulations work with directed graphs for every undirected edge $e$, two new edges where introduced, $e_{ij}$ and $e_{ji}$ denoting the corresponding arcs. -For all Formulations the same objective function was used. $c_{ij}$ denoting the cost function of the arc and $x_{ij}$ being $1$ if the arc is chosen or $0$ otherwise. +For all Formulations the same objective function was used. \begin{equation} \min{\sum_i \sum_{j\not=i} c_{ij}x_{ij}} \end{equation} -$c_{ij}$ denoting the cost function of the arc and $x_{ij}$ being $1$ if the arc is chosen or $0$ otherwise. Therefore a constraint limiting the values $x$ can take was used. +$c_{ij}$ is denoting the cost of the arc and $x_{ij}$ being $1$ if the arc is chosen or $0$ otherwise. +Therefore a constraint limiting the values $x$ can take was used. \begin{equation} x_{ij} \in \{0,1\} \qquad \forall (i,j) \end{equation} @@ -77,6 +78,11 @@ \section{MTZ Formulation} \section{SCF Formulation} +A commodity is introduced. This commodity can flow along each +arc and results thus in the following decision variables: +\begin{equation} + f_{ij} \qquad \forall (i,j) +\end{equation} There must be $k$ arcs in the tree (including arc from $0$) \begin{equation} \sum_{(i,j)} x_{ij} = k @@ -114,46 +120,55 @@ \section{SCF Formulation} \end{equation} The flow going through an arc can be at most $k$. \begin{equation} - f_{i,j}\leq kx_{i,j} + f_{ij}\leq kx_{ij} \end{equation} \section{MCF Formulation} +For every node a different commodity is introduced. These commodities can flow along each +arc and result thus in the following decision variables: +\begin{equation} + f_{ij}^l \in \{0,1\} \qquad \forall (i,j) \quad \forall l = 1,\dots, n\\ +\end{equation} + Most of the constraints are the same as in the single commodity flow formulation. \begin{align} \sum_{(i,j)} x_{ij} = k\\ - \sum_{i>0}v_i =k \\ - \sum_{j>0} x_{0j}=1\\ - \sum_{i>0} x_{i0}=0\\ + \sum_{i\geq1}v_i =k \\ + \sum_{j\geq1} x_{0j}=1\\ + \sum_{i\geq1} x_{i0}=0\\ x_{ij} \leq v_i\\ x_{ij} \leq v_j\\ - v_i + x_{ij} + x_{ji} \leq v_j + 1\\ + v_i + x_{ij} + x_{ji} \leq v_j + 1 \end{align} -The commodities going out of vertex $0$ can be at most $1$ each and the sum of all commodities must be $k$. +The commodities of type $l$ going out of vertex $0$ must be exactly $v_l$ (only commodities of selected nodes are sent out) +and the sum of all sent from $0$ commodities must be $k$. \begin{equation} - \sum_{j>0} f_{0j}^l \leq 1 \qquad \forall l\in [1,n]\\ - \sum_{l=1}^n \sum_{(0,j)} f_{0,j}^l = k\\ + \sum_{j\geq1} f_{0j}^l = v_l \qquad \forall l= 1,\dots, n \end{equation} -The sum of flows on commodity $l$ flowing into vertex $l$ is at most $1$. \begin{equation} -\sum_{i,i\not =l} f_{il}^l \leq 1 \qquad \forall l\in [1,n]\\ + \sum_{l=1}^n \sum_{(0,j)} f_{0j}^l = k\\ +\end{equation} +The sum of flows on commodity $l$ flowing into vertex $l$ is at most $v_l$. +\begin{equation} +\sum_{i,i\not =l} f_{il}^l \leq v_l \qquad \forall l = 1,\dots,n\\ \end{equation} If there is a flow on an arc, the arc must be selected. \begin{equation} -0\leq f_{ij}^l \leq x_{i,j} \qquad \forall (i,j), \forall l \in [0,n] +0\leq f_{ij}^l \leq x_{ij} \qquad \forall (i,j) \quad \forall l = 0,\ldots,n \end{equation} All vertices which are not the target of the commodity can not consume a flow. \begin{equation} -\sum_{i,i\not = j}f_{ij}^l - \sum_{i,i\not = j} f_{ji}^l =0 \qquad \forall j, l\in [1,n], j\not =l \\ +\sum_{i,i\not = j}f_{ij}^l - \sum_{i,i\not = j} f_{ji}^l =0 \qquad \forall j, l = 1,\dots,n \quad j\not =l \\ \end{equation} -If $l$ is target of some flow, the outgoing flow on its commodity must be $0$ +$v_l$ cannot send out flow of it's own commodity. \begin{equation} -\sum_{j\not=l} f_{l,j}^l =0\\ +\sum_{j\not=l} f_{lj}^l =0\\ \end{equation} If there is flow incoming to vertex $l$ on its commodity, the vertex must be selected \begin{equation} -\sum_{(i,l)} f_{i,l}^l - v_l=0 \qquad \forall l\in [1,n], i\in[0,n]\\ +\sum_{(i,l)} f_{il}^l - v_l=0 \qquad \forall l = 1,\dots,n \quad \forall i = 1,\dots,n\\ \end{equation} -The sum of flows on all commodities must be $k$ +The sum of incoming flows matching a node, over all commodities, must be $k$ \begin{equation} \sum_{l=1}^n \sum_{(i,l)} f_{i,l}^l = k\\ \end{equation} @@ -165,6 +180,16 @@ \section{MCF Formulation} \end{equation} \section{Results} + +SCF is the only formulation that solves all instances. MTZ seems to have advantages over SCF with +smaller $k$-values but fails to solve the last configuration (after several hours the laptop +used for the benchmarks became unresponsive, possibly due overheating issues). MTZ also uses more +branch-and-bound-nodes. + +Our MCF-Formulation is not able to solve all instances (for \emph{g06} it fails to prove optimality, +in the time we granted to it, although the optimal value is found, for \emph{g07} and \emph{g08} the +program crashes after exhausting the memory of the test computer (8GB)). + \input{results.tex} \end{document} diff --git a/doc/results.tex b/doc/results.tex index 47e1fdc..208b8c9 100644 --- a/doc/results.tex +++ b/doc/results.tex @@ -3,20 +3,20 @@ \multicolumn{2}{c}{} & \multicolumn{2}{c}{\textbf{MTZ}} & \multicolumn{2}{c}{\textbf{SCF}} & \multicolumn{2}{c}{\textbf{MCF}} & \textbf{Optimal Value}\\ & k & time [s] & nodes & times [s] & nodes & time [s] & nodes & \\ \hline - \multirow{2}{*}{g01} & 2 & 0.01 & 0 & 0.00 & 0 & 0.03 & 0 & 46 \\ - & 5 & 0.02 & 0 & 0.02 & 0 & 0.03 & 0 & 477 \\ + \multirow{2}{*}{g01} & 2 & 0.01 & 0 & 0.00 & 0 & 0.04 & 0 & 46 \\ + & 5 & 0.02 & 0 & 0.02 & 0 & 0.07 & 0 & 477 \\ \hline \multirow{2}{*}{g02} & 4 & 0.05 & 0 & 0.03 & 0 & 0.22 & 0 & 373 \\ - & 10 & 0.07 & 0 & 0.05 & 0 & 0.16 & 0 & 1390 \\ + & 10 & 0.07 & 0 & 0.05 & 0 & 0.15 & 0 & 1390 \\ \hline - \multirow{2}{*}{g03} & 10 & 0.18 & 36 & 1.59 & 1725 & 1.08 & 0 & 725 \\ - & 25 & 1.55 & 1896 & 0.13 & 0 & 2.00 & 0 & 3074 \\ + \multirow{2}{*}{g03} & 10 & 0.18 & 36 & 1.59 & 1725 & 1.37 & 0 & 725 \\ + & 25 & 1.55 & 1896 & 0.13 & 0 & 2.38 & 0 & 3074 \\ \hline - \multirow{2}{*}{g04} & 14 & 0.53 & 68 & 2.55 & 478 & 12.62 & 0 & 909 \\ - & 35 & 2.70 & 604 & 0.36 & 0 & 11.21 & 0 & 3292 \\ + \multirow{2}{*}{g04} & 14 & 0.53 & 68 & 2.55 & 478 & 16.56 & 97 & 909 \\ + & 35 & 2.70 & 604 & 0.36 & 0 & 9.36 & 0 & 3292 \\ \hline - \multirow{2}{*}{g05} & 20 & 1.86 & 621 & 0.35 & 0 & 23.87 & 0 & 1235 \\ - & 50 & 7.79 & 6681 & 0.52 & 0 & 25.19 & 0 & 4898 \\ + \multirow{2}{*}{g05} & 20 & 1.86 & 621 & 0.35 & 0 & 14.73 & 0 & 1235 \\ + & 50 & 7.79 & 6681 & 0.52 & 0 & 26.59 & 0 & 4898 \\ \hline \multirow{2}{*}{g06} & 40 & 80.06 & 24464 & 43.21 & 1074 & \textemdash & \textemdash & 2068 \\ & 100 & 163.29 & 122401 & 7.84 & 2825 & \textemdash & \textemdash & 6705 \\ diff --git a/src/kMST_ILP.cpp b/src/kMST_ILP.cpp index d646018..030d5c9 100644 --- a/src/kMST_ILP.cpp +++ b/src/kMST_ILP.cpp @@ -111,7 +111,7 @@ void kMST_ILP::modelSCF() model.add(IloMinimize(env,objfunc)); objfunc.end(); - //(3.1) + //(3.2) IloExpr co2(env); for(int i=0;i f(env,n); + //f (4.1) + IloArray f(env,n); //IloIntVar f[n][2*m]; for(int l=1;l::iterator it=instance.incidentEdges.at(l).begin();it!=instance.incidentEdges.at(l).end();it++){ @@ -458,18 +458,18 @@ void kMST_ILP::modelMCF() } - //(3.14) - for (int l=1;l::iterator it=instance.incidentEdges.at(l).begin();it!=instance.incidentEdges.at(l).end();it++){ @@ -506,13 +505,12 @@ void kMST_ILP::modelMCF() else if(instance.edges.at(*it).v2==l && instance.edges.at(*it).v1!=l){ co+=f[l][*it]; } - } } - model.add(co==k); - co.end(); + model.add(co==k); + co.end(); - //(3.16) + //(4.10) IloExpr co_35(env); for (int l=1;l::iterator it=instance.incidentEdges.at(0).begin();it!=instance.incidentEdges.at(0).end();it++){ @@ -540,7 +537,7 @@ void kMST_ILP::modelMCF() model.add(co - v[l]==0); co.end(); } - //(3.18) + //(4.17) for(int k=0;k