Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projet-optimisation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aliaume Lopez
projet-optimisation
Commits
624d2195
Commit
624d2195
authored
Jan 11, 2017
by
Aliaume Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajout images
parent
03d1592f
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
71 additions
and
13 deletions
+71
-13
approximations.py
approximations.py
+1
-1
dual.py
dual.py
+33
-1
images/00_APPROX_tsp225_approx2.png
images/00_APPROX_tsp225_approx2.png
+0
-0
images/00_APPROX_tsp225_approx2_2opt.png
images/00_APPROX_tsp225_approx2_2opt.png
+0
-0
images/00_APPROX_tsp225_glouton.png
images/00_APPROX_tsp225_glouton.png
+0
-0
images/00_APPROX_tsp225_glouton_2opt.png
images/00_APPROX_tsp225_glouton_2opt.png
+0
-0
images/0CVX_tsp225_approxPL.png
images/0CVX_tsp225_approxPL.png
+0
-0
images/0CVX_tsp225_separationfinie.png
images/0CVX_tsp225_separationfinie.png
+0
-0
images/0CVX_tsp225_simple_1.png
images/0CVX_tsp225_simple_1.png
+0
-0
images/0CVX_tsp225_simple_11.png
images/0CVX_tsp225_simple_11.png
+0
-0
images/0CVX_tsp225_simple_21.png
images/0CVX_tsp225_simple_21.png
+0
-0
images/0CVX_tsp225_simple_31.png
images/0CVX_tsp225_simple_31.png
+0
-0
images/0CVX_tsp225_simple_41.png
images/0CVX_tsp225_simple_41.png
+0
-0
new_separation.py
new_separation.py
+5
-1
rapport/presentation.tex
rapport/presentation.tex
+31
-9
rapport/rapport_projet_opti.tex
rapport/rapport_projet_opti.tex
+1
-1
No files found.
approximations.py
View file @
624d2195
...
...
@@ -125,7 +125,7 @@ logging.basicConfig(filename='approximations_run.log',
datefmt
=
'%m/%d/%Y %I:%M:%S %p'
)
# Choix du fichier test
filename
=
"
eil101
"
filename
=
"
tsp225
"
probleme
=
read_tsp_file
(
"problemes/{}.tsp"
.
format
(
filename
))
graphe
=
probleme
[
"GRAPH"
]
...
...
dual.py
View file @
624d2195
...
...
@@ -16,6 +16,33 @@ import mincut
import
numpy
as
np
import
scipy.optimize
as
scopt
import
cvxpy
as
cvx
def
minim
(
A_eq
,
b_eq
,
c
,
A_in
=
[],
b_in
=
[]):
A_eq
=
np
.
array
(
A_eq
)
b_eq
=
np
.
array
(
b_eq
)
c
=
np
.
array
(
c
)
m
,
n
=
A_eq
.
shape
assert
(
n
==
len
(
c
)
and
(
m
==
len
(
b_eq
)))
x
=
cvx
.
Variable
(
n
)
objective
=
cvx
.
Minimize
(
cvx
.
sum_entries
(
c
*
x
))
if
(
A_in
==
[]):
constraints
=
[
0
<=
x
,
A_eq
*
x
==
b_eq
]
else
:
constraints
=
[
0
<=
x
,
A_eq
*
x
==
b_eq
,
A_in
*
x
>=
b_in
]
prob
=
cvx
.
Problem
(
objective
,
constraints
)
opt
=
prob
.
solve
()
s
=
prob
.
status
valx
=
np
.
copy
(
x
.
value
)
valx
=
np
.
array
(
np
.
transpose
(
valx
)[
0
])
return
({
"status"
:
s
,
"opt"
:
opt
,
"x"
:
valx
})
def
subsets
(
l
):
"""
Retourne l'ensemble de sous ensembles
...
...
@@ -333,8 +360,13 @@ def algorithme_separation (graphe, filename="default_separation_dual", maxiter=1
# On se demande si on a une bonne solution ou non
# logging.debug ("Solve dual problem")
# res2 = minim (A,b, [ - y for y in c ])
res1
=
vrai_simplexe
(
A1
,
b1
,
c1
)
res2
=
vrai_simplexe
(
A
,
b
,
[
-
y
for
y
in
c
])
logging
.
debug
(
"Dual value : {}"
.
format
(
-
1
*
res2
[
"fun"
]))
print
(
"{} - {}"
.
format
(
res1
[
"fun"
],
-
1
*
res2
[
"fun"
]))
logging
.
debug
(
"CHECK if good primal solution"
)
edge_to_add
=
trouve_arete_a_ajouter
(
n
,
e_s
,
w
,
A
,
b
,
c
,
graphe
,
res2
[
"x"
])
logging
.
debug
(
"EDGE to add : {}"
.
format
(
edge_to_add
))
...
...
@@ -387,7 +419,7 @@ def algorithme_separation (graphe, filename="default_separation_dual", maxiter=1
if
__name__
==
'__main__'
:
filename
=
"
burma14
"
filename
=
"
ch150
"
# initialisation du loggeur
logging
.
basicConfig
(
filename
=
'dual_run.log'
,
level
=
logging
.
DEBUG
,
...
...
images/00_APPROX_tsp225_approx2.png
0 → 100644
View file @
624d2195
14.4 KB
images/00_APPROX_tsp225_approx2_2opt.png
0 → 100644
View file @
624d2195
10.8 KB
images/00_APPROX_tsp225_glouton.png
0 → 100644
View file @
624d2195
11.8 KB
images/00_APPROX_tsp225_glouton_2opt.png
0 → 100644
View file @
624d2195
11.5 KB
images/0CVX_tsp225_approxPL.png
0 → 100644
View file @
624d2195
10.4 KB
images/0CVX_tsp225_separationfinie.png
0 → 100644
View file @
624d2195
11.8 KB
images/0CVX_tsp225_simple_1.png
0 → 100644
View file @
624d2195
12.8 KB
images/0CVX_tsp225_simple_11.png
0 → 100644
View file @
624d2195
12.7 KB
images/0CVX_tsp225_simple_21.png
0 → 100644
View file @
624d2195
11.9 KB
images/0CVX_tsp225_simple_31.png
0 → 100644
View file @
624d2195
12.7 KB
images/0CVX_tsp225_simple_41.png
0 → 100644
View file @
624d2195
14.3 KB
new_separation.py
View file @
624d2195
...
...
@@ -315,6 +315,10 @@ def algorithme_separation(graphe, filename="default_separation_output",epsilon =
return
value
,
convert_to_edges
(
graphe
,
sol
)
def
primal_dual
(
graphe
,
filename
=
"primal_dual"
,
epsilon
=
0.0001
):
pass
def
test
(
filename
):
"""
Un test de l'algorithme
...
...
@@ -372,4 +376,4 @@ def test_separation_on_file (filename):
test_separation_on_file
(
"
hk48
"
)
test_separation_on_file
(
"
tsp225
"
)
rapport/presentation.tex
View file @
624d2195
...
...
@@ -523,6 +523,28 @@ Implémenté dans NetworkX.
\end{frame}
\begin{frame}
\frametitle
{
Exemple d'historique
}
\begin{exampleblock}
{
Sur un problème avec 225 points
}
\begin{figure}
\centering
\begin{overlayarea}
{
6cm
}{
4cm
}
\only
<1>
{
\includegraphics
[width=7cm]
{
../images/0CVX
_
tsp225
_
simple
_
1.png
}}
\only
<2>
{
\includegraphics
[width=7cm]
{
../images/0CVX
_
tsp225
_
simple
_
11.png
}}
\only
<3>
{
\includegraphics
[width=7cm]
{
../images/0CVX
_
tsp225
_
simple
_
21.png
}}
\only
<4>
{
\includegraphics
[width=7cm]
{
../images/0CVX
_
tsp225
_
simple
_
31.png
}}
\only
<5>
{
\includegraphics
[width=7cm]
{
../images/0CVX
_
tsp225
_
simple
_
41.png
}}
\only
<6>
{
\includegraphics
[width=7cm]
{
../images/0CVX
_
tsp225
_
separationfinie.png
}}
\only
<7>
{
\includegraphics
[width=7cm]
{
../images/0CVX
_
tsp225
_
approxPL.png
}}
\only
<8>
{
\includegraphics
[width=7cm]
{
../images/00
_
APPROX
_
tsp225
_
approx2
_
2opt.png
}}
\only
<9>
{
\includegraphics
[width=7cm]
{
../images/00
_
APPROX
_
tsp225
_
glouton
_
2opt.png
}}
\end{overlayarea}
\caption
{
Le problème tsp225 de valeur optimale
$
3919
$}
\end{figure}
\end{exampleblock}
\end{frame}
\begin{frame}
plus de résultats
\end{frame}
...
...
@@ -536,7 +558,7 @@ Implémenté dans NetworkX.
\begin{equation}
\label
{
eqn:dual
}
\boxed
{
\begin{array}
{
rll
}
\textrm
{
Maximiser
}
&
\displaystyle
-
\sum
_{
uv
\in
E'
}
\lambda
_{
1,uv
}
x
_{
uv
}
- 2
\sum
_{
u
\in
V
}
\nu
_
u + 2
\sum
_{
S
\in
W
}
\lambda
_{
3,S
}
\\
\textrm
{
Maximiser
}
&
\displaystyle
-
\sum
_{
uv
\in
E'
}
\lambda
_{
1,uv
}
- 2
\sum
_{
u
\in
V
}
\nu
_
u + 2
\sum
_{
S
\in
W
}
\lambda
_{
3,S
}
\\
\textrm
{
Avec
}
&
\lambda
_
1
\geq
0
\\
&
\lambda
_
2
\geq
0
\\
&
\lambda
_
3
\geq
0
\\
...
...
@@ -564,13 +586,13 @@ Avec $D_{E'}$ la matirce d'incidence du graphe restreint à $E'$, et $G_{E'}$ la
En pratique~: on ajoute toutes les arêtes.
\begin{exampleblock}
{
Algorithme dual suivi de primal
}
Boucle~:
\begin{enumerate}
\item
Calcul d'un sous ensemble
$
E'
$
d'arête qui donne
une minoration avec la méthode du dual
\item
Calcul d'une borne inférieure de plus
en plus précise en utilisant le primal
sur l'ensemble
$
E'
$
d'arêtes
\item
Calcul d'une contrainte de
\emph
{
sous-tour
}
à ajouter via le calcul du primal
\end{enumerate}
\end{exampleblock}
...
...
rapport/rapport_projet_opti.tex
View file @
624d2195
...
...
@@ -512,7 +512,7 @@ L'expression du dual est alors simplement~:
\begin{equation}
\label
{
eqn:dual
}
\boxed
{
\begin{array}
{
rll
}
\textrm
{
max
}
&
\displaystyle
-
\sum
_{
uv
\in
E'
}
\lambda
_{
1,uv
}
x
_{
uv
}
- 2
\sum
_{
u
\in
V
}
\nu
_
u + 2
\sum
_{
S
\in
W
}
\lambda
_{
3,S
}
\\
\textrm
{
max
}
&
\displaystyle
-
\sum
_{
uv
\in
E'
}
\lambda
_{
1,uv
}
- 2
\sum
_{
u
\in
V
}
\nu
_
u + 2
\sum
_{
S
\in
W
}
\lambda
_{
3,S
}
\\
&
\lambda
_
1
\geq
0
\\
&
\lambda
_
2
\geq
0
\\
&
\lambda
_
3
\geq
0
\\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment