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
67753d94
Commit
67753d94
authored
4 months ago
by
OUATTARA Sie
Browse files
Options
Downloads
Patches
Plain Diff
on stoke recupere la liste des objets du sac optimal
parent
f62f4c98
Branches
Branches containing commit
No related tags found
1 merge request
!5
on stoke recupere la liste des objets du sac optimal
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
out/production/aroTP2/App.class
+0
-0
0 additions, 0 deletions
out/production/aroTP2/App.class
src/App.java
+1
-3
1 addition, 3 deletions
src/App.java
src/Backpack.java
+4
-4
4 additions, 4 deletions
src/Backpack.java
src/Loot.java
+1
-1
1 addition, 1 deletion
src/Loot.java
with
6 additions
and
8 deletions
out/production/aroTP2/App.class
+
0
−
0
View file @
67753d94
No preview for this file type
This diff is collapsed.
Click to expand it.
src/App.java
+
1
−
3
View file @
67753d94
...
...
@@ -3,9 +3,7 @@ import java.util.List;
public
class
App
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Backpack
backpack
=
new
InstanceReader
().
read
(
"src/sac
4
"
);
Backpack
backpack
=
new
InstanceReader
().
read
(
"src/sac
Test
"
);
backpack
.
solve
();
System
.
out
.
println
(
"meilleur solution :"
+
backpack
.
getBestValue
());
System
.
out
.
println
(
"meilleur solution :"
+
Arrays
.
toString
(
backpack
.
getBestSolution
()));
}
}
This diff is collapsed.
Click to expand it.
src/Backpack.java
+
4
−
4
View file @
67753d94
import
java.util.Arrays
;
import
java.util.Comparator
;
import
java.util.List
;
...
...
@@ -7,8 +8,8 @@ public class Backpack {
private
int
bestValue
=
0
;
private
int
currentWeight
=
0
;
private
int
currentValue
=
0
;
private
boolean
[]
currentSolution
;
private
boolean
[]
bestSolution
;
private
final
boolean
[]
currentSolution
;
private
final
boolean
[]
bestSolution
;
public
Backpack
(
int
capacity
,
List
<
Loot
>
loots
)
{
this
.
capacity
=
capacity
;
...
...
@@ -21,8 +22,7 @@ public class Backpack {
this
.
sortByRatio
();
explore_from
(
0
);
System
.
out
.
println
(
"La valeur optimale est : "
+
bestValue
);
System
.
out
.
println
(
"Objets inclus dans la solution optimale : "
+
bestSolution
);
System
.
out
.
println
(
"Objets inclus dans la solution optimale : "
+
Arrays
.
toString
(
bestSolution
));
}
public
String
toString
(){
...
...
This diff is collapsed.
Click to expand it.
src/Loot.java
+
1
−
1
View file @
67753d94
public
class
Loot
{
private
int
weight
,
value
;
private
final
int
weight
,
value
;
private
final
float
ratio
;
public
Loot
(
int
weight
,
int
value
)
{
...
...
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