Changeset 1095
- Timestamp:
- 07/04/08 08:42:46 (3 months ago)
- Files:
-
- trunk/openopt/scikits/openopt/Kernel/LLSP.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openopt/scikits/openopt/Kernel/LLSP.py
r1093 r1095 1 1 from ooMisc import assignScript 2 2 from BaseProblem import MatrixProblem 3 from numpy import asfarray, ones, inf, dot, nan, zeros, any 3 from numpy import asfarray, ones, inf, dot, nan, zeros, any, all, isfinite 4 4 from numpy.linalg import norm 5 5 import NLP … … 17 17 def objFunc(self, x): 18 18 r = norm(dot(self.C, x) - self.d) ** 2 / 2.0 19 if self.damp != 0: r += self.damp * norm(x-self.xd)**2 / 2.020 if any( self.f): r += dot(self.f, x)19 if not self.damp is None: r += self.damp * norm(x-self.xd)**2 / 2.0 20 if any(isfinite(self.f)): r += dot(self.f, x) 21 21 return r 22 22 … … 26 26 p.args.f = self # DO NOT USE p.args = self IN PROB ASSIGNMENT! 27 27 self.inspire(p) 28 p.checkdf()28 #p.checkdf() 29 29 r = p.solve(solver, **kwargs) 30 30 return r … … 43 43 prob.lb = -inf * ones(prob.n) 44 44 prob.ub = inf * ones(prob.n) 45 if not kwargs.has_key('damp'): kwargs['damp'] = 046 if not kwargs.has_key('xd'): kwargs['xd'] = zeros(prob.n)47 if not kwargs.has_key('f'): kwargs['f'] = zeros(prob.n)45 if not kwargs.has_key('damp'): kwargs['damp'] = None 46 if not kwargs.has_key('xd'): kwargs['xd'] = nan*ones(prob.n) 47 if not kwargs.has_key('f'): kwargs['f'] = nan*ones(prob.n) 48 48 49 49 if prob.x0 is nan: prob.x0 = zeros(prob.n) … … 57 57 def dff(x, LLSPprob): 58 58 r = dot(LLSPprob.C.T, dot(LLSPprob.C,x)) - dot(LLSPprob.C.T, LLSPprob.d) 59 if LLSPprob.damp != 0: r += LLSPprob.damp*(x - LLSPprob.xd)60 r += LLSPprob.f59 if not LLSPprob.damp is None: r += LLSPprob.damp*(x - LLSPprob.xd) 60 if all(isfinite(LLSPprob.f)) : r += LLSPprob.f 61 61 return r 62 62
