parameters: (self,objective_scale,keep_bounds=True)
return_statement: return res
docstring: If this problem is constrained, returns a new problem in which
          the objective function is a scoring function that sums all of
          the equality / inequality errors at x plus
          objective_scale*objective function(x).  If objective_scale is small,
          then the scoring function is approximately minimized at a feasible
          minimum.
  
          If the problem is unconstrained, this just returns self.
  
          If keep_bounds = true, this does not add the bounds to the
          inequality errors.
docstring_summary: If this problem is constrained, returns a new problem in which
          the objective function is a scoring function that sums all of
          the equality / inequality errors at x plus
          objective_scale*objective function(x).  If objective_scale is small,
          then the scoring function is approximately minimized at a feasible
          minimum.
docstring_tokens: If this problem is constrained returns a new problem in which the objective function is a scoring function that sums all of the equality / inequality errors at x plus objective_scale * objective function ( x ) . If objective_scale is small then the scoring function is approximately minimized at a feasible minimum .
function: def makeUnconstrained(self,objective_scale,keep_bounds=True):
          """If this problem is constrained, returns a new problem in which
          the objective function is a scoring function that sums all of
          the equality / inequality errors at x plus
          objective_scale*objective function(x).  If objective_scale is small,
          then the scoring function is approximately minimized at a feasible
          minimum.
  
          If the problem is unconstrained, this just returns self.
  
          If keep_bounds = true, this does not add the bounds to the
          inequality errors.
          """
          #create a scoring function that is approximately minimized at
          #a feasible minimum
          if keep_bounds == False:
              raise NotImplementedError("getting rid of bounds is not implemented yet")
          if len(self.feasibilityTests) == 0 and len(self.inequalities) == 0 and len(self.equalities) == 0:
              #already unconstrained
              return self
  
          if len(self.inequalities) == 0 and len(self.equalities) == 0:
              #just have a feasibility test
              def flatObjective(x):
                  if any(not f(x) for f in self.feasibilityTests):
                      return float('inf')
                  return self.objective(x)
              res = OptimizationProblem()
              res.setObjective(flatObjective,self.objectiveGrad)
              res.bounds = self.bounds
              return res
  
          def flatObjective(x):
              if any(not f(x) for f in self.feasibilityTests):
                  return float('inf')
              f = 0
              #add sum of squared equalities
              for g in self.equalities:
                  gx = g(x)
                  f += max(abs(v) for v in gx)
              for h in self.inequalities:
                  hx = h(x)
                  f += sum(max(v,0) for v in hx)
              if self.objective is not None:
                  f += objective_scale*self.objective(x)
              return f
          
          res = OptimizationProblem()
          res.setObjective(flatObjective,None)
          res.bounds = self.bounds
          return res
function_tokens: def makeUnconstrained ( self , objective_scale , keep_bounds = True ) : #create a scoring function that is approximately minimized at #a feasible minimum if keep_bounds == False : raise NotImplementedError ( "getting rid of bounds is not implemented yet" ) if len ( self . feasibilityTests ) == 0 and len ( self . inequalities ) == 0 and len ( self . equalities ) == 0 : #already unconstrained return self if len ( self . inequalities ) == 0 and len ( self . equalities ) == 0 : #just have a feasibility test def flatObjective ( x ) : if any ( not f ( x ) for f in self . feasibilityTests ) : return float ( 'inf' ) return self . objective ( x ) res = OptimizationProblem ( ) res . setObjective ( flatObjective , self . objectiveGrad ) res . bounds = self . bounds return res def flatObjective ( x ) : if any ( not f ( x ) for f in self . feasibilityTests ) : return float ( 'inf' ) f = 0 #add sum of squared equalities for g in self . equalities : gx = g ( x ) f += max ( abs ( v ) for v in gx ) for h in self . inequalities : hx = h ( x ) f += sum ( max ( v , 0 ) for v in hx ) if self . objective is not None : f += objective_scale * self . objective ( x ) return f res = OptimizationProblem ( ) res . setObjective ( flatObjective , None ) res . bounds = self . bounds return res