Skip to content

Commit b81b0fd

Browse files
committed
added cpp
1 parent fd493b5 commit b81b0fd

27 files changed

+2140
-0
lines changed

cpp/Debug/clear.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
for i in Bernoulli Uniform Normal Mixture; do
4+
for j in QLearning UCB1 ParticleFilter Beta NormalGamma DirichletNormalGamma; do
5+
rm -f $i-$j:*
6+
done
7+
done
8+
9+
rm -f MixtureBandit-*
10+
rm -f curve.png
11+
rm -f core*
12+
rm -f gnuplot_cmds

cpp/Debug/killall.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
for i in `seq 1 100`; do
4+
killall bandit
5+
done

cpp/Debug/makefile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
################################################################################
2+
# Automatically-generated file. Do not edit!
3+
################################################################################
4+
5+
-include ../makefile.init
6+
7+
RM := rm -rf
8+
9+
# All of the sources participating in the build are defined here
10+
-include sources.mk
11+
-include src/subdir.mk
12+
-include subdir.mk
13+
-include objects.mk
14+
15+
ifneq ($(MAKECMDGOALS),clean)
16+
ifneq ($(strip $(C_UPPER_DEPS)),)
17+
-include $(C_UPPER_DEPS)
18+
endif
19+
ifneq ($(strip $(CPP_DEPS)),)
20+
-include $(CPP_DEPS)
21+
endif
22+
ifneq ($(strip $(C++_DEPS)),)
23+
-include $(C++_DEPS)
24+
endif
25+
ifneq ($(strip $(CC_DEPS)),)
26+
-include $(CC_DEPS)
27+
endif
28+
ifneq ($(strip $(C_DEPS)),)
29+
-include $(C_DEPS)
30+
endif
31+
ifneq ($(strip $(CXX_DEPS)),)
32+
-include $(CXX_DEPS)
33+
endif
34+
endif
35+
36+
-include ../makefile.defs
37+
38+
# Add inputs and outputs from these tool invocations to the build variables
39+
40+
# All Target
41+
all: bandit
42+
43+
# Tool invocations
44+
bandit: $(OBJS) $(USER_OBJS)
45+
@echo 'Building target: $@'
46+
@echo 'Invoking: GCC C++ Linker'
47+
g++ -o "bandit" $(OBJS) $(USER_OBJS) $(LIBS)
48+
@echo 'Finished building target: $@'
49+
@echo ' '
50+
51+
# Other Targets
52+
clean:
53+
-$(RM) $(EXECUTABLES)$(C_UPPER_DEPS)$(CPP_DEPS)$(C++_DEPS)$(CC_DEPS)$(OBJS)$(C_DEPS)$(CXX_DEPS) bandit
54+
-@echo ' '
55+
56+
.PHONY: all clean dependents
57+
.SECONDARY:
58+
59+
-include ../makefile.targets

