Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Algorithm Engineering
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
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dennis Miroslav Weiß
Algorithm Engineering
Commits
2c91a4bb
Commit
2c91a4bb
authored
3 years ago
by
Dennis Weiss
Browse files
Options
Downloads
Patches
Plain Diff
Using heuristic to decide branching order
parent
cb0299b5
Branches
all-with-parameter
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
algorithm-engineering-search-tree/src/main/java/berlin/tu/algorithmengineering/searchtree/Main.java
+8
-8
8 additions, 8 deletions
.../java/berlin/tu/algorithmengineering/searchtree/Main.java
with
8 additions
and
8 deletions
algorithm-engineering-search-tree/src/main/java/berlin/tu/algorithmengineering/searchtree/Main.java
+
8
−
8
View file @
2c91a4bb
...
@@ -267,10 +267,10 @@ public class Main {
...
@@ -267,10 +267,10 @@ public class Main {
return
weightedClusterEditingBinarySearch
(
graph
,
k
+
1
,
hi
);
return
weightedClusterEditingBinarySearch
(
graph
,
k
+
1
,
hi
);
}
}
private
static
ResultEdgeExistsWithSolutionSize
getUpperBound
(
Graph
graph
,
int
iter
,
boolean
simulatedAnnealing
)
{
private
static
ResultEdgeExistsWithSolutionSize
getUpperBound
(
Graph
graph
,
int
greedyIterations
,
int
simulatedAnnealing
Iterations
)
{
ResultEdgeExistsWithSolutionSize
resultEdgeExistsWithSolutionSize
=
new
ResultEdgeExistsWithSolutionSize
(
null
,
Integer
.
MAX_VALUE
);
ResultEdgeExistsWithSolutionSize
resultEdgeExistsWithSolutionSize
=
new
ResultEdgeExistsWithSolutionSize
(
null
,
Integer
.
MAX_VALUE
);
for
(
int
i
=
0
;
i
<
iter
;
i
++)
{
for
(
int
i
=
0
;
i
<
greedyIterations
;
i
++)
{
boolean
[][]
heuristicResultEdgeExists
=
Heuristics
.
getGreedyHeuristicNeighborhood
(
graph
);
boolean
[][]
heuristicResultEdgeExists
=
Heuristics
.
getGreedyHeuristicNeighborhood
(
graph
);
int
heuristicCost
=
Utils
.
getCostToChange
(
graph
,
heuristicResultEdgeExists
);
int
heuristicCost
=
Utils
.
getCostToChange
(
graph
,
heuristicResultEdgeExists
);
if
(
heuristicCost
<
resultEdgeExistsWithSolutionSize
.
getSolutionSize
())
{
if
(
heuristicCost
<
resultEdgeExistsWithSolutionSize
.
getSolutionSize
())
{
...
@@ -279,9 +279,9 @@ public class Main {
...
@@ -279,9 +279,9 @@ public class Main {
}
}
}
}
if
(
simulatedAnnealing
)
{
if
(
simulatedAnnealing
Iterations
>
0
)
{
SimulatedAnnealing
.
performSimulatedAnnealing
(
SimulatedAnnealing
.
performSimulatedAnnealing
(
graph
,
Utils
.
copy
(
resultEdgeExistsWithSolutionSize
.
getResultEdgeExists
(),
graph
.
getNumberOfVertices
()),
20_000
,
resultEdgeExistsWithSolutionSize
graph
,
Utils
.
copy
(
resultEdgeExistsWithSolutionSize
.
getResultEdgeExists
(),
graph
.
getNumberOfVertices
()),
simulatedAnnealingIterations
,
resultEdgeExistsWithSolutionSize
);
);
}
}
...
@@ -289,7 +289,7 @@ public class Main {
...
@@ -289,7 +289,7 @@ public class Main {
}
}
private
static
ResultEdgeExistsWithSolutionSize
weightedClusterEditingOptim
(
Graph
graph
)
{
private
static
ResultEdgeExistsWithSolutionSize
weightedClusterEditingOptim
(
Graph
graph
)
{
ResultEdgeExistsWithSolutionSize
resultEdgeExistsWithSolutionSizeOfUpperBound
=
getUpperBound
(
graph
,
32
,
true
);
ResultEdgeExistsWithSolutionSize
resultEdgeExistsWithSolutionSizeOfUpperBound
=
getUpperBound
(
graph
,
32
,
20_000
);
return
weightedClusterEditingOptim
(
return
weightedClusterEditingOptim
(
graph
,
0
,
resultEdgeExistsWithSolutionSizeOfUpperBound
.
getResultEdgeExists
(),
graph
,
0
,
resultEdgeExistsWithSolutionSizeOfUpperBound
.
getResultEdgeExists
(),
...
@@ -362,14 +362,14 @@ public class Main {
...
@@ -362,14 +362,14 @@ public class Main {
P3
p3
=
getBiggestWeightP3
(
graph
,
p3List
);
P3
p3
=
getBiggestWeightP3
(
graph
,
p3List
);
MergeVerticesInfo
mergeVerticesInfo
=
graph
.
mergeVertices
(
p3
.
getU
(),
p3
.
getV
());
MergeVerticesInfo
mergeVerticesInfo
=
graph
.
mergeVertices
(
p3
.
getU
(),
p3
.
getV
());
ResultEdgeExistsWithSolutionSize
resultEdgeExistsWithSolutionSizeUpperBoundAfterMerge
=
getUpperBound
(
graph
,
16
,
false
);
ResultEdgeExistsWithSolutionSize
resultEdgeExistsWithSolutionSizeUpperBoundAfterMerge
=
getUpperBound
(
graph
,
8
,
200
);
graph
.
revertMergeVertices
(
mergeVerticesInfo
);
graph
.
revertMergeVertices
(
mergeVerticesInfo
);
int
costToFlip
=
graph
.
flipEdgeAndSetForbidden
(
p3
.
getU
(),
p3
.
getV
());
int
costToFlip
=
graph
.
flipEdgeAndSetForbidden
(
p3
.
getU
(),
p3
.
getV
());
ResultEdgeExistsWithSolutionSize
resultEdgeExistsWithSolution
s
SizeUpperBoundAfterDeletion
=
getUpperBound
(
graph
,
16
,
false
);
ResultEdgeExistsWithSolutionSize
resultEdgeExistsWithSolutionSizeUpperBoundAfterDeletion
=
getUpperBound
(
graph
,
8
,
200
);
graph
.
flipBackForbiddenEdge
(
p3
.
getU
(),
p3
.
getV
(),
costToFlip
);
graph
.
flipBackForbiddenEdge
(
p3
.
getU
(),
p3
.
getV
(),
costToFlip
);
if
(
resultEdgeExistsWithSolution
s
SizeUpperBoundAfterDeletion
.
getSolutionSize
()
<
resultEdgeExistsWithSolutionSizeUpperBoundAfterMerge
.
getSolutionSize
())
{
if
(
resultEdgeExistsWithSolutionSizeUpperBoundAfterDeletion
.
getSolutionSize
()
+
mergeVerticesInfo
.
getCost
()
<
resultEdgeExistsWithSolutionSizeUpperBoundAfterMerge
.
getSolutionSize
()
-
costToFlip
)
{
costToFlip
=
graph
.
flipEdgeAndSetForbidden
(
p3
.
getU
(),
p3
.
getV
());
costToFlip
=
graph
.
flipEdgeAndSetForbidden
(
p3
.
getU
(),
p3
.
getV
());
ResultEdgeExistsWithSolutionSize
solutionAfterDeletion
=
weightedClusterEditingOptim
(
ResultEdgeExistsWithSolutionSize
solutionAfterDeletion
=
weightedClusterEditingOptim
(
graph
,
costToEdit
-
costToFlip
,
upperBoundSolutionEdgeExists
,
upperBound
graph
,
costToEdit
-
costToFlip
,
upperBoundSolutionEdgeExists
,
upperBound
...
...
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