def generate(self, variables: Sequence[expr.Variable]) -> expr.BooleanExpression: if self.cardinality is None: cardinality = random.randint(1, len(variables) - 1) else: cardinality = self.cardinality return expr.AtMost(variables, cardinality)
def get_constraints(self) -> Iterable[expr.BooleanExpression]: variable_group = [ variable for variable in self.problem.get_variables() if re.match('eps_[a-z]{2}$', variable.get_name()) is not None ] if len(variable_group) == 0: return [] # z3.AtMost not defined if applied to empty list return [expr.AtMost(variable_group, 3)]
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)]
def get_constraints(self) -> Iterable[expr.BooleanExpression]: pattern = 'rho_(' + '|'.join(ms_data_utility.AGGREGATE_FUNCTIONS) + ')' +\ '|mean_free_path|free_path_per_voxel' variable_group = [ variable for variable in self.problem.get_variables() if re.match(pattern, variable.get_name()) is not None ] if len(variable_group) == 0: return [] # z3.AtMost not defined if applied to empty list return [expr.AtMost(variable_group, 1)]
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)]
def generate(self, variables: Sequence[expr.Variable]) -> expr.BooleanExpression: result = expr.Iff(variables) # If this constraint is the first, AND it with a Gloabl-AT-MOST constraint (AND makes sure # the number of constraints is not increased by two in one call of generate()). if (self.problem.get_num_constraints() == 0) and ( self.global_at_most < len(self.problem.get_variables())): global_at_most_constraint = expr.AtMost( self.problem.get_variables(), self.global_at_most) result = expr.And([global_at_most_constraint, result]) return result
def get_constraints(self) -> Iterable[expr.BooleanExpression]: constraints = [] 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 ] if len(variable_group ) > 0: # z3.AtMost not defined if applied to empty list constraints.append(expr.AtMost(variable_group, 1)) return constraints
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_group = [ variable for variable in self.problem.get_variables() if re.search( quantity + '_(' + '|'.join(ms_data_utility.AGGREGATE_FUNCTIONS) + ')$', variable.get_name()) is not None ] if len(variable_group ) > 0: # z3.AtMost not defined if applied to empty list constraints.append(expr.AtMost(variable_group, 1)) return constraints
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
def get_constraints(self) -> Iterable[expr.BooleanExpression]: return [expr.AtMost(self.problem.get_variables(), self.global_at_most)]