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
fc4c50c9
Commit
fc4c50c9
authored
Nov 05, 2021
by
Sinaro LY
Browse files
grasp un peu plus joli
parent
864e2866
Changes
3
Hide whitespace changes
Inline
Side-by-side
Code/JobShop/main.cpp
View file @
fc4c50c9
...
...
@@ -8,35 +8,17 @@
using
namespace
std
;
int
main
()
{
srand
(
210584
97
);
srand
(
210584
65
);
t_graphe
graph
;
graph
=
lecture_fichier
(
"la01.txt"
);
//int best = INT16_MAX;
//for (int i = 0; i < 1000; i++)
//{
// bierwirth v = generateVector(graph.nb_pieces, graph.nb_machines);
// solution_t sol = evaluer(v, graph);
// auto solRech = solution::rechercheLocale(v, graph, 1000);
// if (solRech.cost < best) {
// best = solRech.cost;
// }
//}
//cout << best << endl;
solution_t
sol
;
bierwirth
v
=
generateVector
(
graph
.
nb_pieces
,
graph
.
nb_machines
);
//sol = evaluer(v, graph);
//cout << "oui" << endl;
sol
.
cost
=
INT16_MAX
;
grasp
(
&
sol
,
graph
,
666
);
//
affiche_solution(sol);
affiche_solution
(
sol
);
cout
<<
"meilleur cout final : "
<<
sol
.
cost
<<
endl
;
...
...
Code/JobShop/solution.cpp
View file @
fc4c50c9
...
...
@@ -260,12 +260,10 @@ void grasp(solution_t* sol, t_graph graphe, int best_cost)
void
grasp
(
solution_t
*
sol
,
t_graph
graphe
,
int
best_cost
)
{
//solution_t solution_tab[SOLUTION_MAX_TAB];
solution_t
new_solution
;
solution_t
best_neighbour
;
bierwirth
v
;
int
nb_neighbours
=
0
;
//int i = 0;
int
nb_it
=
0
;
int
count
;
int
size
=
graphe
.
nb_machines
*
graphe
.
nb_pieces
;
...
...
@@ -287,22 +285,15 @@ void grasp(solution_t* sol, t_graph graphe, int best_cost)
do
{
v
=
generateVector
(
graphe
.
nb_pieces
,
graphe
.
nb_machines
);
new_solution
=
solution
::
rechercheLocale
(
v
,
graphe
,
1000
);
new_solution
.
v
=
v
;
//cout << "oui2" << endl;
}
while
(
sameH
(
new_solution
,
hash
,
HASH_SIZE
));
//cout << "oui3" << endl;
while
(
nb_neighbours
<
MAX_NEIGHBOURS
&&
count
<
MAX_COUNT
&&
nb_neighbours
<
1
)
{
new_solution
=
genNeighbour
(
new_solution
.
v
,
size
,
graphe
.
nb_pieces
,
graphe
.
nb_machines
);
v
=
new_solution
.
v
;
//cout << "oui4" << endl;
//vecteur_valide(v, graphe.nb_machines, graphe.nb_pieces);
new_solution
=
solution
::
rechercheLocale
(
v
,
graphe
,
1000
);
//cout << new_solution.cost << endl;
new_solution
.
v
=
v
;
if
(
sameH
(
new_solution
,
hash
,
HASH_SIZE
)
==
0
)
//s'ils ont un hash diffrent
...
...
@@ -323,13 +314,13 @@ void grasp(solution_t* sol, t_graph graphe, int best_cost)
if
(
best_neighbour
.
cost
<
sol
->
cost
)
{
*
sol
=
best_neighbour
;
cout
<<
best_neighbour
.
cost
<<
endl
;
//
cout << best_neighbour.cost << endl;
}
++
nb_it
;
}
cout
<<
"nombre d'iterations : "
<<
nb_it
<<
endl
;
}
Code/JobShop/x64/Debug/solution.obj
View file @
fc4c50c9
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