Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OAD - TP2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maxime POULAIN
OAD - TP2
Commits
fc4c50c9
Commit
fc4c50c9
authored
Nov 5, 2021
by
Sinaro LY
Browse files
Options
Downloads
Patches
Plain Diff
grasp un peu plus joli
parent
864e2866
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Code/JobShop/main.cpp
+2
-20
2 additions, 20 deletions
Code/JobShop/main.cpp
Code/JobShop/solution.cpp
+3
-12
3 additions, 12 deletions
Code/JobShop/solution.cpp
Code/JobShop/x64/Debug/solution.obj
+0
-0
0 additions, 0 deletions
Code/JobShop/x64/Debug/solution.obj
with
5 additions
and
32 deletions
Code/JobShop/main.cpp
+
2
−
20
View file @
fc4c50c9
...
@@ -8,35 +8,17 @@
...
@@ -8,35 +8,17 @@
using
namespace
std
;
using
namespace
std
;
int
main
()
{
int
main
()
{
srand
(
210584
97
);
srand
(
210584
65
);
t_graphe
graph
;
t_graphe
graph
;
graph
=
lecture_fichier
(
"la01.txt"
);
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
;
solution_t
sol
;
bierwirth
v
=
generateVector
(
graph
.
nb_pieces
,
graph
.
nb_machines
);
bierwirth
v
=
generateVector
(
graph
.
nb_pieces
,
graph
.
nb_machines
);
//sol = evaluer(v, graph);
//cout << "oui" << endl;
sol
.
cost
=
INT16_MAX
;
sol
.
cost
=
INT16_MAX
;
grasp
(
&
sol
,
graph
,
666
);
grasp
(
&
sol
,
graph
,
666
);
//
affiche_solution(sol);
affiche_solution
(
sol
);
cout
<<
"meilleur cout final : "
<<
sol
.
cost
<<
endl
;
cout
<<
"meilleur cout final : "
<<
sol
.
cost
<<
endl
;
...
...
...
...
This diff is collapsed.
Click to expand it.
Code/JobShop/solution.cpp
+
3
−
12
View file @
fc4c50c9
...
@@ -260,12 +260,10 @@ void grasp(solution_t* sol, t_graph graphe, int best_cost)
...
@@ -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
)
void
grasp
(
solution_t
*
sol
,
t_graph
graphe
,
int
best_cost
)
{
{
//solution_t solution_tab[SOLUTION_MAX_TAB];
solution_t
new_solution
;
solution_t
new_solution
;
solution_t
best_neighbour
;
solution_t
best_neighbour
;
bierwirth
v
;
bierwirth
v
;
int
nb_neighbours
=
0
;
int
nb_neighbours
=
0
;
//int i = 0;
int
nb_it
=
0
;
int
nb_it
=
0
;
int
count
;
int
count
;
int
size
=
graphe
.
nb_machines
*
graphe
.
nb_pieces
;
int
size
=
graphe
.
nb_machines
*
graphe
.
nb_pieces
;
...
@@ -287,22 +285,15 @@ void grasp(solution_t* sol, t_graph graphe, int best_cost)
...
@@ -287,22 +285,15 @@ void grasp(solution_t* sol, t_graph graphe, int best_cost)
do
do
{
{
v
=
generateVector
(
graphe
.
nb_pieces
,
graphe
.
nb_machines
);
v
=
generateVector
(
graphe
.
nb_pieces
,
graphe
.
nb_machines
);
new_solution
=
solution
::
rechercheLocale
(
v
,
graphe
,
1000
);
new_solution
=
solution
::
rechercheLocale
(
v
,
graphe
,
1000
);
new_solution
.
v
=
v
;
new_solution
.
v
=
v
;
//cout << "oui2" << endl;
}
while
(
sameH
(
new_solution
,
hash
,
HASH_SIZE
));
}
while
(
sameH
(
new_solution
,
hash
,
HASH_SIZE
));
//cout << "oui3" << endl;
while
(
nb_neighbours
<
MAX_NEIGHBOURS
&&
count
<
MAX_COUNT
&&
nb_neighbours
<
1
)
while
(
nb_neighbours
<
MAX_NEIGHBOURS
&&
count
<
MAX_COUNT
&&
nb_neighbours
<
1
)
{
{
new_solution
=
genNeighbour
(
new_solution
.
v
,
size
,
graphe
.
nb_pieces
,
graphe
.
nb_machines
);
new_solution
=
genNeighbour
(
new_solution
.
v
,
size
,
graphe
.
nb_pieces
,
graphe
.
nb_machines
);
v
=
new_solution
.
v
;
v
=
new_solution
.
v
;
//cout << "oui4" << endl;
//vecteur_valide(v, graphe.nb_machines, graphe.nb_pieces);
new_solution
=
solution
::
rechercheLocale
(
v
,
graphe
,
1000
);
new_solution
=
solution
::
rechercheLocale
(
v
,
graphe
,
1000
);
//cout << new_solution.cost << endl;
new_solution
.
v
=
v
;
new_solution
.
v
=
v
;
if
(
sameH
(
new_solution
,
hash
,
HASH_SIZE
)
==
0
)
//s'ils ont un hash diffrent
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)
...
@@ -323,13 +314,13 @@ void grasp(solution_t* sol, t_graph graphe, int best_cost)
if
(
best_neighbour
.
cost
<
sol
->
cost
)
if
(
best_neighbour
.
cost
<
sol
->
cost
)
{
{
*
sol
=
best_neighbour
;
*
sol
=
best_neighbour
;
cout
<<
best_neighbour
.
cost
<<
endl
;
//
cout << best_neighbour.cost << endl;
}
}
++
nb_it
;
++
nb_it
;
}
}
cout
<<
"nombre d'iterations : "
<<
nb_it
<<
endl
;
}
}
This diff is collapsed.
Click to expand it.
Code/JobShop/x64/Debug/solution.obj
+
0
−
0
View file @
fc4c50c9
No preview for this file type
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment