Changeset 1065
- Timestamp:
- 06/27/08 15:49:00 (2 months ago)
- Files:
-
- trunk/openopt/scikits/openopt/Kernel/Point.py (modified) (1 diff)
- trunk/openopt/scikits/openopt/Kernel/Residuals.py (modified) (3 diffs)
- trunk/openopt/scikits/openopt/Kernel/ooGraphics.py (modified) (7 diffs)
- trunk/openopt/scikits/openopt/Kernel/runProbSolver.py (modified) (1 diff)
- trunk/openopt/scikits/openopt/solvers/UkrOpt/lincher_oo.py (modified) (2 diffs)
- trunk/openopt/scikits/openopt/solvers/UkrOpt/nssolve_oo.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openopt/scikits/openopt/Kernel/Point.py
r1061 r1065 124 124 self._dmr, self._dmrName, self._dmrInd = g, resType, ind 125 125 if retAll: 126 return copy(self._dmr), self._dmrName, self._dmrInd126 return copy(self._dmr), self._dmrName, copy(self._dmrInd) 127 127 else: 128 128 return copy(self._dmr) trunk/openopt/scikits/openopt/Kernel/Residuals.py
r977 r1065 1 1 __docformat__ = "restructuredtext en" 2 from numpy import concatenate, asfarray, array, where, argmax, zeros 2 from numpy import concatenate, asfarray, array, where, argmax, zeros, isfinite 3 3 empty_arr = asfarray([]) 4 4 … … 73 73 if r < val_max: 74 74 r, ind, fname = val_max, ind_max, field 75 if self.probType == 'NLSP':76 fv = abs(self.f(x))77 ind_max = argmax(fv)78 val_max = fv[ind_max]79 if r < val_max:80 r, ind, fname = val_max, ind_max, 'f'75 # if self.probType == 'NLSP': 76 # fv = abs(self.f(x)) 77 # ind_max = argmax(fv) 78 # val_max = fv[ind_max] 79 # if r < val_max: 80 # r, ind, fname = val_max, ind_max, 'f' 81 81 if retAll: 82 82 return r, fname, ind … … 133 133 134 134 def isFeas(self, x): 135 return self.getMaxResidual(x) <= self.contol 135 is_X_finite = all(isfinite(x)) 136 is_ConTol_OK = self.getMaxResidual(x) <= self.contol 137 cond1 = is_ConTol_OK and is_X_finite 138 if self.probType == 'NLSP': return cond1 and self.F(x) < self.ftol 139 else: return cond1 136 140 137 141 trunk/openopt/scikits/openopt/Kernel/ooGraphics.py
r1047 r1065 79 79 #TODO: the condition should be handled somewhere other place, not here. 80 80 if p.probType == 'NLSP': 81 Y_LABELS = ['log10(max Constr)']82 pylab.plot([0], [log10(p.contol)-1.5])81 Y_LABELS = ['log10(maxResidual)'] 82 #pylab.plot([0], [log10(p.contol)-1.5]) 83 83 elif p.probType == 'LSP': 84 84 Y_LABELS = ['sum(residuals^2)'] 85 85 elif p.probType == 'LLSP': 86 p.err('LLSP graphic output not implemented yet')86 p.err('LLSP graphic output is not implemented yet') 87 87 else: 88 88 Y_LABELS = ['objFunc(x)'] … … 185 185 186 186 if p.probType == 'NLSP': 187 yy = log10(yy+p. contol/self.REDUCE)187 yy = log10(yy+p.ftol/self.REDUCE) 188 188 YY = [yy] 189 189 … … 199 199 pylab.plot([xx[0]+d_x], [YY[1][0]+1]) 200 200 pylab.subplot(2, 1, 1) 201 elif p.probType == 'NLSP':202 [xmin, xmax] = pylab.xlim()203 pylab.scatter([xx[0], xmax], [log10(yy[0]), log10(yy[0])], s=1, c='w', faceted=False, marker='o')204 pylab.axhline(y=log10(p.primalConTol), linewidth = self.axLineWidth, ls = self.axLineStyle, color='g',\205 marker = self.axMarker, ms = self.axMarkerSize, mew = self.markerEdgeWidth, mec = self.axMarkerEdgeColor, mfc = self.axFaceColor)206 pylab.xlim([xmin, xmax])201 # if p.probType == 'NLSP': 202 # [xmin, xmax] = pylab.xlim() 203 # pylab.scatter([xx[0], xmax], [log10(yy[0]), log10(yy[0])], s=1, c='w', faceted=False, marker='o') 204 # pylab.axhline(y=log10(p.primalConTol), linewidth = self.axLineWidth, ls = self.axLineStyle, color='g',\ 205 # marker = self.axMarker, ms = self.axMarkerSize, mew = self.markerEdgeWidth, mec = self.axMarkerEdgeColor, mfc = self.axFaceColor) 206 # pylab.xlim([xmin, xmax]) 207 207 208 208 … … 233 233 if isfinite(p.ylim[0]): pylab.plot([xx[0]], [p.ylim[0]], color='w') 234 234 if isfinite(p.ylim[1]): pylab.plot([xx[0]], [p.ylim[1]], color='w') 235 if p.probType == 'NLSP' or ind == 1: 235 if p.probType == 'NLSP': pylab.plot([xx[0]], [log10(p.ftol / self.REDUCE)], color='w') 236 if ind == 1: 236 237 pylab.plot([xx[0], xx[-1]], [log10(p.primalConTol), log10(p.primalConTol)], ls = self.axLineStyle, linewidth = self.axLineWidth, color='g',\ 238 marker = self.axMarker, ms = self.axMarkerSize, mew = self.markerEdgeWidth, mec = self.axMarkerEdgeColor, mfc = self.axFaceColor) 239 elif p.probType == 'NLSP': 240 pylab.plot([xx[0], xx[-1]], [log10(p.ftol), log10(p.ftol)], ls = self.axLineStyle, linewidth = self.axLineWidth, color='g',\ 237 241 marker = self.axMarker, ms = self.axMarkerSize, mew = self.markerEdgeWidth, mec = self.axMarkerEdgeColor, mfc = self.axFaceColor) 238 242 if isNewTrajectory: … … 257 261 else: s = self.specifierError 258 262 pylab.plot([xx[-1]], [yy2[-1]], color, marker = s, markersize = self.markerSize) 259 pylab.draw() 263 260 264 #pylab.axis('auto') 261 265 [xmin, xmax, ymin, ymax] = pylab.axis() … … 264 268 pylab.scatter([(xmin+xmax)/2, (xmin+xmax)/2], [ymin-delta, ymax+delta], s=1, c='w', faceted=False, marker='o') 265 269 pylab.draw() 270 if ind == 0 and p.probType == 'NLSP': 271 pylab.plot([xmin, xmax], [log10(p.ftol), log10(p.ftol)],\ 272 linewidth = self.axLineWidth, ls = self.axLineStyle, color='g',\ 273 marker = self.axMarker, ms = self.axMarkerSize, \ 274 mew = self.markerEdgeWidth, mec = self.axMarkerEdgeColor, mfc = self.axFaceColor) 266 275 if ind == 1: 267 276 pylab.plot([xmin, xmax], [log10(p.primalConTol), log10(p.primalConTol)],\ … … 269 278 marker = self.axMarker, ms = self.axMarkerSize, \ 270 279 mew = self.markerEdgeWidth, mec = self.axMarkerEdgeColor, mfc = self.axFaceColor) 271 # pylab.subplot(self.nSubPlots, 1, 1) 272 # pylab.plot([xmax], [yy2[-1]], color='w') 273 elif p.probType == 'NLSP': 274 pylab.axhline(y=log10(p.primalConTol), xmin=xmin, xmax=xmax,\ 275 linewidth = self.axLineWidth, ls = self.axLineStyle, color='g',\ 276 marker = self.axMarker, ms = self.axMarkerSize, \ 277 mew = self.markerEdgeWidth, mec = self.axMarkerEdgeColor, mfc = self.axFaceColor) 280 pylab.subplot(self.nSubPlots, 1, 1) 281 pylab.plot([xmax], [yy2[-1]], color='w') 282 283 284 285 # if p.probType == 'NLSP': 286 # pylab.axhline(y=log10(p.primalConTol), xmin=xmin, xmax=xmax,\ 287 # linewidth = self.axLineWidth, ls = self.axLineStyle, color='g',\ 288 # marker = self.axMarker, ms = self.axMarkerSize, \ 289 # mew = self.markerEdgeWidth, mec = self.axMarkerEdgeColor, mfc = self.axFaceColor) 278 290 279 291 trunk/openopt/scikits/openopt/Kernel/runProbSolver.py
r1064 r1065 204 204 #if not hasattr(p, 'xf'): p.xf = p.xk 205 205 p.xf = p.xf.flatten() 206 if all(isfinite(p.xf)) andp.isFeas(p.xf):206 if p.isFeas(p.xf): 207 207 p.isFeasible = True 208 208 else: p.isFeasible = False trunk/openopt/scikits/openopt/solvers/UkrOpt/lincher_oo.py
r1004 r1065 70 70 #r = p.solve('ALGENCAN') 71 71 72 72 __docformat__ = "restructuredtext en" 73 73 74 74 from numpy import diag, ones, inf, any, copy, sqrt, vstack, concatenate, asarray, nan, where, array, zeros, exp 75 75 from scikits.openopt.Kernel.BaseAlg import * 76 76 from scikits.openopt import LP, QP, NLP, LLSP, NSP 77 __docformat__ = "restructuredtext en" 78 #TODO: handle this situation in runPorbSolver 77 79 78 from scikits.openopt.Kernel.ooMisc import WholeRepr2LinConst 80 79 from scikits.openopt.solvers.optimizers import * 81 80 from scikits.openopt.solvers.optimizers.line_search import * 82 from scipy.optimize import line_search as scipy_optimize_linesearch83 from scipy.optimize.linesearch import line_search as scipy_optimize_linesearch_f81 #from scipy.optimize import line_search as scipy_optimize_linesearch 82 #from scipy.optimize.linesearch import line_search as scipy_optimize_linesearch_f 84 83 from numpy import arange, sign, hstack 85 84 from UkrOptMisc import getDirectionOptimPoint, getConstrDirection … … 90 89 __license__ = "BSD" 91 90 __authors__ = "Dmitrey" 92 __alg__ = "a linearization solver fromCherkassy town, Ukraine"91 __alg__ = "a linearization-based solver written in Cherkassy town, Ukraine" 93 92 __constraintsThatCannotBeHandled__ = [] # empty list means the solver can handle all constraints 94 93 __isIterPointAlwaysFeasible__ = lambda self, p: p.__isNoMoreThanBoxBounded__() trunk/openopt/scikits/openopt/solvers/UkrOpt/nssolve_oo.py
r1004 r1065 13 13 __iterfcnConnected__ = True 14 14 __constraintsThatCannotBeHandled__ = [] 15 __isIterPointAlwaysFeasible__ = lambda self, p: p.isUC 15 16 __info__ = """ 16 17 Solves system of non-smooth or noisy equations … … 42 43 #p2.solver.__decodeIterFcnArgs__(p2, *args, **kwargs) 43 44 p.xk = p2.xk.copy() 44 p.fk = p.f(p.xk) 45 Fk = norm(p.fk, inf) 45 Fk = norm(p.f(p.xk), inf) 46 46 p.rk = p.getMaxResidual(p.xk) 47 47 48 #TODO: HANDLE CONSTRAINTS,ADD p.rk48 #TODO: ADD p.rk 49 49 50 50 if p.nEvals['f'] > p.maxFunEvals: … … 58 58 else: p.istop = p2.istop 59 59 60 # if (p.iprint>0 and (p.iter-1) % p.iprint == 0) or (p2.istop and p.iprint>=0): 61 # if p.isUC: mrstr='' 62 # else: mrstr = 'MaxResidual: %0.2e' % p.getMaxResidual(p.xk) 63 # print 'itn', p.iter-1, ' Fk: %0.2e' % Fk, mrstr 64 65 p.iterfcn()#checkOOstopCreteria = False 60 p.iterfcn() 66 61 67 62
