-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_instance.jl
40 lines (33 loc) · 1.11 KB
/
load_instance.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# --------------------------------------------------------------------------- #
# collect the un-hidden filenames available in a given folder
function getfname(pathtofolder)
# recupere tous les fichiers se trouvant dans le repertoire cible
allfiles = readdir(pathtofolder)
# vecteur booleen qui marque les noms de fichiers valides
flag = trues(size(allfiles))
k=1
for f in allfiles
# traite chaque fichier du repertoire
if f[1] == '.'
# fichier cache => supprimer
flag[k] = false
end
k = k+1
end
# extrait les noms valides et retourne le vecteur correspondant
finstances = allfiles[flag]
return finstances
end
# --------------------------------------------------------------------------- #
# loading an instance
function load(fname)
f=open(fname)
# Read the vector of capacity of knapsacks
c = parse.(Int, split(readline(f)) )
# Read the vector of profit of items
p = parse.(Int, split(readline(f)) )
# Read the vector of weight of items
w = parse.(Int, split(readline(f)) )
close(f)
return p, w, c
end