Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Branch-and-Bound
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OUATTARA Sie
Branch-and-Bound
Commits
0e6e110a
Commit
0e6e110a
authored
4 months ago
by
OUATTARA Sie
Browse files
Options
Downloads
Patches
Plain Diff
ajout de varaible pour coimpter le nopmbre de noeuds
parent
67753d94
No related branches found
No related tags found
1 merge request
!6
ajout de varaible pour coimpter le nopmbre de noeuds
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/App.java
+2
-2
2 additions, 2 deletions
src/App.java
src/Backpack.java
+3
-8
3 additions, 8 deletions
src/Backpack.java
with
5 additions
and
10 deletions
src/App.java
+
2
−
2
View file @
0e6e110a
...
...
@@ -3,7 +3,7 @@ import java.util.List;
public
class
App
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Backpack
backpack
=
new
InstanceReader
().
read
(
"
src/sacTest
"
);
Backpack
backpack
=
new
InstanceReader
().
read
(
"
/home/aristidecod/Documents/branch-and-bound/src/sac0
"
);
backpack
.
solve
();
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Backpack.java
+
3
−
8
View file @
0e6e110a
...
...
@@ -10,6 +10,7 @@ public class Backpack {
private
int
currentValue
=
0
;
private
final
boolean
[]
currentSolution
;
private
final
boolean
[]
bestSolution
;
private
int
nodesExplored
=
0
;
public
Backpack
(
int
capacity
,
List
<
Loot
>
loots
)
{
this
.
capacity
=
capacity
;
...
...
@@ -23,6 +24,7 @@ public class Backpack {
explore_from
(
0
);
System
.
out
.
println
(
"La valeur optimale est : "
+
bestValue
);
System
.
out
.
println
(
"Objets inclus dans la solution optimale : "
+
Arrays
.
toString
(
bestSolution
));
System
.
out
.
println
(
"Nombre de nœuds explorés : "
+
nodesExplored
);
}
public
String
toString
(){
...
...
@@ -59,6 +61,7 @@ public class Backpack {
}
private
void
explore_from
(
int
index
)
{
nodesExplored
++;
// Si on a exploré tous les objets
if
(
index
>=
loots
.
size
())
{
if
(
currentValue
>
bestValue
)
{
...
...
@@ -92,12 +95,4 @@ public class Backpack {
// on explore sans l'objet
explore_from
(
index
+
1
);
}
public
int
getBestValue
()
{
return
bestValue
;
}
public
boolean
[]
getBestSolution
()
{
return
bestSolution
;
}
}
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
register
or
sign in
to comment