cpp/Debug/mixture.gnuplot

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
#!/usr/bin/gnuplot -persist
2+
#
3+
#
4+
# G N U P L O T
5+
# Version 4.6 patchlevel 1 last modified 2012-09-26
6+
# Build System: Linux x86_64
7+
#
8+
# Copyright (C) 1986-1993, 1998, 2004, 2007-2012
9+
# Thomas Williams, Colin Kelley and many others
10+
#
11+
# gnuplot home: http://www.gnuplot.info
12+
# faq, bugs, etc: type "help FAQ"
13+
# immediate help: type "help" (plot window: hit 'h')
14+
# set terminal wxt 0
15+
# set output
16+
unset clip points
17+
set clip one
18+
unset clip two
19+
set bar 1.000000 front
20+
set border 31 front linetype -1 linewidth 1.000
21+
set timefmt z "%d/%m/%y,%H:%M"
22+
set zdata
23+
set timefmt y "%d/%m/%y,%H:%M"
24+
set ydata
25+
set timefmt x "%d/%m/%y,%H:%M"
26+
set xdata
27+
set timefmt cb "%d/%m/%y,%H:%M"
28+
set timefmt y2 "%d/%m/%y,%H:%M"
29+
set y2data
30+
set timefmt x2 "%d/%m/%y,%H:%M"
31+
set x2data
32+
set boxwidth
33+
set style fill empty border
34+
set style rectangle back fc lt -3 fillstyle solid 1.00 border lt -1
35+
set style circle radius graph 0.02, first 0, 0
36+
set style ellipse size graph 0.05, 0.03, first 0 angle 0 units xy
37+
set dummy x,y
38+
set format x "% g"
39+
set format y "% g"
40+
set format x2 "% g"
41+
set format y2 "% g"
42+
set format z "% g"
43+
set format cb "% g"
44+
set format r "% g"
45+
set angles radians
46+
set grid nopolar
47+
set grid xtics nomxtics ytics nomytics noztics nomztics \
48+
nox2tics nomx2tics noy2tics nomy2tics nocbtics nomcbtics
49+
set grid layerdefault linetype 0 linewidth 1.000, linetype 0 linewidth 1.000
50+
set raxis
51+
set key title ""
52+
set key inside right top vertical Right noreverse enhanced autotitles nobox
53+
set key noinvert samplen 4 spacing 1 width 0 height 0
54+
set key maxcolumns 0 maxrows 0
55+
set key noopaque
56+
unset label
57+
unset arrow
58+
set style increment default
59+
unset style line
60+
unset style arrow
61+
set style histogram clustered gap 2 title offset character 0, 0, 0
62+
unset logscale
63+
set offsets 0, 0, 0, 0
64+
set pointsize 1
65+
set pointintervalbox 1
66+
set encoding default
67+
unset polar
68+
unset parametric
69+
unset decimalsign
70+
set view 60, 30, 1, 1
71+
set samples 100, 100
72+
set isosamples 10, 10
73+
set surface
74+
unset contour
75+
set clabel '%8.3g'
76+
set mapping cartesian
77+
set datafile separator whitespace
78+
unset hidden3d
79+
set cntrparam order 4
80+
set cntrparam linear
81+
set cntrparam levels auto 5
82+
set cntrparam points 5
83+
set size ratio 0 1,1
84+
set origin 0,0
85+
set style data points
86+
set style function lines
87+
set xzeroaxis linetype -2 linewidth 1.000
88+
set yzeroaxis linetype -2 linewidth 1.000
89+
set zzeroaxis linetype -2 linewidth 1.000
90+
set x2zeroaxis linetype -2 linewidth 1.000
91+
set y2zeroaxis linetype -2 linewidth 1.000
92+
set ticslevel 0.5
93+
set mxtics default
94+
set mytics default
95+
set mztics default
96+
set mx2tics default
97+
set my2tics default
98+
set mcbtics default
99+
set xtics border in scale 1,0.5 mirror norotate offset character 0, 0, 0 autojustify
100+
set xtics autofreq norangelimit
101+
set ytics border in scale 1,0.5 mirror norotate offset character 0, 0, 0 autojustify
102+
set ytics autofreq norangelimit
103+
set ztics border in scale 1,0.5 nomirror norotate offset character 0, 0, 0 autojustify
104+
set ztics autofreq norangelimit
105+
set nox2tics
106+
set noy2tics
107+
set cbtics border in scale 1,0.5 mirror norotate offset character 0, 0, 0 autojustify
108+
set cbtics autofreq norangelimit
109+
set rtics axis in scale 1,0.5 nomirror norotate offset character 0, 0, 0 autojustify
110+
set rtics autofreq norangelimit
111+
set title ""
112+
set title offset character 0, 0, 0 font "" norotate
113+
set timestamp bottom
114+
set timestamp ""
115+
set timestamp offset character 0, 0, 0 font "" norotate
116+
set rrange [ * : * ] noreverse nowriteback
117+
set trange [ * : * ] noreverse nowriteback
118+
set urange [ * : * ] noreverse nowriteback
119+
set vrange [ * : * ] noreverse nowriteback
120+
set xlabel ""
121+
set xlabel offset character 0, 0, 0 font "" textcolor lt -1 norotate
122+
set x2label ""
123+
set x2label offset character 0, 0, 0 font "" textcolor lt -1 norotate
124+
set xrange [ * : * ] noreverse nowriteback
125+
set x2range [ * : * ] noreverse nowriteback
126+
set ylabel ""
127+
set ylabel offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270
128+
set y2label ""
129+
set y2label offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270
130+
set yrange [ * : * ] noreverse nowriteback
131+
set y2range [ * : * ] noreverse nowriteback
132+
set zlabel ""
133+
set zlabel offset character 0, 0, 0 font "" textcolor lt -1 norotate
134+
set zrange [ * : * ] noreverse nowriteback
135+
set cblabel ""
136+
set cblabel offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270
137+
set cbrange [ * : * ] noreverse nowriteback
138+
set zero 1e-08
139+
set lmargin -1
140+
set bmargin -1
141+
set rmargin -1
142+
set tmargin -1
143+
set locale "en_US.UTF-8"
144+
set pm3d explicit at s
145+
set pm3d scansautomatic
146+
set pm3d interpolate 1,1 flush begin noftriangles nohidden3d corners2color mean
147+
set palette positive nops_allcF maxcolors 0 gamma 1.5 color model RGB
148+
set palette rgbformulae 7, 5, 15
149+
set colorbox default
150+
set colorbox vertical origin screen 0.9, 0.2, 0 size screen 0.05, 0.6, 0 front bdefault
151+
set style boxplot candles range 1.50 outliers pt 7 separation 1 labels auto unsorted
152+
set loadpath
153+
set fontpath
154+
set psdir
155+
set fit noerrorvariables
156+
GNUTERM = "wxt"
157+
plot 'MixtureBandit-0' w l, 'MixtureBandit-1' w l, 'MixtureBandit-2' w l, 'MixtureBandit-3' w l, 'MixtureBandit-4' w l, 'MixtureBandit-5' w l, 'MixtureBandit-6' w l, 'MixtureBandit-7' w l
158+
# EOF

