SG++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
python.uq.operations.sparse_grid Namespace Reference

Functions

def add
 
def addConst
 
def balance
 
def checkInterpolation
 
def checkPositivity
 
def copyGrid
 
def createGrid
 
def dehierarchize
 
def dehierarchizeList
 
def dehierarchizeOnNewGrid
 
def estimateConvergence
 
def estimateSurplus
 def estimateSurplus(grid, gp, v): gs = grid.getStorage() ix = gs.seq(gp) More...
 
def evalHierToTop
 
def evalSGFunction
 
def evalSGFunctionMulti
 
def getBasis
 
def getBoundsOfSupport
 
def getDegree
 
def getHierarchicalAncestors
 
def getIndex
 
def getLevel
 
def getLevelIndex
 
def getNonExistingHierarchicalAncestors
 
def hasAllChildren
 
def hasBorder
 
def hasChildren
 
def hierarchize
 
def hierarchizeBruteForce
 
def insertHierarchicalAncestors
 
def insertPoint
 
def insertTruncatedBorder
 
def isHierarchicalAncestor
 
def isRefineable
 
def isValid
 
def isValid1d
 
def parent
 
def parents
 
def sub
 

Function Documentation

def python.uq.operations.sparse_grid.add (   alpha,
  alphas 
)
def python.uq.operations.sparse_grid.addConst (   grid,
  alpha,
  c 
)
def python.uq.operations.sparse_grid.balance (   grid)
def python.uq.operations.sparse_grid.checkInterpolation (   grid,
  alpha,
  nodalValues,
  epsilon = 1e-13 
)
def python.uq.operations.sparse_grid.createGrid (   grid,
  dim,
  deg = 1,
  addTruncatedBorder = False 
)
def python.uq.operations.sparse_grid.dehierarchizeList (   grid,
  alpha,
  gps 
)
evaluate sparse grid function at grid points in gps
@param grid: Grid
@param alpha: DataVector
@param gps: list of HashGridPoint

References sgpp::op_factory.createOperationMultipleEval().

def python.uq.operations.sparse_grid.dehierarchizeOnNewGrid (   gridResult,
  grid,
  alpha 
)
def python.uq.operations.sparse_grid.estimateSurplus (   grid,
  gp,
  v 
)

def estimateSurplus(grid, gp, v): gs = grid.getStorage() ix = gs.seq(gp)

surplus is already known

if ix < len(v): print "warning: not estimated", return v[ix]

vgp = []

get all available parents

myParents = [(d, pgp) for (d, pgp) in parents(grid, gp) if gs.has_key(pgp)] vparents = np.ndarray(len(myParents), dtype='float32') for i, (dp, p) in enumerate(myParents): ipar = gs.seq(p) vparents[i] = v[ipar]

get all grand parents = parents of parents

for dgrp, grp in parents(grid, p):

use a linear extrapolation through parent and grandparent

to estimate the surplus of the current collocation node

igrandpar = gs.seq(grp) xpar = p.getStandardCoordinate(dgrp) xgrandpar = grp.getStandardCoordinate(dgrp) xgp = p.getStandardCoordinate(dgrp) + 2 ** -gp.getLevel(dp)

slope between parent and grand parent

a = (v[ipar] - v[igrandpar]) / (xpar - xgrandpar)

half the slope for the child

a /= 2.

same behavior -> keep direction

if (v[ipar] > 0 and v[igrandpar] > 0) or \ (v[ipar] < 0 and v[igrandpar] < 0): sign = 1.

alternating behavior -> change direction

else: sign = -1.

a *= sign

add constant part

b = v[ipar] - a * xpar

force extrapolation with half the difference between

father and grand father for the child

xgp = xpar + (xpar - xgrandpar) / 2.

do the linear extrapolation

y = a * xgp + b

import matplotlib.pyplot as plt

plt.plot([xpar, xgp], [a * xi + b for xi in [xpar, xgp]])

plt.plot([xgrandpar, xpar], [sign * 2 * a * xi + v[ipar]

- sign * 2 * a * xpar

for xi in [xgrandpar, xpar]])

plt.plot(xpar, v[ipar], marker='p', label='parent')

plt.plot(xgrandpar, v[igrandpar], marker='o', label='grand father')

plt.plot(xgp, y, marker='x', label='self')

plt.legend(loc='best')

plt.show()

        vgp.append(y)

if len(vgp) == 0:
    vgp = vparents

return np.max(vgp) 
Linear extrapolation of the surplus
@param grid: Grid
@param gp: HashGridPoint
@param v: DataVector, surplus vector
@return: float, estimated surplus for gp

References python.uq.operations.sparse_grid.parents().

Referenced by python.uq.refinement.RefinementStrategy.SquaredSurplusBFRanking.rank(), python.uq.refinement.RefinementStrategy.ExpectationValueBFRanking.rank(), python.uq.refinement.RefinementStrategy.LinearSurplusEstimationRanking.rank(), and python.uq.refinement.RefinementStrategy.VarianceBFRanking.update().

def python.uq.operations.sparse_grid.evalHierToTop (   basis,
  grid,
  coeffs,
  gp,
  d 
)
def python.uq.operations.sparse_grid.getLevelIndex (   gp)
def python.uq.operations.sparse_grid.getNonExistingHierarchicalAncestors (   grid,
  gp 
)
def python.uq.operations.sparse_grid.hasChildren (   grid,
  gp 
)
def python.uq.operations.sparse_grid.insertTruncatedBorder (   grid,
  gp 
)
def python.uq.operations.sparse_grid.isHierarchicalAncestor (   grid,
  gpi,
  gpj 
)
def python.uq.operations.sparse_grid.isValid1d (   grid,
  level,
  index 
)
def python.uq.operations.sparse_grid.parent (   grid,
  gp,
  d 
)
def python.uq.operations.sparse_grid.sub (   alpha,
  alphas 
)