Ejemplo n.º 1
0
 def __init__(self, constraints_extract, splitvars_flag):
     self.var_dis = vd()
     self.sv_pre_map, self.sv_pre_inv_map = self.pre_map_gen(
         constraints_extract.predicates)
     #print(self.sv_pre_map)
     self.sv_post_map, self.sv_post_inv_map = self.post_map_gen(
         constraints_extract.predicates)
     #print(self.sv_post_map)
     self.num_predicates = len(constraints_extract.predicates)
     self.action_vars = constraints_extract.action_vars
     self.predicate_dict = constraints_extract.predicate_dict
     self.predicate_types = constraints_extract.predicate_types
     self.max_predicate_args = constraints_extract.max_predicate_args
     self.av_map, self.av_inv_map, self.parameter_map = self.action_map_gen(
         len(constraints_extract.predicates),
         constraints_extract.action_vars,
         constraints_extract.bin_object_type_vars_dict)
     #print(self.av_map)
     #print(self.av_inv_map)
     #print(self.parameter_map)
     self.obj_forall_vars = {}
     self.split_predicates_forall_vars = []
     self.forall_vars_gen(constraints_extract.forall_variables_type_dict,
                          constraints_extract.bin_object_type_vars_dict,
                          constraints_extract.max_predicate_args)
     #print(self.obj_forall_vars)
     [self.next_gate_var] = self.var_dis.get_vars(1)
     self.integer_tfun = self.integer_tfun_gen(
         constraints_extract.predicate_split_action_list,
         constraints_extract.predicates)
     self.gates_gen = gg(self, splitvars_flag)
     self.num_aux_vars = self.gates_gen.total_gates - self.next_gate_var + 1
Ejemplo n.º 2
0
    def __init__(self, constraints_extract, tfun, k):
        self.var_dis = vd()
        self.action_vars = []
        self.forall_vars_first = []
        self.forall_vars_second = []
        self.quantifier_block = []
        self.encoding = []
        self.initial_output_gate = 0  # initial output gate can never be 0
        self.goal_output_gate = 0  # goal output gate can never be 0
        self.if_tfun_gate = 0  # if transition gate can never be 0
        self.if_then_tfun_gate = 0  # if then transition gate can never be 0
        self.final_output_gate = 0  # final output gate can never be 0

        # generating k+1 states, since k steps:
        self.states_gen = sg(self.var_dis, tfun.num_state_vars, k)
        #print(states_gen.states)

        self.generate_forall_var(tfun.num_state_vars)

        self.generate_initial_gate(constraints_extract)

        self.generate_goal_gate(constraints_extract, k)

        self.generate_if_block_for_transition(tfun.num_state_vars, k)

        self.generate_if_then_transition(tfun)

        self.generate_final_gate()

        self.generate_quantifier_blocks()
Ejemplo n.º 3
0
    def __init__(self, constraints_extract, tfun, k, extraction):
        self.var_dis = vd()
        self.action_vars = []
        self.quantifier_block = []
        self.encoding = []
        self.initial_output_gate = 0  # initial output gate can never be 0
        self.goal_output_gate = 0  # goal output gate can never be 0
        self.condition_output_gates = []
        self.extract_output_gates = []
        self.if_blocks = []
        self.transition_output_gate = 0  # transition output gate can never be 0
        self.final_output_gate = 0  # final output gate can never be 0

        self.initial_state = self.var_dis.get_vars(tfun.num_state_vars)
        self.goal_state = self.var_dis.get_vars(tfun.num_state_vars)

        # CTE encoding results in makespan of 2^(k+1)
        # We use 0 ... log_k -1 for consistency:
        self.log_k = int(math.log2(k))
        assert (math.pow(2, self.log_k) == k)

        # sg generates k+1 states, so using k - 1 as parameter:
        self.quantifier_states_gen = sg(self.var_dis, tfun.num_state_vars,
                                        (3 * self.log_k) - 1)

        # We only use log_k forall variables:
        self.forall_vars = self.var_dis.get_vars(self.log_k)

        self.transition_first_state = self.var_dis.get_vars(
            tfun.num_state_vars)

        self.transition_second_state = self.var_dis.get_vars(
            tfun.num_state_vars)

        # generating k actions variables for extraction:
        self.extraction_action_vars_gen = sg(self.var_dis,
                                             tfun.num_action_vars, k - 1)

        self.generate_initial_gate(constraints_extract)

        self.generate_zero_condition(tfun.num_state_vars)

        self.generate_conditions(tfun.num_state_vars)

        self.generate_transition_function(tfun)

        if (extraction):
            self.generate_extract_gates(tfun.num_action_vars, k)

        self.generate_goal_gate(constraints_extract, k)

        self.generate_final_gate(extraction)

        self.generate_quantifier_blocks(extraction)
