spam incomming, sry la dsi
Co-authored-by: gdamms <gdamms@users.noreply.github.com>
This commit is contained in:
parent
576268b061
commit
329cd2a67b
17
distrib.py
Normal file
17
distrib.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
PATH = "data"
|
||||||
|
|
||||||
|
import os
|
||||||
|
result = [os.path.join(dp, f) for dp, dn, filenames in os.walk(PATH) for f in filenames if os.path.splitext(f)[1] == '.opb']
|
||||||
|
|
||||||
|
with open("machines.txt") as file:
|
||||||
|
machines = file.readlines()
|
||||||
|
machines = [machine.rstrip() for machine in machines]
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
while len(result) > 0:
|
||||||
|
knap = result.pop()[:-4]
|
||||||
|
victime = machines[i % len(machines)]
|
||||||
|
i+=1
|
||||||
|
cmd = f"""ssh lfainsin@{victime} -o "ConnectTimeout 3" -o "StrictHostKeyChecking no" "cd 2A/RO/tp2/ && tmux new-session -d 'julia test.jl {knap}.opb > {knap}.stdout'" """
|
||||||
|
print(cmd)
|
||||||
|
os.system(cmd)
|
252
machines.txt
Normal file
252
machines.txt
Normal file
|
@ -0,0 +1,252 @@
|
||||||
|
ablette.enseeiht.fr
|
||||||
|
acdc.enseeiht.fr
|
||||||
|
ackbar.enseeiht.fr
|
||||||
|
actinium.enseeiht.fr
|
||||||
|
ader.enseeiht.fr
|
||||||
|
aerosmith.enseeiht.fr
|
||||||
|
alose.enseeiht.fr
|
||||||
|
anguille.enseeiht.fr
|
||||||
|
antimoine.enseeiht.fr
|
||||||
|
apollinaire.enseeiht.fr
|
||||||
|
aragorn.enseeiht.fr
|
||||||
|
archimede.enseeiht.fr
|
||||||
|
arryn.enseeiht.fr
|
||||||
|
arwen.enseeiht.fr
|
||||||
|
aspicot.enseeiht.fr
|
||||||
|
aston.enseeiht.fr
|
||||||
|
atanasoff.enseeiht.fr
|
||||||
|
atkinson.enseeiht.fr
|
||||||
|
azote.enseeiht.fr
|
||||||
|
babagge.enseeiht.fr
|
||||||
|
backus.enseeiht.fr
|
||||||
|
banshee.enseeiht.fr
|
||||||
|
baratheon.enseeiht.fr
|
||||||
|
basilic.enseeiht.fr
|
||||||
|
bastie.enseeiht.fr
|
||||||
|
baudelaire.enseeiht.fr
|
||||||
|
behemot.enseeiht.fr
|
||||||
|
bilbo.enseeiht.fr
|
||||||
|
bishop.enseeiht.fr
|
||||||
|
bleriot.enseeiht.fr
|
||||||
|
bobafett.enseeiht.fr
|
||||||
|
boeing.enseeiht.fr
|
||||||
|
bonite.enseeiht.fr
|
||||||
|
boole.enseeiht.fr
|
||||||
|
boromir.enseeiht.fr
|
||||||
|
bouba.enseeiht.fr
|
||||||
|
boucher.enseeiht.fr
|
||||||
|
brassens.enseeiht.fr
|
||||||
|
bravoos.enseeiht.fr
|
||||||
|
brochet.enseeiht.fr
|
||||||
|
bulbizarre.enseeiht.fr
|
||||||
|
cable.enseeiht.fr
|
||||||
|
calimero.enseeiht.fr
|
||||||
|
candy.enseeiht.fr
|
||||||
|
carapuce.enseeiht.fr
|
||||||
|
carbone.enseeiht.fr
|
||||||
|
carmack.enseeiht.fr
|
||||||
|
carpe.enseeiht.fr
|
||||||
|
casimir.enseeiht.fr
|
||||||
|
chenipan.enseeiht.fr
|
||||||
|
chevesne.enseeiht.fr
|
||||||
|
chewie.enseeiht.fr
|
||||||
|
clapton.enseeiht.fr
|
||||||
|
clash.enseeiht.fr
|
||||||
|
clementine.enseeiht.fr
|
||||||
|
cobalt.enseeiht.fr
|
||||||
|
colossus.enseeiht.fr
|
||||||
|
cooper.enseeiht.fr
|
||||||
|
copernic.enseeiht.fr
|
||||||
|
corb.enseeiht.fr
|
||||||
|
cyclope.enseeiht.fr
|
||||||
|
dagobah.enseeiht.fr
|
||||||
|
darwin.enseeiht.fr
|
||||||
|
daurade.enseeiht.fr
|
||||||
|
dazzler.enseeiht.fr
|
||||||
|
deeppurple.enseeiht.fr
|
||||||
|
demusset.enseeiht.fr
|
||||||
|
descartes.enseeiht.fr
|
||||||
|
diabolo.enseeiht.fr
|
||||||
|
dijkstra.enseeiht.fr
|
||||||
|
doors.enseeiht.fr
|
||||||
|
dorne.enseeiht.fr
|
||||||
|
dragon.enseeiht.fr
|
||||||
|
dylan.enseeiht.fr
|
||||||
|
eagles.enseeiht.fr
|
||||||
|
edison.enseeiht.fr
|
||||||
|
einsten.enseeiht.fr
|
||||||
|
elrond.enseeiht.fr
|
||||||
|
eomer.enseeiht.fr
|
||||||
|
eowyn.enseeiht.fr
|
||||||
|
eperlan.enseeiht.fr
|
||||||
|
epica.enseeiht.fr
|
||||||
|
esteban.enseeiht.fr
|
||||||
|
ewok.enseeiht.fr
|
||||||
|
farman.enseeiht.fr
|
||||||
|
fermat.enseeiht.fr
|
||||||
|
ferre.enseeiht.fr
|
||||||
|
fletan.enseeiht.fr
|
||||||
|
fluor.enseeiht.fr
|
||||||
|
forge.enseeiht.fr
|
||||||
|
frodon.enseeiht.fr
|
||||||
|
galilee.enseeiht.fr
|
||||||
|
galium.enseeiht.fr
|
||||||
|
gambit.enseeiht.fr
|
||||||
|
gandalf.enseeiht.fr
|
||||||
|
gardon.enseeiht.fr
|
||||||
|
garros.enseeiht.fr
|
||||||
|
gautier.enseeiht.fr
|
||||||
|
gimli.enseeiht.fr
|
||||||
|
gobelin.enseeiht.fr
|
||||||
|
gobie.enseeiht.fr
|
||||||
|
goldorak.enseeiht.fr
|
||||||
|
gorgone.enseeiht.fr
|
||||||
|
gosling.enseeiht.fr
|
||||||
|
goujon.enseeiht.fr
|
||||||
|
greyjoy.enseeiht.fr
|
||||||
|
griffon.enseeiht.fr
|
||||||
|
grove.enseeiht.fr
|
||||||
|
guynemer.enseeiht.fr
|
||||||
|
havok.enseeiht.fr
|
||||||
|
hawking.enseeiht.fr
|
||||||
|
heidi.enseeiht.fr
|
||||||
|
hendrix.enseeiht.fr
|
||||||
|
hippogriffe.enseeiht.fr
|
||||||
|
hopper.enseeiht.fr
|
||||||
|
hugo.enseeiht.fr
|
||||||
|
hydre.enseeiht.fr
|
||||||
|
hypotrempe.enseeiht.fr
|
||||||
|
iceberg.enseeiht.fr
|
||||||
|
iode.enseeiht.fr
|
||||||
|
jabba.enseeiht.fr
|
||||||
|
jeangrey.enseeiht.fr
|
||||||
|
jobs.enseeiht.fr
|
||||||
|
jubele.enseeiht.fr
|
||||||
|
kenobi.enseeiht.fr
|
||||||
|
kepler.enseeiht.fr
|
||||||
|
kernighan.enseeiht.fr
|
||||||
|
kiss.enseeiht.fr
|
||||||
|
knuth.enseeiht.fr
|
||||||
|
ladyoscar.enseeiht.fr
|
||||||
|
lafontaine.enseeiht.fr
|
||||||
|
lamartine.enseeiht.fr
|
||||||
|
lando.enseeiht.fr
|
||||||
|
lannister.enseeiht.fr
|
||||||
|
latecoere.enseeiht.fr
|
||||||
|
legolas.enseeiht.fr
|
||||||
|
leia.enseeiht.fr
|
||||||
|
lindbergh.enseeiht.fr
|
||||||
|
liskov.enseeiht.fr
|
||||||
|
loureed.enseeiht.fr
|
||||||
|
lovelace.enseeiht.fr
|
||||||
|
luke.enseeiht.fr
|
||||||
|
magicarpe.enseeiht.fr
|
||||||
|
magma.enseeiht.fr
|
||||||
|
magneto.enseeiht.fr
|
||||||
|
malicia.enseeiht.fr
|
||||||
|
mallarme.enseeiht.fr
|
||||||
|
manticore.enseeiht.fr
|
||||||
|
marcheursblancs.enseeiht.fr
|
||||||
|
martell.enseeiht.fr
|
||||||
|
maupassant.enseeiht.fr
|
||||||
|
maya.enseeiht.fr
|
||||||
|
meeren.enseeiht.fr
|
||||||
|
melofee.enseeiht.fr
|
||||||
|
mermoz.enseeiht.fr
|
||||||
|
merry.enseeiht.fr
|
||||||
|
messerschmitt.enseeiht.fr
|
||||||
|
metallica.enseeiht.fr
|
||||||
|
minotaure.enseeiht.fr
|
||||||
|
mordocet.enseeiht.fr
|
||||||
|
motorhead.enseeiht.fr
|
||||||
|
murdock.enseeiht.fr
|
||||||
|
muse.enseeiht.fr
|
||||||
|
mystique.enseeiht.fr
|
||||||
|
neon.enseeiht.fr
|
||||||
|
nerophis.enseeiht.fr
|
||||||
|
neumann.enseeiht.fr
|
||||||
|
newton.enseeiht.fr
|
||||||
|
nickel.enseeiht.fr
|
||||||
|
nymphe.enseeiht.fr
|
||||||
|
ohm.enseeiht.fr
|
||||||
|
omble.enseeiht.fr
|
||||||
|
orphie.enseeiht.fr
|
||||||
|
oxygene.enseeiht.fr
|
||||||
|
palomete.enseeiht.fr
|
||||||
|
palpatine.enseeiht.fr
|
||||||
|
pascal.enseeiht.fr
|
||||||
|
pegase.enseeiht.fr
|
||||||
|
phenix.enseeiht.fr
|
||||||
|
phosphore.enseeiht.fr
|
||||||
|
piafabec.enseeiht.fr
|
||||||
|
pikachu.enseeiht.fr
|
||||||
|
pinkfloyd.enseeiht.fr
|
||||||
|
pippin.enseeiht.fr
|
||||||
|
poe.enseeiht.fr
|
||||||
|
polaris.enseeiht.fr
|
||||||
|
polonium.enseeiht.fr
|
||||||
|
portreal.enseeiht.fr
|
||||||
|
prevert.enseeiht.fr
|
||||||
|
psykokwak.enseeiht.fr
|
||||||
|
psylocke.enseeiht.fr
|
||||||
|
queen.enseeiht.fr
|
||||||
|
r2d2.enseeiht.fr
|
||||||
|
rattata.enseeiht.fr
|
||||||
|
rimbaud.enseeiht.fr
|
||||||
|
rocket.enseeiht.fr
|
||||||
|
rondoudou.enseeiht.fr
|
||||||
|
roucool.enseeiht.fr
|
||||||
|
rouget.enseeiht.fr
|
||||||
|
saintexupery.enseeiht.fr
|
||||||
|
salameche.enseeiht.fr
|
||||||
|
sam.enseeiht.fr
|
||||||
|
sand.enseeiht.fr
|
||||||
|
sandre.enseeiht.fr
|
||||||
|
sar.enseeiht.fr
|
||||||
|
sauvageons.enseeiht.fr
|
||||||
|
scorpion.enseeiht.fr
|
||||||
|
scoubidou.enseeiht.fr
|
||||||
|
shadowcat.enseeiht.fr
|
||||||
|
shannon.enseeiht.fr
|
||||||
|
silure.enseeiht.fr
|
||||||
|
snorki.enseeiht.fr
|
||||||
|
snow.enseeiht.fr
|
||||||
|
socrate.enseeiht.fr
|
||||||
|
sodium.enseeiht.fr
|
||||||
|
solo.enseeiht.fr
|
||||||
|
stallman.enseeiht.fr
|
||||||
|
stark.enseeiht.fr
|
||||||
|
stones.enseeiht.fr
|
||||||
|
succube.enseeiht.fr
|
||||||
|
sunfire.enseeiht.fr
|
||||||
|
superbus.enseeiht.fr
|
||||||
|
swartz.enseeiht.fr
|
||||||
|
tacaud.enseeiht.fr
|
||||||
|
tanche.enseeiht.fr
|
||||||
|
tao.enseeiht.fr
|
||||||
|
targaryen.enseeiht.fr
|
||||||
|
taupiqueur.enseeiht.fr
|
||||||
|
tesla.enseeiht.fr
|
||||||
|
titane.enseeiht.fr
|
||||||
|
tornade.enseeiht.fr
|
||||||
|
torvalds.enseeiht.fr
|
||||||
|
truite.enseeiht.fr
|
||||||
|
turing.enseeiht.fr
|
||||||
|
tyrell.enseeiht.fr
|
||||||
|
uranium.enseeiht.fr
|
||||||
|
vador.enseeiht.fr
|
||||||
|
vairon.enseeiht.fr
|
||||||
|
verlaine.enseeiht.fr
|
||||||
|
voisin.enseeiht.fr
|
||||||
|
volantis.enseeiht.fr
|
||||||
|
volta.enseeiht.fr
|
||||||
|
winterfell.enseeiht.fr
|
||||||
|
wright.enseeiht.fr
|
||||||
|
wyvern.enseeiht.fr
|
||||||
|
xorn.enseeiht.fr
|
||||||
|
yoda.enseeiht.fr
|
||||||
|
z6po.enseeiht.fr
|
||||||
|
zemanek.enseeiht.fr
|
||||||
|
zia.enseeiht.fr
|
||||||
|
zirconium.enseeiht.fr
|
||||||
|
zztop.enseeiht.fr
|
|
@ -1,18 +1,3 @@
|
||||||
import Pkg;
|
|
||||||
Pkg.add("GraphRecipes");
|
|
||||||
Pkg.add("Plots");
|
|
||||||
using GraphRecipes, Plots #only used to visualize the search tree at the end of the branch-and-bound
|
|
||||||
|
|
||||||
"""Open and read a KnapFile.
|
|
||||||
|
|
||||||
Args: \\
|
|
||||||
- filename (String): the name of the file to read.
|
|
||||||
|
|
||||||
Returns: \\
|
|
||||||
- price (Vector{Integer}): prices of items to put in the KnapSack. \\
|
|
||||||
- weight (Vector{Integer}): weights of items to put in the KnapSack. \\
|
|
||||||
- capacity (Integer): the maximum capacity of the KnapSack.
|
|
||||||
"""
|
|
||||||
function readKnapInstance(filename)
|
function readKnapInstance(filename)
|
||||||
price = []
|
price = []
|
||||||
weight = []
|
weight = []
|
||||||
|
@ -38,24 +23,6 @@ function readKnapInstance(filename)
|
||||||
return price, weight, capacity
|
return price, weight, capacity
|
||||||
end
|
end
|
||||||
|
|
||||||
"""Test if a node should be pruned.
|
|
||||||
|
|
||||||
Args: \\
|
|
||||||
- x (Vector{Integer}): the node to be tested. \\
|
|
||||||
- price (Vector{Integer}): prices of items to put in the KnapSack. \\
|
|
||||||
- weight (Vector{Integer}): weights of items to put in the KnapSack. \\
|
|
||||||
- capacity (Integer): the maximum capacity of the KnapSack. \\
|
|
||||||
- BestProfit (Integer): the current BestProfit value. \\
|
|
||||||
- Bestsol (Integer): the current BestSol values. \\
|
|
||||||
- affich (Bool): determine if the function should print to stdout.
|
|
||||||
|
|
||||||
Returns: \\
|
|
||||||
- TA (Bool): true if the node is feasible. \\
|
|
||||||
- TO (Bool): true if the node is optimal. \\
|
|
||||||
- TR (Bool): true if the node is resolvable. \\
|
|
||||||
- BestProfit (Integer): the updated value of BestProfit. \\
|
|
||||||
- Bestsol (Vector{Integer}): the updated values of BestSol.
|
|
||||||
"""
|
|
||||||
function TestsSondabilite_relaxlin(x, price, weight, capacity, BestProfit, Bestsol, affich)
|
function TestsSondabilite_relaxlin(x, price, weight, capacity, BestProfit, Bestsol, affich)
|
||||||
TA, TO, TR = false, false, false
|
TA, TO, TR = false, false, false
|
||||||
|
|
||||||
|
@ -96,22 +63,9 @@ function TestsSondabilite_relaxlin(x, price, weight, capacity, BestProfit, Bests
|
||||||
return TA, TO, TR, Bestsol, BestProfit
|
return TA, TO, TR, Bestsol, BestProfit
|
||||||
end
|
end
|
||||||
|
|
||||||
"""Split a node in two.
|
|
||||||
|
|
||||||
Args: \\
|
|
||||||
- price (Vector{Integer}): prices of items to put in the KnapSack. \\
|
|
||||||
- listvars (Vector{Vector{Integer}}): the current values of listvars. \\
|
|
||||||
- listvals (Vector{Integer}): the current values of listvals.
|
|
||||||
|
|
||||||
Returns: \\
|
|
||||||
- listvars (Vector{Vector{Integer}}): the updated values of listvars. \\
|
|
||||||
- listvals (Vector{Integer}): the updated values of listvals.
|
|
||||||
"""
|
|
||||||
function SeparerNoeud_relaxlin(price, listvars, listvals)
|
function SeparerNoeud_relaxlin(price, listvars, listvals)
|
||||||
# Le noeud est non-sondable. Appliquer le critère de séparation pour le séparer en sous-noeuds
|
# Le noeud est non-sondable. Appliquer le critère de séparation pour le séparer en sous-noeuds
|
||||||
|
|
||||||
# Cas du noeud le plus à gauche
|
# Cas du noeud le plus à gauche
|
||||||
|
|
||||||
# On sépare le noeud actuel en 2 sous-noeuds
|
# On sépare le noeud actuel en 2 sous-noeuds
|
||||||
predX = pop!(listvars)
|
predX = pop!(listvars)
|
||||||
nextX0 = copy(predX)
|
nextX0 = copy(predX)
|
||||||
|
@ -148,18 +102,6 @@ function SeparerNoeud_relaxlin(price, listvars, listvals)
|
||||||
return listvars, listvals
|
return listvars, listvals
|
||||||
end
|
end
|
||||||
|
|
||||||
"""Pop node fom the list to explore another node.
|
|
||||||
|
|
||||||
Args: \\
|
|
||||||
- price (Vector{Integer}): prices of items to put in the KnapSack. \\
|
|
||||||
- listvars (Vector{Vector{Integer}}): the current values of listvars. \\
|
|
||||||
- listvals (Vector{Integer}): the current values of listvals.
|
|
||||||
|
|
||||||
Returns: \\
|
|
||||||
- listvars (Vector{Vector{Integer}}): the updated values of listvars. \\
|
|
||||||
- listvals (Vector{Integer}): the updated values of listvals. \\
|
|
||||||
- stop (Bool): true if the tree search is finished.
|
|
||||||
"""
|
|
||||||
function ExplorerAutreNoeud_relaxlin(listvars, listvals)
|
function ExplorerAutreNoeud_relaxlin(listvars, listvals)
|
||||||
# Le noeud est sondable, on l'enlève de la pile des noeuds à sonder
|
# Le noeud est sondable, on l'enlève de la pile des noeuds à sonder
|
||||||
|
|
||||||
|
@ -208,32 +150,34 @@ function AllDef(x)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
"""Solve the KnapSack problem for the data contained in `filename`.
|
|
||||||
|
|
||||||
Args: \\
|
|
||||||
- filename (String): the name of the file to read.
|
|
||||||
|
|
||||||
Returns: \\
|
|
||||||
- trParentnodes (Vector{Integer}): the parents nodes, to plot the tree.
|
|
||||||
- trChildnodes (Vector{Integer}): the child nodes, to plot the tree.
|
|
||||||
- trNamenodes (Vector{Integer}): the name of the nodes, to plot the tree.
|
|
||||||
"""
|
|
||||||
function SolveKnapInstance(filename)
|
function SolveKnapInstance(filename)
|
||||||
|
|
||||||
stop = false
|
stop = false
|
||||||
affich = false
|
affich = true
|
||||||
|
|
||||||
# Extraction des données
|
# Extraction des données
|
||||||
price, weight, capacity = readKnapInstance(filename)
|
price, weight, capacity = readKnapInstance(filename)
|
||||||
|
|
||||||
if affich
|
tri = true
|
||||||
println("Capacity : ", capacity, " | Number of objects : ", length(price), "\n")
|
if tri
|
||||||
|
couples = zip(price, weight)
|
||||||
|
couples = sort(collect(couples), by = x -> x[1] / x[2])
|
||||||
|
unzip(a) = map(x->getfield.(a, x), fieldnames(eltype(a)))
|
||||||
|
price, weight = unzip(couples)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Pour dessiner le graph
|
expected = split(split(filename, "-")[2], ".")[1]
|
||||||
trParentnodes = Int64[]
|
nodes_nb = length(price)
|
||||||
trChildnodes = Int64[]
|
nodes_max = 2^nodes_nb
|
||||||
trNamenodes = []
|
|
||||||
|
if affich
|
||||||
|
println("---", filename, "---")
|
||||||
|
println("Capacity = ", capacity)
|
||||||
|
println("Number of objects = ", nodes_nb)
|
||||||
|
println("Expected optimal value = ", expected)
|
||||||
|
println("Maximum number of nodes = ", nodes_max)
|
||||||
|
println()
|
||||||
|
end
|
||||||
|
|
||||||
# Liste des variable pour naviguer de noeuds en noeuds
|
# Liste des variable pour naviguer de noeuds en noeuds
|
||||||
listvars = []
|
listvars = []
|
||||||
|
@ -242,6 +186,7 @@ function SolveKnapInstance(filename)
|
||||||
|
|
||||||
# La meilleur solution et sa valeur
|
# La meilleur solution et sa valeur
|
||||||
BestProfit = -1
|
BestProfit = -1
|
||||||
|
LastBestProfit = -1
|
||||||
Bestsol = []
|
Bestsol = []
|
||||||
|
|
||||||
# Compter le nombre de noeud explorés
|
# Compter le nombre de noeud explorés
|
||||||
|
@ -251,7 +196,6 @@ function SolveKnapInstance(filename)
|
||||||
push!(listvars, [-1 for p in price])
|
push!(listvars, [-1 for p in price])
|
||||||
push!(listvals, Objective(last(listvars), price))
|
push!(listvals, Objective(last(listvars), price))
|
||||||
push!(listnodes, 1)
|
push!(listnodes, 1)
|
||||||
push!(trNamenodes, 0)
|
|
||||||
newnodeid = 2
|
newnodeid = 2
|
||||||
|
|
||||||
while (!stop)
|
while (!stop)
|
||||||
|
@ -259,52 +203,40 @@ function SolveKnapInstance(filename)
|
||||||
# Le noeud actuel
|
# Le noeud actuel
|
||||||
x = last(listvars)
|
x = last(listvars)
|
||||||
|
|
||||||
if affich && current_node_number % 10000 == 0
|
if affich && LastBestProfit != BestProfit
|
||||||
println("----------\nNode n°", current_node_number, " :\n")
|
println("Node n°", current_node_number, ": \tBestProfit = ", BestProfit)
|
||||||
println("Previous Solution memorized ", " with bestprofit ", BestProfit, "\n")
|
LastBestProfit = BestProfit
|
||||||
end
|
end
|
||||||
|
|
||||||
# Test de sondabilité du noeud actuel
|
# Test de sondabilité du noeud actuel
|
||||||
# -> On mets a jour la solution et sa valeur si besoin
|
# -> On mets a jour la solution et sa valeur si besoin
|
||||||
TA, TO, TR, Bestsol, BestProfit = TestsSondabilite_relaxlin(x, price, weight, capacity, BestProfit, Bestsol, affich)
|
TA, TO, TR, Bestsol, BestProfit = TestsSondabilite_relaxlin(x, price, weight, capacity, BestProfit, Bestsol, false)
|
||||||
|
|
||||||
is_node_sondable = TA || TO || TR
|
is_node_sondable = TA || TO || TR
|
||||||
if (!is_node_sondable)
|
if (!is_node_sondable)
|
||||||
# Le noeud n'est pas sondable, on le sépare en 2 sous-noeuds
|
# Le noeud n'est pas sondable, on le sépare en 2 sous-noeuds
|
||||||
listvars, listvals = SeparerNoeud_relaxlin(price, listvars, listvals)
|
listvars, listvals = SeparerNoeud_relaxlin(price, listvars, listvals)
|
||||||
|
|
||||||
curnode = pop!(listnodes)
|
|
||||||
|
|
||||||
push!(trParentnodes, curnode)
|
|
||||||
push!(trParentnodes, curnode)
|
|
||||||
|
|
||||||
push!(listnodes, newnodeid + 1)
|
|
||||||
push!(listnodes, newnodeid)
|
|
||||||
|
|
||||||
push!(trChildnodes, newnodeid)
|
|
||||||
push!(trChildnodes, newnodeid + 1)
|
|
||||||
|
|
||||||
push!(trNamenodes, newnodeid - 1)
|
|
||||||
push!(trNamenodes, newnodeid)
|
|
||||||
|
|
||||||
newnodeid += 2
|
newnodeid += 2
|
||||||
|
|
||||||
else
|
else
|
||||||
# Le noeud est sondable, on passe au noeud suivant
|
# Le noeud est sondable, on passe au noeud suivant
|
||||||
listvars, listvals, stop = ExplorerAutreNoeud_relaxlin(listvars, listvals)
|
listvars, listvals, stop = ExplorerAutreNoeud_relaxlin(listvars, listvals)
|
||||||
|
|
||||||
pop!(listnodes)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
current_node_number += 1
|
current_node_number += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if affich
|
println("\n--------------------------------------------------")
|
||||||
println("\n******\n\nOptimal value = ", BestProfit, "\n\nOptimal x = ", Bestsol)
|
println("Expected optimal value = ", expected)
|
||||||
|
println("Optimal value = ", BestProfit)
|
||||||
|
println("Optimal x = ", Bestsol)
|
||||||
|
println("Maximum number of nodes = ", nodes_max)
|
||||||
|
println("Nodes explored = ", current_node_number)
|
||||||
|
if parse(Int64, expected) == BestProfit
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
return trParentnodes, trChildnodes, trNamenodes
|
|
||||||
end
|
end
|
||||||
|
|
||||||
trParentnodes, trChildnodes, trNamenodes = SolveKnapInstance("data/circle/knapPI_16_10000_1000_5_-912198.opb")
|
SolveKnapInstance(ARGS[1])
|
||||||
# graphplot(trParentnodes, trChildnodes, names = trNamenodes, method = :tree)
|
|
Loading…
Reference in a new issue