def relax_objective(self, problem, objective): result = self.relax_expression(problem, objective.root_expr, side=RelaxationSide.UNDER) new_objective = Objective(objective.name, result.expression, objective.original_sense) return RelaxationResult(new_objective, result.constraints)
def relax_objective(self, problem, objective): self._objective_count += 1 if self._objective_count > 1: raise ValueError( 'Apply LinearRelaxation to multiobjective problem') new_variable = Variable('_objvar', None, None, Domain.REAL) new_objective_expr = LinearExpression([new_variable], [1.0], 0.0) new_objective = Objective( objective.name, new_objective_expr, objective.original_sense, ) under_result = self.relax_expression(problem, objective.root_expr) new_cons_expr = SumExpression([ under_result.expression, LinearExpression([new_variable], [-1.0], 0.0), ]) new_cons = Constraint('_obj_{}'.format(objective.name), new_cons_expr, None, 0.0) under_result.constraints.append(new_cons) return RelaxationResult(new_objective, under_result.constraints)
def relax_constraint(self, problem, constraint): cons_idx = self._constraint_idx[constraint.name] u = self._u[cons_idx] minus_u = LinearExpression([u], [-1], 0.0) new_expr = SumExpression([constraint.root_expr, minus_u]) new_constraint = Constraint(constraint.name, new_expr, constraint.lower_bound, constraint.upper_bound) return RelaxationResult(new_constraint, [])
def relax_constraint(self, problem, constraint): if constraint.lower_bound is None: side = RelaxationSide.UNDER elif constraint.upper_bound is None: side = RelaxationSide.OVER else: side = RelaxationSide.BOTH result = self.relax_expression(problem, constraint.root_expr, side=side) new_constraint = Constraint(constraint.name, result.expression, constraint.lower_bound, constraint.upper_bound) new_constraint.metadata = constraint.metadata return RelaxationResult(new_constraint, result.constraints)
def relax_constraint(self, problem, constraint): result = self.relax_expression(problem, constraint.root_expr) new_constraint = Constraint(constraint.name, result.expression, constraint.lower_bound, constraint.upper_bound) return RelaxationResult(new_constraint, result.constraints)
def relax_constraint(self, problem, constraint): return RelaxationResult(constraint)
def relax_objective(self, problem, objective): return RelaxationResult(objective)
def relax_objective(self, problem, objective): result = self.relax_expression(problem, objective.root_expr) new_objective = Objective(objective.name, result.expression, objective.sense) return RelaxationResult(new_objective, result.constraints)
def relax_constraint(self, problem, constraint): if constraint.name != 'cons2': return RelaxationResult(constraint) w = Variable('aux', None, None, None) return RelaxationResult(Constraint('aux_cons2', w, None, None))
def relax_objective(self, problem, objective): coefficients = np.ones(problem.num_constraints) expr = LinearExpression(self._u, coefficients.tolist(), 0.0) new_objective = Objective('objective', expr, Sense.MINIMIZE) return RelaxationResult(new_objective, [])