Ejemplo n.º 4
0
    def __init__(self, constraints_extract, tfun, k, splitvars_flag,
                 actions_overlap_flag):
        self.var_dis = vd()
        self.quantifier_block = []
        self.encoding = []
        self.initial_output_gate = 0  # initial output gate can never be 0
        self.goal_output_gate = 0  # goal output gate can never be 0
        self.transition_step_output_gates = []
        self.if_existential_output_gate = 0  # existential final gate can never be 0
        self.final_transition_gate = 0  # final transition gate can never be 0
        self.final_output_gate = 0  # final output gate can never be 0

        self.predicates = []
        self.gen_predicate_vars(tfun, k)

        if (actions_overlap_flag == 0):
            self.action_with_parameter_vars = []
            self.gen_action_with_parameter_vars(
                constraints_extract.bin_object_type_vars_dict,
                constraints_extract.action_vars, tfun, k)
        else:
            self.base_parameter_vars_with_overlap = []
            self.action_with_parameter_vars_with_overlap = []
            self.gen_action_with_parameter_vars_with_overlap(
                constraints_extract.bin_object_type_vars_dict,
                constraints_extract.action_vars_overlap_dict,
                constraints_extract.action_vars, tfun, k)

        self.forall_vars = []
        self.forall_vars_map = {}
        self.gen_forall_vars(tfun.obj_forall_vars)

        self.split_forall_vars = self.var_dis.get_vars(
            len(tfun.split_predicates_forall_vars))
        #print(self.split_forall_vars)

        self.generate_k_transitions(tfun, k, actions_overlap_flag)

        self.generate_initial_gate(constraints_extract, splitvars_flag)
        self.generate_goal_gate(constraints_extract, k, splitvars_flag)

        self.gen_conditional_transition_gates(
            constraints_extract.updated_objects)

        self.gen_if_existential_gate(constraints_extract.updated_objects,
                                     constraints_extract.action_vars,
                                     actions_overlap_flag, k)

        self.generate_final_gate()

        self.generate_quantifier_blocks(k, splitvars_flag,
                                        actions_overlap_flag)
  def __init__(self, constraints_extract, splitvars_flag):
    self.var_dis = vd()
    #self.sv_pre_map, self.sv_pre_inv_map = self.map_gen(constraints_extract.predicates)
    #print(self.sv_pre_map)
    #self.sv_post_map, self.sv_post_inv_map = self.map_gen(constraints_extract.predicates)
    #print(self.sv_post_map)

    # Generating static predicates map for preconditions, which is earlier time step:
    self.s_sv_pre_map, self.s_sv_pre_inv_map = self.map_gen(constraints_extract.static_predicates)
    # Generating non-static predicates map for preconditions, which is earlier time step:
    self.ns_sv_pre_map, self.ns_sv_pre_inv_map = self.map_gen(constraints_extract.non_static_predicates)
    # Generating non-static predicates map for post conditions, which is later time step:
    self.ns_sv_post_map, self.ns_sv_post_inv_map = self.map_gen(constraints_extract.non_static_predicates)

    self.num_predicates = len(constraints_extract.predicates)
    self.num_static_predicates = len(constraints_extract.static_predicates)
    self.num_nonstatic_predicates = len(constraints_extract.non_static_predicates)
    self.action_vars = constraints_extract.action_vars
    self.predicate_dict = constraints_extract.predicate_dict
    self.static_predicates = constraints_extract.static_predicates
    self.nonstatic_predicates = constraints_extract.non_static_predicates
    #print(self.static_predicates)
    #print(self.nonstatic_predicates)
    self.predicate_types = constraints_extract.predicate_types
    self.max_predicate_args = constraints_extract.max_predicate_args
    self.av_map, self.av_inv_map, self.parameter_map = self.action_map_gen(len(constraints_extract.predicates), constraints_extract.action_vars, constraints_extract.bin_object_type_vars_dict)
    #print(self.av_map)
    #print(self.av_inv_map)
    #print(self.parameter_map)
    self.obj_forall_vars = {}
    self.split_predicates_forall_vars = []
    self.forall_vars_gen(constraints_extract.forall_variables_type_dict, constraints_extract.bin_object_type_vars_dict, constraints_extract.max_predicate_args)
    #print(self.obj_forall_vars)
    [self.next_gate_var] = self.var_dis.get_vars(1)
    #self.integer_tfun = self.integer_tfun_gen(constraints_extract.predicate_split_action_list, constraints_extract.predicates)
    self.integer_tfun = self.integer_tfun_gen(constraints_extract.predicate_static_and_nonstatic_split_action_list, constraints_extract.predicates)
    #for action in self.integer_tfun:
    #  print(action)
    self.gates_gen = gg(self, splitvars_flag)
    self.num_aux_vars = self.gates_gen.total_gates - self.next_gate_var + 1
