示例#1
0
	def adversarial_nested_inference(self, Q):
		t = Q.fetch("t")
		q = ProgramTrace(self.nested_model)

		# condits the nested model with the chaser's information
		q.condition("other_run_start", Q.fetch("init_run_start"))
		q.condition("t", Q.fetch("t")) 
		# since we assume that the chaser knows where the runner starts
		q.condition("run_start", Q.get_obs("other_run_start"))

		for i in xrange(30):
			# the runner wants all detections to be False
			q.condition("detected_t_"+str(i), False)

			#XXX You can choose if you want the worst case scenario: 
			# Worse case scenario: where runner fully observes chaser
			# IF NOT: then The Runner will have a Naive model of the Chaser
			# 
			#  XXX UNCOMMENT IF YOU WANT WORST CASE SCENARIO 
			# (although sometimes, the behavior of the RRT messes with this)
			# this is because the Chaser isn't guarenteed to search like a planned path
			# if i < t:
			# 	q.condition("other_run_x_"+str(prev_t), Q.fetch("init_run_x_"+str(i)))
			# 	q.condition("other_run_y_"+str(prev_t), Q.fetch("init_run_y_"+str(i)))

		#print q.cond_data_db
		# need to think about this a bit more - iris - 1.17.2018
		# thought about it -- I think I want the path with the least number of detections
		# since this nested bit is in the runner's perspective
		post_sample_traces, trace =  self.get_trace_for_least_detected_path_PO(q)

		return trace
示例#2
0
    def collaborative_nested_inference(self, Q):
        t = Q.get_obs("t")
        q = ProgramTrace(self.nested_model)
        q.condition("run_start", Q.get_obs("run_start"))
        q.condition("t", Q.get_obs("t"))
        # condition on previous time steps

        for prev_t in xrange(t):
            q.condition("run_x_" + str(prev_t),
                        Q.get_obs("run_x_" + str(prev_t)))
            q.condition("run_y_" + str(prev_t),
                        Q.get_obs("run_y_" + str(prev_t)))

        post_sample_traces = self.run_inference(q, post_samples=10, samples=16)
        return post_sample_traces
示例#3
0
def single_run_model(model, observations, conditions):
    Q = ProgramTrace(model)

    for name in observations.keys():
        Q.set_obs(name, observations[name])

    for name in conditions.keys():
        Q.condition(name, conditions[name])

    score, trace = Q.run_model()

    mean = Q.fetch("mean")
    Q = None
    #print trace
    return (mean, trace)
示例#4
0
	def adversarial_nested_inference(self, Q):
		t = Q.fetch("t")
		q = ProgramTrace(self.nested_model)
		q.condition("other_run_start", Q.fetch("init_run_start"))
		q.condition("t", Q.fetch("t")) 
		q.condition("run_start", Q.get_obs("other_run_start"))

		for i in xrange(30):
			# the runner wants all detections to be False
			q.condition("detected_t_"+str(i), False)

			#XXX NO, we don't want the worst case scenario: The Runner should have a Naive model of the Chaser
			# worse case scenario where runner fully observes chaser
			# if i < t:
			# 	q.condition("other_run_x_"+str(prev_t), Q.fetch("init_run_x_"+str(i)))
			# 	q.condition("other_run_y_"+str(prev_t), Q.fetch("init_run_y_"+str(i)))

		#print q.cond_data_db
		# need to think about this a bit more - iris - 1.17.2018
		# thought about it -- I think I want the path with the least number of detections
		# since this nested bit is in the runner's perspective
		post_sample_traces, trace =  self.get_trace_for_least_detected_path_PO(q)

		return post_sample_traces, trace
示例#5
0
    def collaborative_nested_inference(self, Q):
        t = Q.fetch("t")
        q = ProgramTrace(self.nested_model)
        q.condition("other_run_start", Q.fetch("init_run_start"))
        q.condition("t", Q.fetch("t"))
        q.condition("run_start", Q.get_obs("other_run_start"))
        q.condition("same_goal", True)

        # Assumes that if Agent A detects Agent B, then Agent B detects Agent A
        for i in xrange(24):
            q.condition("detected_t_" + str(i),
                        Q.get_obs("detected_t_" + str(i)))

            #condition on observations from other agent of me
            if (Q.get_obs("detected_t_" + str(i)) == True):
                if (i == (t - 1)):
                    q.condition("run_x_" + str(i),
                                Q.get_obs("other_x_" + str(i)))
                    q.condition("run_y_" + str(i),
                                Q.get_obs("other_y_" + str(i)))

        prev_t = (t - 1)
        q.condition("other_run_x_" + str(prev_t),
                    Q.fetch("init_run_x_" + str(prev_t)))
        q.condition("other_run_y_" + str(prev_t),
                    Q.fetch("init_run_y_" + str(prev_t)))

        print q.cond_data_db
        trace = self.get_trace_for_most_probable_goal_location(q)

        return trace
示例#6
0
	def condition_middle_model(self, Q):
		t = Q.fetch("t")
		q = ProgramTrace(self.nested_model)
		q.condition("other_run_start", Q.fetch("init_run_start"))
		#XXX just for testing purposes XXX remove in real simulation
		#q.condition("other_run_goal", Q.fetch("init_run_goal"))
		q.condition("t", Q.fetch("t")) 
		q.condition("run_start", Q.get_obs("other_run_start"))
		#XXX just for testing purposes XXX remove in real simulation
		#q.condition("run_goal", Q.get_obs("other_run_goal"))

		for i in xrange(0, 29):
			# the runner wants all detections to be False
			# ****** NEED *****
			q.condition("detected_t_"+str(i), False)
			# assumes that the chaser's runner has a perfect knowledge of the chaser
			if i <  t:
				q.set_obs("other_run_x_"+str(i), Q.get_obs("init_run_x_"+str(i)))
				q.set_obs("other_run_y_"+str(i), Q.get_obs("init_run_y_"+str(i)))
		
		#print ("runner conditioned vals:", q.cond_data_db)

		return q