Changeset 1065

Show
Ignore:
Timestamp:
06/27/08 15:49:00 (2 months ago)
Author:
dmitrey.kroshko
Message:

bugfix for NLPS graphic output + some minor changes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openopt/scikits/openopt/Kernel/Point.py

    r1061 r1065  
    124124            self._dmr, self._dmrName,  self._dmrInd = g, resType, ind 
    125125        if retAll: 
    126             return copy(self._dmr),  self._dmrName,  self._dmrInd 
     126            return copy(self._dmr),  self._dmrName,  copy(self._dmrInd) 
    127127        else: 
    128128            return copy(self._dmr) 
  • trunk/openopt/scikits/openopt/Kernel/Residuals.py

    r977 r1065  
    11__docformat__ = "restructuredtext en" 
    2 from numpy import concatenate, asfarray, array, where, argmax, zeros 
     2from numpy import concatenate, asfarray, array, where, argmax, zeros, isfinite 
    33empty_arr = asfarray([]) 
    44 
     
    7373                if r < val_max: 
    7474                    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' 
    8181        if retAll: 
    8282            return r, fname, ind 
     
    133133 
    134134    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 
    136140 
    137141 
  • trunk/openopt/scikits/openopt/Kernel/ooGraphics.py

    r1047 r1065  
    7979            #TODO: the condition should be handled somewhere other place, not here. 
    8080            if p.probType == 'NLSP': 
    81                 Y_LABELS = ['log10(maxConstr)'] 
    82                 pylab.plot([0], [log10(p.contol)-1.5]) 
     81                Y_LABELS = ['log10(maxResidual)'] 
     82                #pylab.plot([0], [log10(p.contol)-1.5]) 
    8383            elif p.probType == 'LSP': 
    8484                Y_LABELS = ['sum(residuals^2)'] 
    8585            elif p.probType == 'LLSP': 
    86                 p.err('LLSP graphic output not implemented yet') 
     86                p.err('LLSP graphic output is not implemented yet') 
    8787            else: 
    8888                Y_LABELS = ['objFunc(x)'] 
     
    185185 
    186186        if p.probType == 'NLSP': 
    187             yy = log10(yy+p.contol/self.REDUCE) 
     187            yy = log10(yy+p.ftol/self.REDUCE) 
    188188        YY = [yy] 
    189189 
     
    199199                pylab.plot([xx[0]+d_x], [YY[1][0]+1]) 
    200200                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]) 
    207207 
    208208 
     
    233233                    if isfinite(p.ylim[0]): pylab.plot([xx[0]],  [p.ylim[0]],  color='w') 
    234234                    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: 
    236237                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',\ 
    237241                marker = self.axMarker, ms = self.axMarkerSize, mew = self.markerEdgeWidth, mec = self.axMarkerEdgeColor, mfc = self.axFaceColor) 
    238242            if isNewTrajectory: 
     
    257261                    else: s = self.specifierError 
    258262                pylab.plot([xx[-1]], [yy2[-1]], color, marker = s, markersize = self.markerSize) 
    259                 pylab.draw() 
     263 
    260264                #pylab.axis('auto') 
    261265                [xmin, xmax, ymin, ymax] = pylab.axis() 
     
    264268                    pylab.scatter([(xmin+xmax)/2,  (xmin+xmax)/2], [ymin-delta, ymax+delta], s=1, c='w', faceted=False,  marker='o') 
    265269                    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) 
    266275                if  ind == 1: 
    267276                    pylab.plot([xmin, xmax], [log10(p.primalConTol), log10(p.primalConTol)],\ 
     
    269278                        marker = self.axMarker, ms = self.axMarkerSize, \ 
    270279                        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) 
    278290 
    279291 
  • trunk/openopt/scikits/openopt/Kernel/runProbSolver.py

    r1064 r1065  
    204204    #if not hasattr(p, 'xf'): p.xf = p.xk 
    205205    p.xf = p.xf.flatten() 
    206     if all(isfinite(p.xf)) and p.isFeas(p.xf): 
     206    if p.isFeas(p.xf): 
    207207        p.isFeasible = True 
    208208    else: p.isFeasible = False 
  • trunk/openopt/scikits/openopt/solvers/UkrOpt/lincher_oo.py

    r1004 r1065  
    7070    #r = p.solve('ALGENCAN') 
    7171 
    72  
     72__docformat__ = "restructuredtext en" 
    7373 
    7474from numpy import diag, ones, inf, any, copy, sqrt, vstack, concatenate, asarray, nan, where, array, zeros, exp 
    7575from scikits.openopt.Kernel.BaseAlg import * 
    7676from scikits.openopt import LP, QP, NLP, LLSP, NSP 
    77 __docformat__ = "restructuredtext en" 
    78 #TODO: handle this situation in runPorbSolver 
     77 
    7978from scikits.openopt.Kernel.ooMisc import WholeRepr2LinConst 
    8079from scikits.openopt.solvers.optimizers import * 
    8180from scikits.openopt.solvers.optimizers.line_search import * 
    82 from scipy.optimize import line_search as scipy_optimize_linesearch 
    83 from scipy.optimize.linesearch import line_search as scipy_optimize_linesearch_f 
     81#from scipy.optimize import line_search as scipy_optimize_linesearch 
     82#from scipy.optimize.linesearch import line_search as scipy_optimize_linesearch_f 
    8483from numpy import arange, sign, hstack 
    8584from UkrOptMisc import getDirectionOptimPoint, getConstrDirection 
     
    9089    __license__ = "BSD" 
    9190    __authors__ = "Dmitrey" 
    92     __alg__ = "a linearization solver from Cherkassy town, Ukraine" 
     91    __alg__ = "a linearization-based solver written in Cherkassy town, Ukraine" 
    9392    __constraintsThatCannotBeHandled__ = [] # empty list means the solver can handle all constraints 
    9493    __isIterPointAlwaysFeasible__ = lambda self, p: p.__isNoMoreThanBoxBounded__() 
  • trunk/openopt/scikits/openopt/solvers/UkrOpt/nssolve_oo.py

    r1004 r1065  
    1313    __iterfcnConnected__ = True 
    1414    __constraintsThatCannotBeHandled__ = [] 
     15    __isIterPointAlwaysFeasible__ = lambda self, p: p.isUC 
    1516    __info__ = """ 
    1617    Solves system of non-smooth or noisy equations 
     
    4243            #p2.solver.__decodeIterFcnArgs__(p2,  *args,  **kwargs) 
    4344            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) 
    4646            p.rk = p.getMaxResidual(p.xk) 
    4747 
    48             #TODO: HANDLE CONSTRAINTS, ADD p.rk 
     48            #TODO: ADD p.rk 
    4949 
    5050            if p.nEvals['f'] > p.maxFunEvals: 
     
    5858                else: p.istop = p2.istop 
    5959 
    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() 
    6661 
    6762