planning with uncertainty variable elimination for decision networks ve dn is variable elimination for decision networks the method optimize is used to optimize all the decisions note that optimize requires legal elimination ordering of the random and decision variablesotherwise it will give an exception ( decision node can only be maximized if the variables that are not its parents have already been eliminated decnnetworks py -(continued from probve import ve class ve_dn(ve)"""variable elimination for decision networks""def __init__(self,dn=none)"""dn is decision network""ve __init__(self,dnself dn dn def optimize(self,elim_order=none,obs={})if elim_order =noneelim_order reversed(self gm split_order()policy [proj_factors [self project_observations(fact,obsfor fact in self dn factorsfor in elim_orderif isinstance( ,decisionvariable)to_max [fac for fac in proj_factors if in fac variables and set(fac variables< all_varsassert len(to_max)== "illegal variable order "+str(elim_order)+at "+str(vnewfac factormax(vto_max[ ]policy append(newfac decision_funproj_factors [fac for fac in proj_factors if fac is not to_max[ ]]+[newfacself display( ,"maximizing", ,"resulting factor",newfac brief(self display( ,newfacelseproj_factors self eliminate_var(proj_factorsvassert len(proj_factors)== ,"should there be only one element of proj_factors?value proj_factors[ get_value({}return value,policy decnnetworks py -(continued class factormax(factor)""" factor obtained by maximizing variable in factor also builds decision_function this is based on factorsum ""version june