Esempio n. 1
0
 def get_constraints(self) -> Iterable[expr.BooleanExpression]:
     constraints = []
     base_quantities = [
         variable.get_name().replace('_1', '')
         for variable in self.problem.get_variables()
         if variable.get_name().endswith('_1')
     ]
     for quantity in base_quantities:
         original_variables = [
             variable for variable in self.problem.get_variables()
             if re.search(quantity +
                          '_[0-9]+$', variable.get_name()) is not None
         ]
         aggregate_variables = [
             variable for variable in self.problem.get_variables()
             if re.search(
                 quantity + '_(' +
                 '|'.join(ms_data_utility.AGGREGATE_FUNCTIONS) +
                 ')$', variable.get_name()) is not None
         ]
         constraints.append(
             expr.Not(
                 expr.And([
                     expr.Or(original_variables),
                     expr.Or(aggregate_variables)
                 ])))
     return constraints
Esempio n. 2
0
 def get_constraints(self) -> Iterable[expr.BooleanExpression]:
     variable_groups = []
     for aggregate in ms_data_utility.AGGREGATE_FUNCTIONS:
         variable_group = [
             variable for variable in self.problem.get_variables()
             if variable.get_name().endswith('_' + aggregate)
         ]
         variable_groups.append(variable_group)
     return [expr.AtMost([expr.Or(x) for x in variable_groups], 1)]
Esempio n. 3
0
 def get_constraints(self) -> Iterable[expr.BooleanExpression]:
     gamma_variables = [
         variable for variable in self.problem.get_variables()
         if 'gamma' in variable.get_name()
     ]
     gamma_abs_variables = [
         variable for variable in gamma_variables
         if 'gamma_abs' in variable.get_name()
     ]
     gamma_variables = [
         variable for variable in gamma_variables
         if 'gamma_abs' not in variable.get_name()
     ]
     return [
         expr.Not(
             expr.And(
                 [expr.Or(gamma_variables),
                  expr.Or(gamma_abs_variables)]))
     ]
Esempio n. 4
0
 def get_constraints(self) -> Iterable[expr.BooleanExpression]:
     variable_groups = []
     for slip_group in SCHMID_GROUPS_100:
         variable_group = [
             variable for variable in self.problem.get_variables()
             if re.search(
                 '_(' + '|'.join([str(i) for i in slip_group]) +
                 ')$', variable.get_name()) is not None
         ]
         variable_groups.append(variable_group)
     return [expr.AtMost([expr.Or(x) for x in variable_groups], 1)]
Esempio n. 5
0
 def get_constraints(self) -> Iterable[expr.BooleanExpression]:
     constraints = []
     base_quantities = [
         variable.get_name().replace('_1', '')
         for variable in self.problem.get_variables()
         if variable.get_name().endswith('_1')
     ]
     for quantity in base_quantities:
         variable_groups = []
         for slip_group in SCHMID_GROUPS_100:
             variable_group = [
                 variable for variable in self.problem.get_variables()
                 if re.search(
                     quantity + '_(' +
                     '|'.join([str(i) for i in slip_group]) +
                     ')$', variable.get_name()) is not None
             ]
             variable_groups.append(variable_group)
         constraints.append(
             expr.AtMost([expr.Or(x) for x in variable_groups], 1))
     return constraints