From ef349ea5f62cfa208a807aebfd2873be6e67ba12 Mon Sep 17 00:00:00 2001 From: eugenefischer <66030419+eugenefischer@users.noreply.github.com> Date: Fri, 14 Oct 2022 18:44:56 -0500 Subject: [PATCH] Correctly store matching weight --- src/main/java/MaximumWeightBipartiteAuctionMatching.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/MaximumWeightBipartiteAuctionMatching.java b/src/main/java/MaximumWeightBipartiteAuctionMatching.java index 0bad61a..9f21515 100644 --- a/src/main/java/MaximumWeightBipartiteAuctionMatching.java +++ b/src/main/java/MaximumWeightBipartiteAuctionMatching.java @@ -17,7 +17,7 @@ public class MaximumWeightBipartiteAuctionMatching implements MatchingAlgo private final Set partition2; private final BigDecimal delta; private final Set matching; - private final BigDecimal matchingWeight; + private BigDecimal matchingWeight; private boolean swappedPartitions = false; public MaximumWeightBipartiteAuctionMatching(Graph graph, Set partition1, Set partition2) { @@ -26,6 +26,7 @@ public class MaximumWeightBipartiteAuctionMatching implements MatchingAlgo this.partition2 = Objects.requireNonNull(partition2, "Partition 2 cannot be null"); int n = Math.max(partition1.size(), partition2.size()); this.delta = BigDecimal.valueOf(1 / ((double) n + 1)); +// this.delta = BigDecimal.valueOf(n/2); this.matching = new LinkedHashSet<>(); this.matchingWeight = BigDecimal.ZERO; } @@ -35,7 +36,7 @@ public class MaximumWeightBipartiteAuctionMatching implements MatchingAlgo Method coded using MaximumWeightBipartiteMatching.class from JgraphT as a model */ @Override - public Matching getMatching() { + public Matching getMatching() { /* * Test input instance @@ -113,7 +114,7 @@ public class MaximumWeightBipartiteAuctionMatching implements MatchingAlgo } for(E edge: matching) { - matchingWeight.add(BigDecimal.valueOf(graph.getEdgeWeight(edge))); + this.matchingWeight = this.matchingWeight.add(BigDecimal.valueOf(graph.getEdgeWeight(edge))); }