#for i in xrange(i+1,i+1+15): # data.append(ProblogExample(i,"throws(john),breaks")) #for i in xrange(i+1,i+1+10): # data.append(ProblogExample(i,"throws(john)")) #i = 0 #for i in xrange(i+1,i+1+23): # data.append(ProblogExample(i,"throws(mary),throws(john),breaks")) #for i in xrange(i+1,i+1+2): # data.append(ProblogExample(i,"throws(mary),throws(john),problog_not(breaks)")) #for i in xrange(i+1,i+1+15): # data.append(ProblogExample(i,"problog_not(throws_mary),throws(john),breaks")) #for i in xrange(i+1,i+1+10): # data.append(ProblogExample(i,"problog_not(throws_mary),throws(john),problog_not(breaks)")) #To make it work, be sure the proofs only contain positive information #if necessary, marginalize variables data.append(ProblogExample(0,"breaks",weight=0.76)) data.append(ProblogExample(1,"throws(mary)",weight=0.5)) data.append(ProblogExample(2,"throws(john)",weight=1)) data.append(ProblogExample(3,"throws(john),throws(mary),breaks",weight=0.46)) #We give the weights, so don't calculate them cc.weight=False runmodel = cc.compileCode(cpcode,otherexamples=data) runmodel.iterations = 500 result = runmodel.run() g = GnuplotDrawer() g.draw(result) pprint.pprint(result.probs[-1])
d = Dataset(["a","b","c"]) d.addData(["laag","laag","hoog"]) d.addData(["laag","hoog","laag"]) d.addData(["hoog","laag","laag"]) d.addData(["hoog","hoog","hoog"]) def runCode(generator): cpcode = generator.generate(m) cc = CPCompiler() runmodel = cc.compileCode(cpcode,d) runmodel.iterations = 1000 result = runmodel.run() return result resnonlin = runCode(NonLinearCPLogicGenerator()) reslin = runCode(LinearCPLogicGenerator()) print "Niet-lineair:" resnonlin.printReport() g = GnuplotDrawer() g.draw(resnonlin) t = TableResultInterpreter() r = t.interprete(m,resnonlin.latest()) ltri = LatexTableResultInterpreter(r) print ltri.out() print "Lineair:" reslin.printReport() g = GnuplotDrawer() g.draw(reslin,prefix="lin-")
d = d.makeDiff() d = d.discretise() def runCode(generator): cpcode = generator.generate(m) cc = CPCompiler() runmodel = cc.compileCode(cpcode,d) runmodel.iterations = 1000 result = runmodel.run() return result reslin = runCode(LinearCPLogicGenerator()) resmaj = runCode(MajorityLinearCPLogicGenerator()) print "Gelijke verdeling:" reslin.printReport() g = GnuplotDrawer() g.draw(reslin) print "Meerderheidsverdeling:" resmaj.printReport() g = GnuplotDrawer() g.draw(resmaj,prefix="maj-") import tempfile datafile = tempfile.NamedTemporaryFile() for p in zip(reslin.sse, resmaj.sse): datafile.file.write("\t".join([str(num) for num in p]) + "\n") datafile.file.flush() g.callGnuplot(2,datafile.name,"fits.png") datafile.close()