예제 #1
0
    def __init__(self, *args, **kwargs):
        #if len(args) > 1: self.err('incorrect args number for GLP constructor, must be 0..1 + (optionaly) some kwargs')

        NonLinProblem.__init__(self, *args, **kwargs)
        
        def maxNonSuccess(p):
            newPoint = p.point(p.xk)
            if self._currentBestPoint is None:
                self._currentBestPoint = newPoint
                return False
            elif newPoint.betterThan(self._currentBestPoint):
                self._currentBestPoint = newPoint
                self._nonSuccessCounter = 0
                return False
            self._nonSuccessCounter += 1
            if self._nonSuccessCounter > self.maxNonSuccess:
                return (True, 'Non-Success Number > maxNonSuccess = ' + str(self.maxNonSuccess))
            else:
                return False
        
        self.kernelIterFuncs[MAX_NON_SUCCESS] = maxNonSuccess
        if 'lb' in kwargs.keys():
            self.n = len(kwargs['lb'])
        elif 'ub' in kwargs.keys():
            self.n = len(kwargs['ub'])
        if hasattr(self, 'n'):
            if not hasattr(self, 'lb'):
                self.lb = -inf * ones(self.n)
            if not hasattr(self, 'ub'):
                self.ub =  inf * ones(self.n)
            if 'x0' not in kwargs and len(args) < 2: 
                self.x0 = (asarray(self.lb) + asarray(self.ub)) / 2.0
예제 #2
0
파일: IP.py 프로젝트: javafx2010/OOSuite
 def __init__(self, *args, **kwargs):
     NonLinProblem.__init__(self, *args, **kwargs)
     domain = args[1]
     self.x0 = dict([(v, 0.5*(val[0]+val[1])) for v, val in domain.items()])
     self.constraints = [v>bounds[0] for v,  bounds in domain.items()] + [v<bounds[1] for v,  bounds in domain.items()]
     #self.data4TextOutput = ['objFunVal', 'residual']
     self._Residual = inf
예제 #3
0
 def __init__(self, *args, **kwargs):
     NonLinProblem.__init__(self, *args, **kwargs)
     self.nSolutions = 'all'
     self.kernelIterFuncs.pop(SMALL_DELTA_X, None)
     self.kernelIterFuncs.pop(SMALL_DELTA_F, None)
     self.data4TextOutput = ['front length', 'income', 'outcome', 'log10(maxResidual)']
     f = self.f
     i = 0
     targets = []
     while True:
         if len(f[i:]) == 0: break
         func = f[i]
         if type(func) in (list, tuple):
             F, tol, val = func
             i += 1
         else:
             F, tol, val = f[i], f[i+1], f[i+2]
             i += 3
         t = target()
         t.func, t.tol = F, tol
         t.val = val if type(val) != str \
         else inf if val in ('max', 'maximum') \
         else -inf if val in ('min', 'minimum') \
         else self.err('incorrect MOP func target')
         targets.append(t)
     self.targets = targets
     self.f = [t.func for t in targets]
     self.user.f = self.f
예제 #4
0
    def __init__(self, *args, **kwargs):
        #if len(args) > 1: self.err('incorrect args number for GLP constructor, must be 0..1 + (optionaly) some kwargs')

        NonLinProblem.__init__(self, *args, **kwargs)

        def maxNonSuccess(p):
            newPoint = p.point(p.xk)
            if self._currentBestPoint is None:
                self._currentBestPoint = newPoint
                return False
            elif newPoint.betterThan(self._currentBestPoint):
                self._currentBestPoint = newPoint
                self._nonSuccessCounter = 0
                return False
            self._nonSuccessCounter += 1
            if self._nonSuccessCounter > self.maxNonSuccess:
                return (True, 'Non-Success Number > maxNonSuccess = ' +
                        str(self.maxNonSuccess))
            else:
                return False

        self.kernelIterFuncs[MAX_NON_SUCCESS] = maxNonSuccess
        if 'lb' in kwargs.keys():
            self.n = len(kwargs['lb'])
        elif 'ub' in kwargs.keys():
            self.n = len(kwargs['ub'])
        if hasattr(self, 'n'):
            if not hasattr(self, 'lb'):
                self.lb = -inf * ones(self.n)
            if not hasattr(self, 'ub'):
                self.ub = inf * ones(self.n)
            if 'x0' not in kwargs and len(args) < 2:
                self.x0 = (asarray(self.lb) + asarray(self.ub)) / 2.0
예제 #5
0
파일: IP.py 프로젝트: AlbertHolmes/openopt
 def __init__(self, *args, **kwargs):
     NonLinProblem.__init__(self, *args, **kwargs)
     domain = args[1]
     self.x0 = dict([(v, 0.5 * (val[0] + val[1])) for v, val in domain.items()])
     self.constraints = [v > bounds[0] for v, bounds in domain.items()] + [
         v < bounds[1] for v, bounds in domain.items()
     ]
     # self.data4TextOutput = ['objFunVal', 'residual']
     self._Residual = inf
예제 #6
0
파일: DFP.py 프로젝트: javafx2010/OOSuite
 def __init__(self, *args, **kwargs):
     NonLinProblem.__init__(self, *args, **kwargs)
     assignScript(self, kwargs)
     self.fff = self.f
     def ff(x):
         r = []
         for i in range(self.Y.shape[0]):
             r.append(asfarray(self.fff(x, self.X[i])-self.Y[i])**2)
         return r
     self.f = ff
예제 #7
0
파일: ODE.py 프로젝트: AlbertHolmes/openopt
 def __init__(self, *args, **kwargs):
     NonLinProblem.__init__(self, *args, **kwargs)
     domain= args[1]
     self.x0 = domain
예제 #8
0
파일: NLSP.py 프로젝트: javafx2010/OOSuite
 def __init__(self, *args, **kwargs):
     NonLinProblem.__init__(self, *args, **kwargs)
     if 'is_oovar' in dir(self.f):
         self.f = [self.f]
예제 #9
0
파일: MINLP.py 프로젝트: javafx2010/OOSuite
 def __init__(self, *args, **kwargs):
     self.goal = 'minimum'
     self.discreteVars = {}
     NonLinProblem.__init__(self, *args, **kwargs)
     self.iprint = 1
예제 #10
0
파일: NSP.py 프로젝트: AlbertHolmes/openopt
 def __init__(self, *args, **kwargs):
     self.goal = 'minimum'
     NonLinProblem.__init__(self, *args, **kwargs)
예제 #11
0
 def __init__(self, *args, **kwargs):
     NonLinProblem.__init__(self, *args, **kwargs)
예제 #12
0
 def __init__(self, *args, **kwargs):
     NonLinProblem.__init__(self, *args, **kwargs)
예제 #13
0
 def __init__(self, *args, **kwargs):
     self.goal = 'minimum'
     self.discreteVars = {}
     NonLinProblem.__init__(self, *args, **kwargs)
     self.iprint=1
예제 #14
0
 def __init__(self, *args, **kwargs):
     self.goal = 'minimum'
     NonLinProblem.__init__(self, *args, **kwargs)
예제 #15
0
 def __init__(self, *args, **kwargs):
     NonLinProblem.__init__(self, *args, **kwargs)
     domain = args[1]
     self.x0 = domain
예제 #16
0
 def __init__(self, *args, **kwargs):
     NonLinProblem.__init__(self, *args, **kwargs)
     if 'is_oovar' in dir(self.f):
         self.f = [self.f]