def oppositeFunction(basef):
 if isinstance(basef, FitnessEvaluator):
  if isinstance(basef, FunctionEnvironment):
   ' added by JPQ '
   if isinstance(basef, MultiObjectiveFunction):
    res = MultiObjectiveFunction()
   else:
    res = FunctionEnvironment(basef.xdim, basef.xopt)
  else:
   res = FitnessEvaluator()
  res.f = (lambda x: (- basef.f(x)))
  if (not (basef.desiredValue is None)):
   res.desiredValue = (- basef.desiredValue)
  res.toBeMinimized = (not basef.toBeMinimized)
  return res
 else:
  return (lambda x: (- basef(x)))

def oppositeFunction ( basef ) : if isinstance ( basef , FitnessEvaluator ) : if isinstance ( basef , FunctionEnvironment ) : if isinstance ( basef , MultiObjectiveFunction ) : res = MultiObjectiveFunction ( ) else : res = FunctionEnvironment ( basef . xdim , basef . xopt ) else : res = FitnessEvaluator ( ) res . f = ( lambda x : ( - basef . f ( x ) ) ) if ( not ( basef . desiredValue is None ) ) : res . desiredValue = ( - basef . desiredValue ) res . toBeMinimized = ( not basef . toBeMinimized ) return res else : return ( lambda x : ( - basef ( x ) ) )
the opposite of a function .