Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added histogram (succession) Laplace learning

  • Loading branch information...
commit 205c9fced1b22ed86aad578a30a8fe67bdedf638 1 parent 72cfe9a
@SnippyHolloW authored
Showing with 40 additions and 13 deletions.
  1. +15 −11 Makefile
  2. +16 −0 model.cpp
  3. +4 −0 model.h
  4. +5 −2 parameters.h
View
26 Makefile
@@ -1,7 +1,7 @@
#!/bin/bash
-PROBT_INCLUDE=/Users/gabrielsynnaeve/these/code/probt/include
-PROBT_LIB=/Users/gabrielsynnaeve/these/code/probt/lib
+PROBT_INCLUDE=/Users/gabrielsynnaeve/these/code/probt22/include
+PROBT_LIB=/Users/gabrielsynnaeve/these/code/probt22/lib
BOOST_STAGE_LIB=/Users/gabrielsynnaeve/labs/boost_1_45_0/stage/lib
BOOST_INCLUDE=/Users/gabrielsynnaeve/labs/boost_1_45_0
@@ -9,7 +9,7 @@ model: model.cpp
g++ -ggdb -arch i386 -I$(PROBT_INCLUDE) model.cpp -L$(PROBT_LIB) -lpl -o model
model_with_serialization: model.cpp
- g++ -ggdb -arch i386 -I$(BOOST_INCLUDE) -I$(PROBT_INCLUDE) model.cpp -L$(BOOST_STAGE_LIB) -L$(PROBT_LIB) -lpl -lboost_serialization-xgcc42-mt -o model
+ g++ -ggdb -arch i386 -D__SERIALIZE__ -I$(BOOST_INCLUDE) -I$(PROBT_INCLUDE) model.cpp -L$(BOOST_STAGE_LIB) -L$(PROBT_LIB) -lpl -lboost_serialization -o model
techtrees: techtrees.cpp
g++ -ggdb -arch i386 -DTECH_TREES -I$(PROBT_INCLUDE) techtrees.cpp -L$(PROBT_LIB) -lpl -o techtrees
@@ -33,16 +33,16 @@ all: tests model techtrees
[ -x /usr/bin/say ] && say "Battlecruiser operational!"
run:
- DYLD_LIBRARY_PATH=$(PROBT_LIB):DYLD_LIBRARY_PATH ./model lPvP.txt tPvP.txt
+ DYLD_LIBRARY_PATH=$(PROBT_LIB):$(DYLD_LIBRARY_PATH) ./model lPvP.txt tPvP.txt
echo $(PROBT_LIB)
run_with_serialization:
- DYLD_LIBRARY_PATH=$(BOOST_STAGE_LIB):$(PROBT_LIB):DYLD_LIBRARY_PATH ./model lPvP.txt tPvP.txt
+ DYLD_LIBRARY_PATH=$(BOOST_STAGE_LIB):$(PROBT_LIB):$(DYLD_LIBRARY_PATH) ./model lPvP.txt tPvP.txt
echo $(BOOST_STAGE_LIB)
echo $(PROBT_LIB)
debugrun:
- DYLD_LIBRARY_PATH=$(PROBT_LIB):DYLD_LIBRARY_PATH gdb ./model < PvP.txt
+ DYLD_LIBRARY_PATH=$(PROBT_LIB):$(DYLD_LIBRARY_PATH) gdb ./model < PvP.txt
echo $(PROBT_LIB)
mymodel: model.cpp
@@ -55,13 +55,13 @@ test_x_values: tests
./test_x_values
test_functional_dirac: tests
- DYLD_LIBRARY_PATH=$(PROBT_LIB):DYLD_LIBRARY_PATH ./test_functional_dirac
+ DYLD_LIBRARY_PATH=$(PROBT_LIB):$(DYLD_LIBRARY_PATH) ./test_functional_dirac
test_lambda: tests
- DYLD_LIBRARY_PATH=$(PROBT_LIB):DYLD_LIBRARY_PATH ./test_lambda
+ DYLD_LIBRARY_PATH=$(PROBT_LIB):$(DYLD_LIBRARY_PATH) ./test_lambda
test_learning: tests
- DYLD_LIBRARY_PATH=$(PROBT_LIB):DYLD_LIBRARY_PATH ./test_learning
+ DYLD_LIBRARY_PATH=$(PROBT_LIB):$(DYLD_LIBRARY_PATH) ./test_learning
sed -i '' 's#set data style lines#set style data lines#' *.gnuplot
gnuplot *.gnuplot
@@ -87,23 +87,27 @@ test_getBuildings: tests
runtests: test_x_values test_functional_dirac test_lambda test_getOpeningVal test_getBuildings
fullbenchs: model mymodel
+ DYLD_LIBRARY_PATH=$(PROBT_LIB):$(DYLD_LIBRARY_PATH)
echo "TODO"
benchs: model mymodel
+ DYLD_LIBRARY_PATH=$(PROBT_LIB):$(DYLD_LIBRARY_PATH)
echo "Benchmarks with Ben Weber labels:\n" > benchs.txt
for name in [TPZ]v[TPZ].txt; do echo "$${name%.*}" >> benchs.txt &&\
- ./model l$$name t$$name | grep ">>> Positive classif" >> benchs.txt\
+ DYLD_LIBRARY_PATH=$(PROBT_LIB):$(DYLD_LIBRARY_PATH) ./model l$$name t$$name | grep ">>> Positive classif" >> benchs.txt\
&& echo "\n" >> benchs.txt; done
echo "Benchmarks with my labels:\n" >> benchs.txt
for name in [TPZ]v[TPZ]x.txt; do echo "$${name%.*}" >> benchs.txt &&\
- ./mymodel l$$name t$$name | grep ">>> Positive classif" >> benchs.txt\
+ DYLD_LIBRARY_PATH=$(PROBT_LIB):$(DYLD_LIBRARY_PATH) ./mymodel l$$name t$$name | grep ">>> Positive classif" >> benchs.txt\
&& echo "\n" >> benchs.txt; done
noisebenchs:
+ DYLD_LIBRARY_PATH=$(PROBT_LIB):$(DYLD_LIBRARY_PATH)
for ((i=1; i<16; i++)); do \
./noisy.sh $$i >> benchs.txt; done
ttbenchs: tt
+ DYLD_LIBRARY_PATH=$(PROBT_LIB):$(DYLD_LIBRARY_PATH)
echo "Launching benchmarks:\n" > ttbenchs.txt
for name in [TPZ]v[TPZ].txt; do echo "$${name%.*}" >> ttbenchs.txt &&\
./tt l$$name t$$name | grep ">>>" >> ttbenchs.txt\
View
16 model.cpp
@@ -324,7 +324,11 @@ void test_X_possible(plValues& lambda, const plValues& X_Obs_conj)
*/
template<class T>
void learn_T_and_X(ifstream& inputstream,
+#ifdef LAPLACE_LEARNING
+ plCndLearnObject<plLearnLaplace>& timeLearner,
+#else
plCndLearnObject<plLearnBellShape>& timeLearner,
+#endif
plCndLearnObject<plLearnHistogram>& xLearner,
plSymbol& Opening, plSymbol& X, plSymbol& Time)
{
@@ -533,7 +537,11 @@ OpeningPredictor::OpeningPredictor(const vector<string>& op,
P_lambda = plFunctionalDirac(lambda, X_Obs_conj ,coherence);
// Specification of P(T | X, Opening)
+#ifdef LAPLACE_LEARNING
+ timeLearner = plCndLearnObject<plLearnLaplace>(Time, X^Opening);
+#else
timeLearner = plCndLearnObject<plLearnBellShape>(Time, X^Opening);
+#endif
cout << ">>>> Learning from: " << learningFileName << endl;
ifstream inputstream(learningFileName);
if (learningFileName[0 + shift] == 'P')
@@ -556,7 +564,11 @@ OpeningPredictor::OpeningPredictor(const vector<string>& op,
time_knowing_x_op.push_default(plUniform(Time));
plValues val(timeLearner.get_computable_object().get_right_variables());
do {
+#ifdef LAPLACE_LEARNING
+ const plLearnLaplace* t = timeLearner.get_learnt_object_for_value(val);
+#else
const plLearnBellShape* t = timeLearner.get_learnt_object_for_value(val);
+#endif
if (t)
{
if (t->get_sigma() < MIN_STD_DEV)
@@ -578,7 +590,11 @@ OpeningPredictor::OpeningPredictor(const vector<string>& op,
/* // Verification of tabulate alignment / order
plValues val(timeLearner.get_computable_object().get_right_variables());
do {
+#ifdef LAPLACE_LEARNING
+ const plLearnLaplace* t = timeLearner.get_learnt_object_for_value(val);
+#else
const plLearnBellShape* t = timeLearner.get_learnt_object_for_value(val);
+#endif
cout << val << endl;
if (t)
{
View
4 model.h
@@ -47,7 +47,11 @@ class OpeningPredictor
plVariablesConjunction X_Obs_conj;
plExternalFunction coherence;
plFunctionalDirac P_lambda;
+#ifdef LAPLACE_LEARNING
+ plCndLearnObject<plLearnLaplace> timeLearner;
+#else
plCndLearnObject<plLearnBellShape> timeLearner;
+#endif
#ifdef __MIN_STD_DEV_BELL_SHAPES__
plDistributionMap time_knowing_x_op;
#endif
View
7 parameters.h
@@ -3,15 +3,18 @@
#define X_KNOWING_OPENING
#define DIRAC_ON_LAST_OPENING
+//#define LAPLACE_LEARNING
#define LEARN_TIME_LIMIT 1080 // 18 minutes, TODO change
//#define LEARN_TIME_LIMIT 900 // 15 minutes
//#define LEARN_TIME_LIMIT 600 // 10 minutes
//#define GENERATE_X_VALUES
//#define DEBUG_OUTPUT 1
-#define TECH_TREES
-#define __SERIALIZE__
+//#define TECH_TREES
+//#define __SERIALIZE__
+#ifndef LAPLACE_LEARNING
#define __MIN_STD_DEV_BELL_SHAPES__
+#endif
/**
* PLOT = 0 => no plotting
* PLOT = 1 => plot P(Opening) over buildings seen for each replay
Please sign in to comment.
Something went wrong with that request. Please try again.