def exploremonitor(params=None): if hasattr(exploremonitor, "prevparams"): # Convert params to numerical value params = sym2num(params) # Compute number of new dimensions explored newdims = sum([np.count_nonzero(param > ubparam) + np.count_nonzero(param < lbparam) for param, ubparam, lbparam in zip(params, exploremonitor.ub, exploremonitor.lb)]) # Update lower and upper bounds exploremonitor.lb = [np.minimum(prevparam, param) for prevparam, param in zip(exploremonitor.prevparams, params)] exploremonitor.ub = [np.maximum(prevparam, param) for prevparam, param in zip(exploremonitor.prevparams, params)] # Update previous params exploremonitor.prevparams = params # Compute the total number of parameters numparams = sum([np.size(param) for param in params]) # Compute the volume of the quadratic hull hullvol = np.prod(np.array([np.prod(np.abs(ubparam - lbparam)) for ubparam, lbparam in zip(exploremonitor.ub, exploremonitor.lb)])) # Return return "| Explored Dimensions: {} of {} || Hull Volume: {} |".format(int(newdims), int(numparams), float(hullvol)) else: # Log params exploremonitor.prevparams = sym2num(params) # Log lower and upper bounds exploremonitor.lb = exploremonitor.prevparams exploremonitor.ub = exploremonitor.prevparams # Return return "| Explored Dimensions: N/A |"
def exploremonitor(params=None): if hasattr(exploremonitor, "prevparams"): # Convert params to numerical value params = nu.sym2num(params) # Compute number of new dimensions explored newdims = sum([np.count_nonzero(param > ubparam) + np.count_nonzero(param < lbparam) for param, ubparam, lbparam in zip(params, exploremonitor.ub, exploremonitor.lb)]) # Update lower and upper bounds exploremonitor.lb = [np.minimum(prevparam, param) for prevparam, param in zip(exploremonitor.prevparams, params)] exploremonitor.ub = [np.maximum(prevparam, param) for prevparam, param in zip(exploremonitor.prevparams, params)] # Update previous params exploremonitor.prevparams = params # Compute the total number of parameters numparams = sum([np.size(param) for param in params]) # Compute the volume of the quadratic hull hullvol = np.prod(np.array([np.prod(np.abs(ubparam - lbparam)) for ubparam, lbparam in zip(exploremonitor.ub, exploremonitor.lb)])) # Return return "| Explored Dimensions: {} of {} || Hull Volume: {} |".format(int(newdims), int(numparams), float(hullvol)) else: # Log params exploremonitor.prevparams = nu.sym2num(params) # Log lower and upper bounds exploremonitor.lb = exploremonitor.prevparams exploremonitor.ub = exploremonitor.prevparams # Return return "| Explored Dimensions: N/A |"
def updatenormmonitor(params): if hasattr(updatenormmonitor, "prevparams"): # Convert to num params = sym2num(params) # Compute update norm updnorm = sum([np.sum((currparam - prevparam) ** 2) for currparam, prevparam in zip(params, updatenormmonitor.prevparams)]) # Log updatenormmonitor.prevparams = params return "| Update Norm: {0:.7f} |".format(float(updnorm)) else: updatenormmonitor.prevparams = sym2num(params) return "| Update Norm: N/A |" pass
def updatenormmonitor(params): if hasattr(updatenormmonitor, "prevparams"): # Convert to num params = nu.sym2num(params) # Compute update norm updnorm = sum([np.sum((currparam - prevparam) ** 2) for currparam, prevparam in zip(params, updatenormmonitor.prevparams)]) # Log updatenormmonitor.prevparams = params return "| Update Norm: {0:.7f} |".format(float(updnorm)) else: updatenormmonitor.prevparams = nu.sym2num(params) return "| Update Norm: N/A |" pass