cpp/Debug/objects.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
################################################################################
2+
# Automatically-generated file. Do not edit!
3+
################################################################################
4+
5+
LIBS := -lboost_program_options
6+
7+
USER_OBJS :=
8+

cpp/Debug/plot.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
GNUPLOT_SCRIPT="gnuplot_cmds"
4+
5+
gnuplot $GNUPLOT_SCRIPT
6+
eog curve.png

cpp/Debug/sources.mk

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
################################################################################
2+
# Automatically-generated file. Do not edit!
3+
################################################################################
4+
5+
CXX_SRCS :=
6+
CPP_SRCS :=
7+
C_UPPER_SRCS :=
8+
ASM_SRCS :=
9+
C_SRCS :=
10+
CC_SRCS :=
11+
OBJ_SRCS :=
12+
C++_SRCS :=
13+
S_UPPER_SRCS :=
14+
O_SRCS :=
15+
EXECUTABLES :=
16+
C_UPPER_DEPS :=
17+
CPP_DEPS :=
18+
C++_DEPS :=
19+
CC_DEPS :=
20+
OBJS :=
21+
C_DEPS :=
22+
CXX_DEPS :=
23+
24+
# Every subdirectory with source files must be described here
25+
SUBDIRS := \
26+
src \
27+

cpp/Debug/src/subdir.mk

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
################################################################################
2+
# Automatically-generated file. Do not edit!
3+
################################################################################
4+
5+
# Add inputs and outputs from these tool invocations to the build variables
6+
CPP_SRCS += \
7+
../src/agent.cpp \
8+
../src/bandit.cpp \
9+
../src/main.cpp \
10+
../src/random.cpp
11+
12+
CPP_DEPS += \
13+
./src/agent.d \
14+
./src/bandit.d \
15+
./src/main.d \
16+
./src/random.d
17+
18+
OBJS += \
19+
./src/agent.o \
20+
./src/bandit.o \
21+
./src/main.o \
22+
./src/random.o
23+
24+
25+
# Each subdirectory must supply rules for building sources it contributes
26+
src/%.o: ../src/%.cpp
27+
@echo 'Building file: $<'
28+
@echo 'Invoking: GCC C++ Compiler'
29+
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
30+
@echo 'Finished building: $<'
31+
@echo ' '
32+
33+

cpp/Debug/test.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#! /bin/bash
2+
3+
SEED=$RANDOM
4+
GNUPLOT_SCRIPT="gnuplot_cmds"
5+
BANDIT="Mixture"
6+
BASIS="4"
7+
ARMS2="3"
8+
TRIALS2="10"
9+
RUNS2="10"
10+
11+
check_id() {
12+
cat ../src/utils.h | grep "\<$1\s=" | awk '{print $3}' | sed "s/,//g"
13+
}
14+
15+
run() {
16+
AGENT="$1"
17+
AGENT_ID=`check_id $AGENT`
18+
19+
shift
20+
OUTPUT="$BANDIT-$AGENT:$*"
21+
22+
echo -n " '$OUTPUT' w l," >> $GNUPLOT_SCRIPT
23+
echo "./bandit --seed $SEED --bandit $BANDIT_ID --basis $BASIS --agent $AGENT_ID --arms $ARMS2 --trials $TRIALS2 --runs $RUNS2 $* > $OUTPUT"
24+
time ./bandit --seed $SEED --bandit $BANDIT_ID --basis $BASIS --agent $AGENT_ID --arms $ARMS2 --trials $TRIALS2 --runs $RUNS2 $* > "$OUTPUT" &
25+
}
26+
27+
if [ ! -z $1 ]; then
28+
SEED=$1
29+
fi
30+
31+
BANDIT_ID=`check_id $BANDIT`
32+
33+
./clear.sh
34+
35+
cat << EOF > $GNUPLOT_SCRIPT
36+
set terminal png font '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansCondensed.ttf,11' size 1280,800
37+
set output "curve.png"
38+
set grid
39+
set log x
40+
EOF
41+
42+
echo -n "plot " >> $GNUPLOT_SCRIPT
43+
44+
run UCB1 --exploration 1
45+
run NormalGamma --beta 1
46+
run DirichletNormalGamma --beta 1
47+
run Beta
48+
run QLearning --eplison 0.1
49+
50+
wait
51+
52+
sed -i -e 's/,$//g' $GNUPLOT_SCRIPT
53+
./plot.sh &
54+

cpp/Release/clear.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
for i in Bernoulli Uniform Normal Mixture; do
4+
for j in QLearning UCB1 ParticleFilter Beta NormalGamma DirichletNormalGamma; do
5+
rm -f $i-$j:*
6+
done
7+
done
8+
9+
rm -f MixtureBandit-*
10+
rm -f curve.png
11+
rm -f core*
12+
rm -f gnuplot_cmds

0 commit comments

Comments
 (0)