scarfs project¶
scarfs module¶
Find approximate fixed points of bounded vector valued functions.
- scarfs.hypercube_fixed_point(func: Callable[[ndarray[tuple[Any, ...], dtype[float64]]], ndarray[tuple[Any, ...], dtype[float64]]], init: ndarray[tuple[Any, ...], dtype[float64]], disc: int) ndarray[tuple[Any, ...], dtype[float64]]¶
Compute an approximate fixed point of a function on the unit hypercube.
This function maps the unit hypercube to the simplex, and in so doing distorts the space. The worst distortion is at the tip of the hypercube [1, 1, …, 1] which has O(d) distortion, so the discretization will be off by O(d) in that case.
Note this homeomorphism is more efficient than using simplotope_fixed_point where each simplex is a 2-simplex.
- Parameters:
func (A continuous function mapping from the d-dimensional unit hypercube) – to itself.
init (An initial guess for the fixed point. Since many may exist, the) – choice of starting point will affect the solution.
disc (The discretization to use. Fixed points will be approximated by the) – reciprocal of this much. Note that due to distortion from the homeomorphism, this won’t accurately reflect the approximation at all areas of the hypercube.
- scarfs.labeled_subsimplex(func: Callable[[ndarray[tuple[Any, ...], dtype[float64]]], ndarray[tuple[Any, ...], dtype[float64]]], init: ndarray[tuple[Any, ...], dtype[float64]], disc: int) ndarray[tuple[Any, ...], dtype[float64]]¶
Find the approximate center of a fully labeled subsimplex.
This runs once at the discretization provided. It is recommended that this be run several times with successively finer discretization and warm started with the past result.
- Parameters:
func (A continuous simplex-to-simplex map whose fixed point is sought. Each) – vertex is labeled by the coordinate that decreases most under func.
init (The starting point on the d-simplex.)
disc (The discretization to use. The returned point lies in a completely) – labeled subsimplex whose vertices are within
1 / discof each other.
- Returns:
ret
- Return type:
A point on the d-simplex approximating a fixed point of
func.
Notes
This is an implementation of the sandwich method from [1] and [2].
- scarfs.simplex_fixed_point(func: Callable[[ndarray[tuple[Any, ...], dtype[float64]]], ndarray[tuple[Any, ...], dtype[float64]]], init: ndarray[tuple[Any, ...], dtype[float64]], disc: int) ndarray[tuple[Any, ...], dtype[float64]]¶
Compute an approximate fixed point of a function on the simplex.
- Parameters:
func (A continuous function mapping from the d-simplex to itself.)
init (An initial guess for the fixed point. Since many may exist, the) – choice of starting point will affect the solution.
disc (The discretization to use. Fixed points will be approximated by the) – reciprocal of this much.
- scarfs.simplotope_fixed_point(func: Callable[[ndarray[tuple[Any, ...], dtype[float64]]], ndarray[tuple[Any, ...], dtype[float64]]], init: ndarray[tuple[Any, ...], dtype[float64]], runs: ndarray[tuple[Any, ...], dtype[int64]], disc: int) ndarray[tuple[Any, ...], dtype[float64]]¶
Compute an approximate fixed point of a function on the simplotope.
Each simplex should be stacked next to each other, and runs specifies the number of elements in each simplex.
- Parameters:
func (A continuous function mapping from the d-simplotope (specified by) – runs) to itself.
init (An initial guess for the fixed point. Since many may exist, the) – choice of starting point will affect the solution.
runs (the length of each simplotope in order.)
disc (The discretization to use. Fixed points will be approximated by the) – reciprocal this much. Since this function computes a homeomorphism to the simplex, the distortion can be up to the number of simplices. Therefore if you want a true approximation discretization of disc, you should specify disc * runs.size.