本文整理汇总了Python中plan.Plan.append方法的典型用法代码示例。如果您正苦于以下问题:Python Plan.append方法的具体用法?Python Plan.append怎么用?Python Plan.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plan.Plan
的用法示例。
在下文中一共展示了Plan.append方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sample_plan
# 需要导入模块: from plan import Plan [as 别名]
# 或者: from plan.Plan import append [as 别名]
def sample_plan(self, plan_id, plan_length, rho, views, view_values, view_costs, current_view_id):
remaining_views = dict()
for v in views:
remaining_views[v.ID] = v
# current_view_id = remaining_views.keys()[0] NOW FUNCTION ARGUMENT
plan = Plan(plan_id)
# pmf for values
value_pmf = self._generate_value_pmf(view_values)
# pmf for costs
cost_pmf = self._generate_cost_pmf(current_view_id, remaining_views.keys(), rho, view_costs)
# joint dist
joint = make_joint(value_pmf, cost_pmf)
joint.normalize()
for j in range(plan_length):
x = joint.random()
plan.append(remaining_views[x])
remaining_views.pop(x)
# sample without replacement
# adapt both pmfs: value and cost
value_pmf.unset(x)
value_pmf.normalize()
cost_pmf = self._generate_cost_pmf(x, remaining_views.keys(), rho, view_costs)
# re-generate joint dist
joint = make_joint(value_pmf, cost_pmf)
joint.normalize()
return plan