Changeset 835 for mystic


Ignore:
Timestamp:
10/15/15 18:41:35 (7 months ago)
Author:
mmckerns
Message:

use LinearKernel? in test_svr1 example; enable use of numpy.poly1d as cost;
enable mystic.log_reader to read Monitor instance

Location:
mystic
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • mystic/examples/test_svc1.py

    r830 r835  
    3030y = concatenate([ones(c1.shape[0]), -ones(c2.shape[0])]).reshape(1,nx) 
    3131 
    32 # build the Kernel Matrix (with the linear kernel) 
     32# build the Kernel Matrix 
    3333# get the QP quadratic and linear terms 
    3434XX = concatenate([c1,-c2]) 
  • mystic/examples/test_svc2.py

    r831 r835  
    4242y = concatenate([ones(c1.shape[0]), -ones(c2.shape[0])]).reshape(1,nx) 
    4343 
    44 # build the Kernel Matrix (with the linear kernel) 
     44# build the Kernel Matrix 
    4545# get the QP quadratic and linear terms 
    4646XX = concatenate([c1,-c2]) 
  • mystic/examples/test_svr1.py

    r830 r835  
    2727# get the QP quadratic term 
    2828X = concatenate([x,-x]) 
    29 Q = 1 + multiply.outer(X,X) 
     29Q = KernelMatrix(X, LinearKernel) 
    3030# get the QP linear term 
    3131Y = concatenate([y,-y]) 
  • mystic/mystic/abstract_solver.py

    r801 r835  
    596596        _cost,_raw,_args = self._cost 
    597597        # check if need to 'wrap' or can return the stored cost 
    598         if cost in [None, _raw, _cost] and ExtraArgs in [None, _args]: 
     598        if (cost is None or cost is _raw or cost is _cost) and \ 
     599           (ExtraArgs is None or ExtraArgs is _args): 
    599600            return 
    600601        # get cost and args if None was given 
     
    651652        _cost,_raw,_args = self._cost 
    652653        # check if need to 'wrap' or can return the stored cost 
    653         if cost in [None, _raw, _cost] and ExtraArgs in [None, _args] \ 
    654            and self._live: 
     654        if (cost is None or cost is _raw or cost is _cost) and \ 
     655           (ExtraArgs is None or ExtraArgs is _args) and self._live: 
    655656            return _cost 
    656657        # 'wrap' the 'new' cost function with _decorate 
  • mystic/mystic/scripts.py

    r810 r835  
    674674    __quit = False 
    675675 
     676    instance = None 
    676677    # handle the special case where list is provided by sys.argv 
    677678    if isinstance(filename, (list,tuple)) and not kwds: 
     
    698699        cmdargs += '' if nid is None else '--nid={} '.format(nid) 
    699700        cmdargs += '' if param is None else '--param="{}" '.format(param) 
    700         cmdargs = filename.split() + shlex.split(cmdargs) 
     701        if isinstance(filename, basestring): 
     702            cmdargs = filename.split() + shlex.split(cmdargs) 
     703        else: # special case of passing in monitor instance 
     704            instance = filename 
     705            cmdargs = ['^1203@magic*key311&'] + shlex.split(cmdargs) 
    701706 
    702707    #XXX: note that 'argparse' is new as of python2.7 
     
    757762 
    758763    try: # get logfile name 
    759       filename = parsed_args[0] 
     764      if instance: 
     765        filename = instance 
     766      else: 
     767        filename = parsed_args[0] 
    760768    except: 
    761769      raise IOError("please provide log file name") 
     
    804812    # parse file contents to get (i,id), cost, and parameters 
    805813    try: 
    806         step, param, cost = logfile_reader(filename) 
     814        if instance: 
     815            step = enumerate(instance.id) 
     816            if len(instance) == instance.id.count(None): 
     817                step = [(i,) for (i,j) in step] 
     818            else: 
     819                step = list(step) 
     820            param, cost = instance.x, instance.y 
     821        else: 
     822            step, param, cost = logfile_reader(filename) 
    807823    except SyntaxError: 
    808824        read_raw_file(filename) 
Note: See TracChangeset for help on using the changeset viewer.