本文整理汇总了Python中writer.Writer.start_next_time_step方法的典型用法代码示例。如果您正苦于以下问题:Python Writer.start_next_time_step方法的具体用法?Python Writer.start_next_time_step怎么用?Python Writer.start_next_time_step使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类writer.Writer
的用法示例。
在下文中一共展示了Writer.start_next_time_step方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CountertraceFinder
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import start_next_time_step [as 别名]
#.........这里部分代码省略.........
trace_elem = utils.swap_present_next(concrete_next_input)
countertrace.append(utils.keep_only_present_inputs(trace_elem))
# the new current_set_of_states is the set of next states (if
# concrete_next_input is used as input):
state_plus_input_ix_jx *= concrete_next_input
next_states = state_plus_input_ix_jx * utils.sys_trans
next_states = utils.swap_present_next(next_states)
current_set_of_states = utils.keep_only_present(next_states)
# If we are here, we found an input for every time step.
repeat_index = self.get_index_of_superset_in_list(list_of_sets, \
current_set_of_states) + 1
trace = InfiniteTraceOfBdds(utils, countertrace, repeat_index)
return trace
def print_trace(self, countertrace):
"""
Prints a countertrace into the file
./spec_debug_results/countertrace.txt.
@param countertrace: A sequence of inputs so that the system is forced
to violate its specification.
@type countertrace: L{InfiniteTraceOfBdds}
"""
# write the inputs according to the countertrace:
for input_bdd in countertrace.get_trace():
for var in self.__utils.input_vars:
symb = self.__utils.get_val_as_string(input_bdd, var, False)
self.__writer.set_chosen_input(var.name, symb)
self.__writer.start_next_time_step()
# finally we define where the trace repeats:
self.__writer.set_repeat_indices(countertrace.repeat_index, \
countertrace.length_stem_plus_loop - 1)
# and write the file:
self.__writer.write_to_file("./spec_debug_results/countertrace.txt")
self.__writer.clear()
def is_graph_system_independent(self, graph_nodes):
"""
Checks if the inputs in a graph are system independent.
This method checks if the inputs in the graph computed by the class
L{PathFinder} are system independent. If this is the case, a
countertrace can be read directly from this graph. If the graph was
generated from a countertrace, the inputs in this graph will always
be system independent (i.e., independent of the moves of the system).
This method is only used to check if the methods compute_countertrace
and make_strategy_system_independent work correctly.
@param graph_nodes: A set of graph nodes.
@type graph_nodes: list<L{GraphNode}>
@return: True if the graph is system independent, False otherwise
@rtype: bool
"""
# The first current state is the initial state:
current_nodes = [graph_nodes[0]]
current_nodes_bdd = graph_nodes[0].bdd
list_of_sets = []
示例2: InteractiveGame
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import start_next_time_step [as 别名]
#.........这里部分代码省略.........
# print the output variables:
for out_var in self.__utils.relevant_out_vars:
symb = self.__utils.get_val_as_string(current_state, out_var, False)
print "current " + out_var.name + " is: " + symb
self.__writer.set_chosen_output(out_var.name, symb);
# print the ix-variables:
ix_value = self.__utils.get_decimal_ix_val(current_state, False)
if ix_value != None:
print "The environment tries to fulfill fairness condition nr",
print str(ix_value) + " next";
self.__writer.set_chosen_aux("ix", str(ix_value))
else:
print "The environment has not decided yet which fairness",
print "condition it will try to reach next"
self.__writer.set_chosen_aux("ix","?")
# print the jx-variables:
nr_changes = self.__utils.how_often_may_jx_change(current_state, \
self.__z_array)
self.__writer.set_chosen_aux("jx changes", str(nr_changes))
jx_value = self.__utils.get_decimal_jx_val(current_state, False);
if jx_value != None:
print "I try to keep the system from fulfilling fairness",
print "condition nr: " + str(jx_value)
print "I reserve the right to change my opinion on that at most",
print str(nr_changes) + " times from now"
self.__writer.set_chosen_aux("jx", str(jx_value))
else:
print "I have not decided yet which fairness condition of the",
print "system I will try to evade";
self.__writer.set_chosen_aux("jx","?")
self.__writer.start_next_time_step()
def _print_next_inputs(self, next_inputs):
"""
Prints all next inputs in a bdd.
@param next_inputs: A bdd containing the next inputs.
@type next_inputs: L{BDD}
"""
for in_var in self.__utils.input_vars:
symb = self.__utils.get_val_as_string(next_inputs, in_var, True)
print "next " + in_var.name + " is: " + symb
def _read_out_vars(self, possible_outputs):
"""
Reads all next output values from STDIN.
This method asks the user to enter the next values of the output
variables of the system. It also resolves all restrictions on the
variables (due to the transition relation of the system and previously
entered variables) and displays possible values for the variable
in brackets:
- enter next hgrant0 (1): means only 1 is allowed for the next hgrant0
- enter next hgrant0 (0): means only 0 is allowed for the next hgrant0
- enter next hgrant0 (0,1): means that you can pick whatever you want
The user is only allowed to enter '0', '1' or 'Q' if she wants to
quit the game.
@param possible_outputs: A bdd with all possible next outputs.
@type possible_outputs: L{BDD}