00001
00002
00003
00004
00005
00006
00007 package edu.tum.cs.srl.bayesnets.inference;
00008
00009 import java.util.Collection;
00010
00011 import edu.ksu.cis.bnj.ver3.core.BeliefNode;
00012 import edu.tum.cs.bayesnets.core.BeliefNetworkEx;
00013 import edu.tum.cs.bayesnets.inference.GibbsSampling;
00014 import edu.tum.cs.bayesnets.inference.SATIS_BSampler;
00015 import edu.tum.cs.bayesnets.inference.Sampler;
00016 import edu.tum.cs.bayesnets.inference.WeightedSample;
00017 import edu.tum.cs.logic.sat.SampleSAT;
00018 import edu.tum.cs.srl.bayesnets.bln.GroundBLN;
00019 import edu.tum.cs.srl.bayesnets.bln.coupling.VariableLogicCoupling;
00020
00027 public class SATISExGibbs extends SATISEx {
00028 protected int gibbsSteps = 9;
00029
00030 public SATISExGibbs(GroundBLN bln) throws Exception {
00031 super(bln);
00032 this.paramHandler.add("gibbsSteps", "setNumGibbsSteps");
00033 }
00034
00035 public void setNumGibbsSteps(int n) {
00036 gibbsSteps = n;
00037 }
00038
00039 @Override
00040 protected Sampler getSampler() throws Exception {
00041 initSATSampler();
00042 return new SATIS_BSampler_Gibbs(gbln.getGroundNetwork(), ss, gbln.getCoupling(), determinedVars);
00043 }
00044
00045 public class SATIS_BSampler_Gibbs extends SATIS_BSampler {
00046
00047 public GibbsSampling gibbsSampler;
00048
00049 public SATIS_BSampler_Gibbs(BeliefNetworkEx bn, SampleSAT sat, VariableLogicCoupling coupling, Collection<BeliefNode> determinedVars) throws Exception {
00050 super(bn, sat, coupling, determinedVars);
00051 gibbsSampler = new GibbsSampling(gbln.getGroundNetwork());
00052 }
00053
00054 public void onAddedSample(WeightedSample s) throws Exception {
00055 for(int i = 0; i < gibbsSteps; i++) {
00056 gibbsSampler.gibbsStep(this.evidenceDomainIndices, s);
00057 addSample(s);
00058 currentStep++;
00059 }
00060 }
00061 }
00062
00063 }