Skip to content

Instantly share code, notes, and snippets.

@robinvanemden
Last active January 19, 2016 12:16
Show Gist options
  • Save robinvanemden/c0f7c75515f6b2b339da to your computer and use it in GitHub Desktop.
Save robinvanemden/c0f7c75515f6b2b339da to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import libs.lif as lf
key = "question"
value = self.context['question']
theta = self.get_theta(all_float=False, key=key, value=value)
Lif = lf.Lif(theta, x0=self.context['x0'], A=self.context['A'], T=150, gamma=.06, omega=1.0, lifversion=1)
Lif.update(self.action["t"],self.action["x"], self.reward)
self.set_theta(Lif, key=key, value=value)
import time
self.log_data({
"type" : "setreward",
"t" : self.action["t"],
"x" : self.action["x"],
"y" : self.reward,
"x0" : theta['x0'],
"QID" : self.context['QID'],
"A" : self.context['A'],
"time" : int(time.time()),
"context" : self.context,
"q" : self.context['question']
})
# -*- coding: utf-8 -*-
import libs.lif as lf
key = "question"
value = self.context['question']
theta = self.get_theta(all_float=False, key=key, value=value)
Lif = lf.Lif(theta, x0=self.context['x0'], A=self.context['A'], T=150, gamma=.06, omega=1.0, lifversion=1)
suggestion = Lif.suggest()
suggested_x = suggestion["x"]
if suggestion["x"] < 0:
suggested_x = 0
self.action["x"] = suggested_x
self.action["t"] = suggestion["t"]
self.set_theta(Lif, key=key, value=value)
import time
self.log_data({
"type" : "getadvice",
"t" : suggestion["t"],
"x" : suggested_x,
"A" : self.context['A'],
"QID" : self.context['QID'],
"time" : int(time.time()),
"context" : self.context,
"q" : self.context['question']
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment