Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Maxime POULAIN
OAD - TP2
Commits
6a835c0c
Commit
6a835c0c
authored
Oct 22, 2021
by
Maxime
Browse files
wip recherche local : out of range in evaluer
parent
24b1ca86
Changes
11
Hide whitespace changes
Inline
Side-by-side
Code/.vs/Optimisation/v16/ipch/AutoPCH/3b104b87a075d561/SOLUTION.ipch
0 → 100644
View file @
6a835c0c
File added
Code/.vs/Optimisation/v16/ipch/AutoPCH/6c56ff6a3a0ad06b/MAIN.ipch
0 → 100644
View file @
6a835c0c
File added
Code/.vs/Optimisation/v16/ipch/AutoPCH/e4f29177cf1719ec/BIERWIRTH.ipch
0 → 100644
View file @
6a835c0c
File added
Code/JobShop/bierwirth.cpp
View file @
6a835c0c
...
...
@@ -9,7 +9,8 @@ using namespace std;
bierwirth
generateVector
(
int
n
,
int
m
)
{
vector
<
int
>
vect
(
n
,
m
);
vector
<
int
>
vectPiece
;
bierwirth
v
(
n
*
m
);
long
size
=
n
*
m
;
bierwirth
v
(
size
);
int
maxIteration
=
n
*
m
;
int
indexRandom
;
...
...
@@ -34,17 +35,26 @@ bierwirth generateVector(int n, int m) {
return
v
;
}
void
permutation
(
bierwirth
&
vector
,
pr_t
i
,
pr_t
j
,
int
n
,
int
m
){
//int aux = vector[j];
//vector[j] = vector[i];
//vector[i] = aux;
cout
<<
vector
.
size
()
<<
endl
;
void
permutation
(
bierwirth
&
vectorIn
,
bierwirth
&
vectorOut
,
pr_t
i
,
pr_t
j
,
int
n
,
int
m
)
{
int
iIndex
=
prToIndex
(
vectorIn
,
i
,
n
,
m
);
int
jIndex
=
prToIndex
(
vectorIn
,
j
,
n
,
m
);
vectorOut
[
jIndex
]
=
vectorIn
[
iIndex
];
vectorOut
[
iIndex
]
=
vectorIn
[
jIndex
];
}
int
prToIndex
(
bierwirth
&
vector
,
pr_t
i
,
int
n
,
int
m
)
{
int
index
=
n
*
m
-
1
;
int
cpt
=
0
;
while
(
index
>=
0
)
{
if
(
vector
[
index
]
==
i
.
piece
)
cpt
++
;
if
(
cpt
==
m
-
i
.
rang
+
1
)
return
index
;
index
--
;
}
return
index
;
}
\ No newline at end of file
Code/JobShop/bierwirth.h
View file @
6a835c0c
#pragma once
#define MAX_VECTOR_SIZE 20
#define MAX_VECTOR_SIZE 20
0
#include
<vector>
#include
"pr.h"
...
...
@@ -9,4 +9,5 @@ typedef std::vector<int> bierwirth;
bierwirth
generateVector
(
int
n
,
int
m
);
void
permutation
(
bierwirth
&
vector
,
pr_t
i
,
pr_t
j
);
\ No newline at end of file
void
permutation
(
bierwirth
&
vectorIn
,
bierwirth
&
vectorOut
,
pr_t
i
,
pr_t
j
,
int
n
,
int
m
);
int
prToIndex
(
bierwirth
&
vector
,
pr_t
i
,
int
n
,
int
m
);
\ No newline at end of file
Code/JobShop/main.cpp
View file @
6a835c0c
...
...
@@ -8,23 +8,26 @@
using
namespace
std
;
int
main
()
{
srand
(
1000074
);
srand
(
1000075
);
t_graphe
graphe
;
graphe
=
lecture_fichier
(
"cours.txt"
);
affiche_taches
(
graphe
);
bierwirth
v
{
0
,
0
,
1
,
1
,
0
,
2
,
1
,
2
,
2
};
solution_t
sol
=
evaluer
(
v
,
graphe
);
t_graphe
graph
;
graph
=
lecture_fichier
(
"la01.txt"
);
affiche_taches
(
graph
);
//bierwirth v{0, 0, 1, 1, 0, 2, 1, 2, 2};
bierwirth
v
=
generateVector
(
graph
.
nb_pieces
,
graph
.
nb_machines
);
solution_t
sol
=
evaluer
(
v
,
graph
);
affiche_solution
(
sol
);
auto
solRech
=
solution
::
rechercheLocale
(
v
,
graph
,
1000
);
cout
<<
endl
<<
endl
<<
endl
;
affiche_solution
(
sol
);
//t_graphe graphe;
//graphe = lecture_fichier("la01.txt");
//affiche_taches(graphe);
//solution_t sol = evaluer(generateVector(graphe.nb_pieces, graphe.nb_machines), graphe);
auto
v
=
generateVector
(
2
,
3
);
utils
::
print
(
v
);
cout
<<
v
.
size
()
<<
endl
;
return
0
;
}
\ No newline at end of file
Code/JobShop/solution.cpp
View file @
6a835c0c
#include
"solution.h"
#include
"gestion_graphes.h"
#include
"utils.h"
void
solution
::
rechercheLocale
(
bierwirth
v
,
solution_t
&
solution
,
t_graph
&
graph
)
{
solution_t
solution
::
rechercheLocale
(
bierwirth
&
v
,
t_graph
&
graph
,
int
maxIteration
)
{
solution_t
solutionEvaluated
=
evaluer
(
v
,
graph
);
pr_t
j
=
solution
.
lastFather
;
pr_t
jFather
=
solution
.
father
[
j
.
piece
][
j
.
rang
];
bierwirth
vOpti
;
solution_t
solutionOpti
;
pr_t
j
=
solutionEvaluated
.
lastFather
;
pr_t
jFather
=
solutionEvaluated
.
father
[
j
.
piece
][
j
.
rang
];
bierwirth
vInput
=
v
;
bierwirth
vOpti
=
v
;
int
iteration
=
0
;
while
((
jFather
.
piece
!=
0
&&
jFather
.
rang
!=
0
)
&&
iteration
<
SOLUTION_MAX_ITERATION
)
{
while
((
jFather
.
piece
!=
0
&&
jFather
.
rang
!=
0
)
&&
iteration
<
maxIteration
)
{
cout
<<
"Iteration - "
<<
iteration
<<
endl
;
if
(
graph
.
mach
[
j
.
piece
][
j
.
rang
]
==
graph
.
mach
[
jFather
.
piece
][
jFather
.
rang
])
{
cout
<<
"Inside "
<<
graph
.
mach
[
j
.
piece
][
j
.
rang
]
<<
endl
;
cout
<<
"Piece "
<<
j
.
piece
<<
endl
;
cout
<<
"Rang "
<<
j
.
rang
<<
endl
<<
endl
;
permutation
(
vInput
,
vOpti
,
j
,
jFather
,
graph
.
nb_pieces
,
graph
.
nb_machines
);
solutionOpti
=
evaluer
(
vOpti
,
graph
);
if
(
solutionOpti
.
cost
<
solutionEvaluated
.
cost
)
{
vInput
=
vOpti
;
solutionEvaluated
=
solutionOpti
;
j
=
solutionEvaluated
.
lastFather
;
jFather
=
solutionEvaluated
.
father
[
j
.
piece
][
j
.
rang
];
}
else
{
j
=
jFather
;
jFather
=
solutionEvaluated
.
father
[
j
.
piece
][
j
.
rang
];
}
}
else
{
j
=
jFather
;
jFather
=
solutionEvaluated
.
father
[
j
.
piece
][
j
.
rang
];
}
iteration
++
;
}
cout
<<
"Iteration : "
<<
iteration
<<
endl
;
return
solutionEvaluated
;
}
solution_t
evaluer
(
bierwirth
v
,
t_graphe
graphe
)
{
...
...
@@ -49,9 +76,10 @@ solution_t evaluer(bierwirth v, t_graphe graphe) {
if
(
npj
==
0
)
{
m
[
j
][
npj
]
=
0
;
sol
.
father
[
j
][
npj
]
=
{
-
1
,
-
1
};
sol
.
father
[
j
][
npj
]
=
{
-
1
,
-
1
};
}
else
{
}
else
{
m
[
j
][
npj
]
=
m
[
j
][
npj
-
1
]
+
graphe
.
d
[
j
][
npj
-
1
];
sol
.
father
[
j
][
npj
].
piece
=
j
;
...
...
Code/JobShop/solution.h
View file @
6a835c0c
...
...
@@ -4,7 +4,6 @@
#include
"pr.h"
#define SOLUTION_MAX_SIZE 100
#define SOLUTION_MAX_ITERATION 100
...
...
@@ -24,7 +23,9 @@ void affiche_solution(solution_t sol);
class
solution
{
static
void
rechercheLocale
(
bierwirth
v
,
solution_t
&
solution
,
t_graph
&
graph
);
public:
static
solution_t
rechercheLocale
(
bierwirth
&
v
,
t_graph
&
graph
,
int
maxIteration
);
};
...
...
Code/JobShop/x64/Debug/gestion_graphe.obj
View file @
6a835c0c
No preview for this file type
Code/JobShop/x64/Debug/solution.obj
View file @
6a835c0c
No preview for this file type
Code/View/x64/Debug/View.vcxproj.AssemblyReference.cache
View file @
6a835c0c
No preview for this file type
Write
Preview
Supports
Markdown
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