00001 package edu.tum.cs.probcog; 00002 00003 import java.io.PrintStream; 00004 00005 import edu.tum.cs.util.StringTool; 00006 00007 public class InferenceResult implements Comparable<InferenceResult> { 00008 public String functionName; 00009 public String[] params; 00010 public double probability; 00011 00012 public InferenceResult(String functionName, String[] params, double p) { 00013 this.functionName = functionName; 00014 this.params = params; 00015 this.probability = p; 00016 } 00017 00023 public boolean mapConstants(Model m) { 00024 //String[] mappedParams = new String[params.length]; 00025 for(int i = 0; i < params.length; i++) { 00026 params[i] = m.mapConstantFromProbCog(params[i]); 00027 if(params[i] == null) 00028 return false; 00029 } 00030 return true; 00031 } 00032 00033 public String toString() { 00034 return String.format("%.6f %s(%s)", probability, functionName, StringTool.join(", ", params)); 00035 } 00036 00037 public void print(PrintStream out) { 00038 out.println(this); 00039 } 00040 00041 @Override 00042 public int compareTo(InferenceResult arg0) { 00043 return Double.compare(this.probability, arg0.probability); 00044 } 00045 }