Ejemplo n.º 6
0
  def __init__(self, constraints_extract, tfun, k, prune):
    self.var_dis = vd()
    self.action_vars = []
    self.quantifier_block = []
    self.encoding = []
    self.initial_output_gate = 0 # initial output gate can never be 0
    self.goal_output_gate = 0 # goal output gate can never be 0
    self.if_conditions_output_gate = 0 # if conditions gate can never be 0
    self.condition_output_gates = []
    self.transition_output_gate = 0 # transition output gate can never be 0
    self.final_conditional_transition_gate = 0 # never 0 if pruning is turned on
    self.final_output_gate = 0 # final output gate can never be 0

    # generating k+1 states, since k steps:
    self.states_gen = sg(self.var_dis, tfun.num_state_vars, k)

    self.log_k = int(math.log2(k))
    # If k not a power of 2, one more bit needed:
    if (math.pow(2,self.log_k) != k):
      self.log_k = self.log_k + 1

    self.forall_vars = self.var_dis.get_vars(self.log_k)

    self.transition_first_state = self.var_dis.get_vars(tfun.num_state_vars)

    self.transition_second_state = self.var_dis.get_vars(tfun.num_state_vars)

    self.generate_initial_gate(constraints_extract)

    self.generate_k_conditions(tfun.num_state_vars, k, prune)

    self.generate_transition_function(tfun, prune)

    self.generate_goal_gate(constraints_extract, k)

    self.generate_final_gate(prune)

    self.generate_quantifier_blocks()
Ejemplo n.º 7
0
  def __init__(self, constraints_extract, tfun, k):
    self.var_dis = vd()
    self.action_vars = []
    self.quantifier_block = []
    self.encoding = []
    self.initial_output_gate = 0 # initial output gate can never be 0
    self.goal_output_gate = 0 # goal output gate can never be 0
    self.transition_step_output_gates = []
    self.final_output_gate = 0 # final output gate can never be 0

    # generating k+1 states, since k steps:
    self.states_gen = sg(self.var_dis, tfun.num_state_vars, k)
    #print(states_gen.states)

    self.generate_initial_gate(constraints_extract)

    self.generate_k_transitions(tfun, k)

    self.generate_goal_gate(constraints_extract, k)

    self.generate_final_gate()

    self.generate_quantifier_blocks()
Ejemplo n.º 8
0
    def __init__(self, constraints_extract, tfun, k, splitvars_flag,
                 actions_overlap_flag, actions_fold_flag, fold_num):
        self.var_dis = vd()
        self.quantifier_block = []
        self.encoding = []
        self.initial_output_gate = 0  # initial output gate can never be 0
        self.goal_output_gate = 0  # goal output gate can never be 0
        self.transition_step_output_gates = []
        self.if_existential_output_gate = 0  # existential final gate can never be 0
        self.final_transition_gate = 0  # final transition gate can never be 0
        self.final_output_gate = 0  # final output gate can never be 0

        # The number of varibles to use for one time step:
        self.fold_num = fold_num
        # The maximum number of variables available for one time step:
        self.max_parameters = -1  # can never be -1, must be updated later:

        self.predicates = []
        self.static_predicates = []
        self.gen_predicate_vars(tfun, k)

        if (actions_overlap_flag == 1):
            self.base_parameter_vars_with_overlap = []
            self.action_with_parameter_vars_with_overlap = []
            self.gen_action_with_parameter_vars_with_overlap(
                constraints_extract.bin_object_type_vars_dict,
                constraints_extract.action_vars_overlap_dict,
                constraints_extract.action_vars, tfun, k)
        elif (actions_fold_flag == 1):
            self.base_parameter_vars_with_fold = []
            # Keeping same names, so that we do not change all the places:
            self.base_parameter_vars_with_overlap = []
            self.action_with_parameter_vars_with_overlap = []
            self.gen_action_with_parameter_vars_with_fold(
                constraints_extract.bin_object_type_vars_dict,
                constraints_extract.action_vars_overlap_dict,
                constraints_extract.action_vars, tfun, k)
        else:
            self.action_with_parameter_vars = []
            self.gen_action_with_parameter_vars(
                constraints_extract.bin_object_type_vars_dict,
                constraints_extract.action_vars, tfun, k)

        self.forall_vars = []
        self.forall_vars_map = {}
        self.gen_forall_vars(tfun.obj_forall_vars)

        self.split_forall_vars = self.var_dis.get_vars(
            len(tfun.split_predicates_forall_vars))
        #print(self.split_forall_vars)

        self.generate_k_transitions(tfun, k, actions_overlap_flag,
                                    actions_fold_flag)

        self.generate_initial_gate(constraints_extract, splitvars_flag)
        self.generate_goal_gate(constraints_extract, k, splitvars_flag)

        self.gen_conditional_transition_gates(
            constraints_extract.updated_objects)

        self.gen_if_existential_gate(constraints_extract.updated_objects,
                                     constraints_extract.action_vars,
                                     actions_overlap_flag, actions_fold_flag,
                                     k)

        self.generate_final_gate()

        self.generate_quantifier_blocks(k, splitvars_flag,
                                        actions_overlap_flag,
                                        actions_fold_flag)