00001 /* 00002 * Created on Aug 7, 2009 00003 * 00004 * TODO To change the template for this generated file go to 00005 * Window - Preferences - Java - Code Style - Code Templates 00006 */ 00007 package edu.tum.cs.srl.mln.inference; 00008 00009 import java.util.ArrayList; 00010 00011 import edu.tum.cs.logic.GroundAtom; 00012 import edu.tum.cs.logic.sat.weighted.WeightedClausalKB; 00013 import edu.tum.cs.srl.mln.MarkovRandomField; 00014 00015 public class MCSAT extends InferenceAlgorithm { 00016 00017 edu.tum.cs.logic.sat.weighted.MCSAT sampler; 00018 00019 public MCSAT(MarkovRandomField mrf) throws Exception { 00020 super(mrf); 00021 WeightedClausalKB wckb = new WeightedClausalKB(mrf, true); 00022 sampler = new edu.tum.cs.logic.sat.weighted.MCSAT(wckb, mrf.getWorldVariables(), mrf.getDb()); 00023 paramHandler.addSubhandler(sampler.getParameterHandler()); 00024 } 00025 00026 @Override 00027 public double getResult(GroundAtom ga) { 00028 return sampler.getResult(ga); 00029 } 00030 00031 @Override 00032 public ArrayList<InferenceResult> infer(Iterable<String> queries, int maxSteps) 00033 throws Exception { 00034 sampler.setDebugMode(debug); 00035 sampler.run(maxSteps); 00036 return getResults(queries); 00037 } 00038 00039 public String getAlgorithmName() { 00040 return sampler.getAlgorithmName(); 00041 } 00042 }