Exemplo 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
Exemplo n.º 2
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)]))
     ]
Exemplo n.º 3
0
 def get_constraints(self) -> Iterable[expr.BooleanExpression]:
     return [
         expr.Not(v) for v, q in zip(self.problem.get_variables(),
                                     self.problem.get_qualities())
         if q < self.threshold
     ]  # could also express this with expr.Implies()
Exemplo n.º 4
0
 def get_constraints(self) -> Iterable[expr.BooleanExpression]:
     return [
         expr.Not(expr.And([v1, v2])) for v1, v2 in self.correlation_pairs
     ]
Exemplo n.º 5
0
 def generate(self,
              variables: Sequence[expr.Variable]) -> expr.BooleanExpression:
     return expr.Not(expr.And(variables))