コード例 #1
0
#          tpnu = Tpnu.from_tpn_autogen(obj)
#      else:
#          raise Exception("Input file " + path + " is neither a CCTP nor a TPN")

#      return tpnu

#  example_file = 'Zipcar-1.cctp'

#  cdru_dir = dirname(__file__)
#  examples_dir = join(cdru_dir, join('..', 'examples'))
#  path = join(examples_dir, example_file)
#  tpnu = getProblemFromFile(path)

# NOTE: Limitation: Assumes num_nodes = N, then events are indexed by 1, 2, ..., N
# TODO: Currently, Tpnu.from_tpn_autogen does map eventID to numbers, but it does not take TPNU as input, if we want to use arbitrary event names, we need to add such a function/mapping
tpnu = Tpnu(str(uuid4()), 'example-tpnu')
tpnu.start_node = 1
tpnu.num_nodes = 3

# Initialize a decision variable
dv = DecisionVariable(str(uuid4()), 'dv')
as1 = Assignment(dv, 'dv-true', 10)
as2 = Assignment(dv, 'dv-false', 3)
dv.add_domain_value(as1)
dv.add_domain_value(as2)
tpnu.add_decision_variable(dv)

# Initialize temporal constraints
tc1 = TemporalConstraint(str(uuid4()), 'tc1', 1, 2, 0, 10)
tc1.controllable = False
tpnu.add_temporal_constraint(tc1)