Fleet  0.0.9
Inference in the LOT
Classes | Functions | Variables
Main.cpp File Reference
#include "Functional.h"
#include "Object.h"
#include "ShapeColorSizeObject.h"
#include "Grammar.h"
#include "Singleton.h"
#include "DeterministicLOTHypothesis.h"
#include "TopN.h"
#include "ParallelTempering.h"
#include "Fleet.h"
Include dependency graph for Main.cpp:
This graph shows which files directly or indirectly include this file:

Classes

class  MyGrammar
 
More...
 

Functions

int main (int argc, char **argv)
 

Variables

double TERMINAL_WEIGHT = 5.0
 
More...
 
MyGrammar grammar
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)
Define a class for handling my specific hypotheses and data. Everything is defaultly
a PCFG prior and regeneration proposals, but I have to define a likelihood
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
class MyHypothesis final : public DeterministicLOTHypothesis<MyHypothesis,MyInput,bool,MyGrammar,&grammar> {
public:
using Super::Super; // inherit the constructors
// Now, if we defaultly assume that our data is a std::vector of t_data, then we
// can just define the likelihood of a single data point, which is here the true
// value with probability x.reliability, and otherwise a coin flip.
double compute_single_likelihood(const datum_t& x) override {
bool out = call(x.input, false);
return out == x.output ? log(x.reliability + (1.0-x.reliability)/2.0) : log((1.0-x.reliability)/2.0);
}
};
/*

Main code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Variable Documentation

◆ grammar

MyGrammar grammar

◆ TERMINAL_WEIGHT

double TERMINAL_WEIGHT = 5.0

We need to define some structs to hold the object features
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
using S = std::string;
// Define a set of objects -- really it's a multiset so we'll use a vector
using ObjectSet = std::vector<MyObject>;
// The arguments to a hypothesis will be a pair of a set and an object (as in Piantadosi, Tenenbaum, Goodman 2016)
using MyInput = std::tuple<MyObject,ObjectSet>; // this is the type of arguments we give to our function
/*

Define the grammar Thid requires the types of the thing we will add to the grammar (bool,Object) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~