Skip to content

Commit

Permalink
conversor fix: #59 and using global random seed
Browse files Browse the repository at this point in the history
  • Loading branch information
rcabanasdepaz committed Feb 14, 2021
1 parent 8d232d7 commit a3beffb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
import ch.idsia.crema.factor.credal.linear.ExtensiveLinearFactor;
import ch.idsia.crema.solver.LinearSolver;
import ch.idsia.crema.solver.commons.Simplex;
import ch.idsia.crema.utility.RandomUtil;
import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;

import java.util.Random;

// FIXME rename
@SuppressWarnings("rawtypes")
public class ExtensiveLinearToRandomBayesianFactor implements Converter<ExtensiveLinearFactor, BayesianFactor> {
private final Random random = new Random();
private final Random random = RandomUtil.getRandom();

public BayesianFactor apply(ExtensiveLinearFactor s) {
return apply(s, -1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import ch.idsia.crema.solver.LinearSolver;
import ch.idsia.crema.solver.SolverFactory;
import ch.idsia.crema.utility.ArraysUtil;
import ch.idsia.crema.utility.RandomUtil;
import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;

import java.util.Random;
Expand All @@ -31,7 +32,7 @@ public class SeparateLinearToRandomBayesian implements Converter<SeparateLinearF
private boolean log = false;

public SeparateLinearToRandomBayesian() {
random = new Random();
random = RandomUtil.getRandom();
}

public SeparateLinearToRandomBayesian(int seed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@ public M getInferenceModel(int target, TIntIntMap evidence) {
return (M) removeBarren.execute(new CutObservedSepHalfspace().execute(model, evidence), target, evidence);
}

@Override
public IntervalFactor query(int target) throws InterruptedException{
return query(target, new TIntIntHashMap());
}

@Override
public IntervalFactor query(int target, TIntIntMap evidence) throws InterruptedException {

M infModel = getInferenceModel(target, evidence);

TIntIntMap filteredEvidence = new TIntIntHashMap(evidence);
TIntIntMap filteredEvidence = new TIntIntHashMap();

// update the evidence
for (int v : evidence.keys()) {
Expand Down

0 comments on commit a3beffb

Please sign in to comment.