removed the trace logging
it incurs a performance cost even when logging is not disabled, since getAcceptanceRate will always get called.
@@ -2,12 +2,10 @@ package io.improbable.keanu.algorithms.mcmc.proposal;
import com.google.common.collect.Maps;
import io.improbable.keanu.vertices.Vertex;
-import lombok.extern.slf4j.Slf4j;
import java.util.Map;
import java.util.Set;
-@Slf4j
public class AcceptanceRateTracker implements ProposalListener {
private Map<Set<Vertex>, Integer> numApplied = Maps.newHashMap();
@@ -16,13 +14,7 @@ public class AcceptanceRateTracker implements ProposalListener {
@Override
public void onProposalApplied(Proposal proposal) {
Set<Vertex> key = proposal.getVerticesWithProposal();
- if (numApplied.keySet().contains(key)) {
- log.trace(String.format(" Applied proposal: %.4f for %s", getAcceptanceRate(key), proposal.getVerticesWithProposal()));
- } else {
- log.trace(String.format(" Applied first proposal for %s", proposal.getVerticesWithProposal()));
- numApplied.put(key, 0);
- }
- Integer previousValue = numApplied.get(key);
+ Integer previousValue = numApplied.getOrDefault(key, 0);
numApplied.put(key, previousValue + 1);
}
