Skip to content

Commit

Permalink
added support for seed provisioning
Browse files Browse the repository at this point in the history
  • Loading branch information
rsfzi committed Dec 18, 2024
1 parent 88c9c7d commit 530d4e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import tools.mdsd.probdist.api.entity.Value;
import tools.mdsd.probdist.api.factory.IProbabilityDistributionFactory;
import tools.mdsd.probdist.api.factory.ProbabilityCalculator;
import tools.mdsd.probdist.api.random.ISeedProvider;
import tools.mdsd.probdist.distributionfunction.Domain;
import tools.mdsd.probdist.distributionfunction.ProbabilityDistribution;
import tools.mdsd.probdist.distributiontype.ProbabilityDistributionSkeleton;
Expand Down Expand Up @@ -161,7 +162,7 @@ public Double probability(List<InputValue<I>> inputs) {
}

@Override
public void init(int seed) {
public void init(ISeedProvider seedProvider) {
if (initialized) {
return;
}
Expand All @@ -170,7 +171,7 @@ public void init(int seed) {
for (LocalProbabilisticNetwork eachLocal : groundNetwork.getLocalProbabilisticModels()) {
for (GroundRandomVariable eachVariable : eachLocal.getGroundRandomVariables()) {
ProbabilityDistributionFunction<I> pdf = probModelHandler.getPDF(eachVariable);
pdf.init(seed);
pdf.init(seedProvider);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import tools.mdsd.probdist.api.entity.ProbabilityDistributionFunction;
import tools.mdsd.probdist.api.entity.Value;
import tools.mdsd.probdist.api.factory.IProbabilityDistributionFactory;
import tools.mdsd.probdist.api.random.ISeedProvider;
import tools.mdsd.probdist.distributionfunction.Domain;
import tools.mdsd.probdist.distributionfunction.ProbabilityDistribution;
import tools.mdsd.probdist.distributiontype.ProbabilityDistributionSkeleton;
Expand Down Expand Up @@ -213,20 +214,20 @@ public Double probability(Trajectory<I> value) {
}

@Override
public void init(int seed) {
public void init(ISeedProvider seedProvider) {
if (initialized) {
throw new RuntimeException("already initialized");
}
initialized = true;

initialDistribution.init(seed);
initialDistribution.init(seedProvider);
for (InterTimeSliceInduction each : dynBehaviourQuery.getInterTimeSliceInductions()) {
ConditionableProbabilityDistribution<I> localCPD = probHandler.getCPD(each.getAppliedGroundVariable());
localCPD.init(seed);
localCPD.init(seedProvider);
}
for (IntraTimeSliceInduction each : dynBehaviourQuery.getIntraTimeSliceInductions()) {
ConditionableProbabilityDistribution<I> localCPD = getCPDFromInitial(each, conditionals);
localCPD.init(seed);
localCPD.init(seedProvider);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import tools.mdsd.probdist.api.factory.ProbabilityDistributionFactory;
import tools.mdsd.probdist.api.parser.DefaultParameterParser;
import tools.mdsd.probdist.api.parser.ParameterParser;
import tools.mdsd.probdist.api.random.NoSeedProvider;
import tools.mdsd.probdist.distributiontype.ProbabilityDistributionRepository;

public class BayesianModelTest {
Expand All @@ -40,7 +41,7 @@ public static void setUpModels() {
IProbabilityDistributionRepositoryLookup probDistRepoLookup = new ProbabilityDistributionRepositoryLookup(
distTypes);

defaultProbabilityDistributionFactory = new ProbabilityDistributionFactory();
defaultProbabilityDistributionFactory = new ProbabilityDistributionFactory(new NoSeedProvider());
IProbabilityDistributionRegistry<CategoricalValue> probabilityDistributionRegistry = defaultProbabilityDistributionFactory;
ParameterParser parameterParser = new DefaultParameterParser();
probabilityDistributionRegistry
Expand Down

0 comments on commit 530d4e3

Please sign in to comment.