29. Global methods
gm.paradigm solves a stationary nonlinear model globally, from the model
alone. It belongs to current RISE and is selected through the same
solve_paradigm option as the other paradigms. The output is a fixed
policy, with a separate policy for each discrete regime. The policy must pass
an independent accuracy certificate before solve reports success or public
simulation can use it.
The iteration couples the regimes through successor-regime expectations. Both exogenous and endogenous transition probabilities are supported. With endogenous probabilities, each candidate uses the model’s true probability row at its current state and controls; probabilities are not frozen at the steady state. Discrete regime labels are never interpolation coordinates.
The policy is a multilinear tensor interpolation, except in the sparse fallback described below. The number of grid points is the product of the axis sizes, so inspect the point count before increasing the state dimension.
29.1. Selecting the paradigm
The factory takes the model alone, optionally with a grid and a reference policy:
m=set(m,'solve_paradigm',@gm.paradigm);
m=set(m,'solve_paradigm',{@gm.paradigm,'grid',G});
m=set(m,'solve_paradigm',{@gm.paradigm,'grid',G,'reference',@reference});
Everything else is inferred from the model: the state is the lagged endogenous values and the current structural innovations, the node unknowns are the full current endogenous vector, and the residual is the model’s own compiled equations. Nothing numerical belongs in the model file.
Gis a three-column cell array: a model variable name, its physical range[low high]and a number of points. Every lagged model variable needs a row; innovations get a default range. The policy is a tensor grid over these axes when it fits the caps: at most 3072 nodes and the byte budget. Grid rows are honored by a tensor or refused withGM_RESOURCE_LIMIT. Only when no row is given, which a state without lagged variables allows, and the default tensor exceeds a cap, does the paradigm build a local sparse plan instead.reference(points,regime)returns the full current policy at each point. It only starts the iteration. Without it, the solved model rules start it when they are available, and otherwise the static terminal policy does.
The former descriptor interface is refused with
gm:paradigm:ObsoleteArgument: setup, representation,
algorithm and options are no longer arguments.
A switching autoregression, \(X_t=\mu(s_t)+\rho X_{t-1}+\sigma E_t\), with \(\rho=0.8\), \(\sigma=0.01\) and \(\mu=(0,0.01)\):
m=dsge_model('switch_ar1.rs');
m=set(m,'solve_paradigm',{@gm.paradigm,'grid',{'X',[-0.25,0.3],17}});
[m,code]=solve(m);
assert(code==0,utils.error.decipher(code));
payload=m.model_data.state_space{1}.solution; % payload.certified is true
[y,code]=gm.evaluate_policy(payload.policy,[0.1;0.5],2); % 0.01+0.8*0.1+0.01*0.5
[db,regimes,code]=simulate(m,'simul_periods',200);
assert(code==0,utils.error.decipher(code));
The axes are named by payload.coordinates.axis_names, here X{-1} and
E{0}. The unit test TestGMPublicRoute runs this example and checks the
policy against the analytic one at 10,000 off-grid states in both regimes,
and the simulated path against the same recursion, to 1e-10.
Choose ranges that contain the successors of every point under the integration
rules: a box the successors leave is refused by the certificate
(GM_OUTSIDE_DOMAIN), for example {'X',[-0.1,0.15],9} above.
As with other paradigms, an empty solve_paradigm selects the ordinary
solver again. See Extending RISE through paradigms for the common
envelope and engine interface. The ordinary solver supplies the steady-state
baseline; its local dynamic-solution verdict does not certify or reject a
global policy by itself.
29.2. Accuracy and domain
An undamped policy gap and node residual test precede a new-policy residual and admissibility check. Only then does the certificate run, on the final candidate of the solve. In every regime it evaluates at least 10,000 off-grid stratified states, plus face centres and corners, and checks every original equation under a higher Gauss-Hermite rule, the difference between that rule and the construction rule, feasibility, complementarity, both sides of every binding surface, and that every positive-probability successor stays inside the box. It is a check of one solve: it does not compare the policy with solves on refined grids or enlarged domains.
Successful policies retain their declared axes, initializer, numerical options and problem signature. Neither a root count nor convergence of time iteration establishes equilibrium existence, uniqueness or determinacy. The certificate concerns the stated model, domain and accuracy experiment. See Solution accuracy for the separate general accuracy interface.
Extension='error' refuses evaluations outside the state grid.
Extension='linear' permits linear extension and reports domain escapes;
that setting must be explicit in the accuracy experiment. A singleton axis
is fixed and can never be extrapolated. gm.evaluate_policy returns
domain diagnostics as its third output. A failed evaluation is unusable.
29.3. Options
The public paradigm uses the defaults of gm.options, which validates
the numerical controls of the low-level gm.time_iteration and rejects
unknown names. The iteration controls are:
Option |
Default |
Meaning |
|---|---|---|
|
5000 |
Maximum coupled outer iterations. |
|
1e-11 |
Maximum absolute undamped control change. |
|
1e-10 |
Original residual threshold in declared residual scales. |
|
1 |
Update fraction in the interval (0,1]. |
|
|
Policy evaluation outside the grid: |
|
256 MiB |
Preflight budget for numerical arrays owned by the iteration. |
|
8192 |
Maximum grid-node columns per node-solver call. |
|
3600 |
Iteration and certificate wall-time budget. |
|
1e10 |
Budget for evaluated node points. |
|
See below |
Controls for safeguarded node solves. |
|
|
Print iteration progress. |
NodeOptions accepts MaxIter (60), TolFun (1e-12), TolStep
(1e-14), FDStep (1e-6), MaxBacktrack (24), RootTolerance
(1e-9 in scaled controls), MaxEvaluations (1e7) and MaxBytes
(256 MiB). A small step alone is not convergence. Finite differences act on
the entire residual, including endogenous probabilities and successor states.
Memory budgets cover documented numerical arrays, not interpreter overhead
or allocations made by user callbacks.
29.4. Return codes
Numerical failures return a nonzero code and no solved policy. Decode a
code with utils.error.decipher(code). The tensor-specific codes are:
Code |
Name |
Meaning |
|---|---|---|
40 |
|
Unsupported stationary model, physical coordinates or configuration. |
41 |
|
No admissible node candidate passes the original residual. |
42 |
|
Distinct admissible node candidates; none is selected. |
43 |
|
A one-step policy query leaves the permitted state domain. |
44 |
|
Original-residual or independent certificate failure. |
45 |
|
Declared memory, time or evaluation budget reached. |
46 |
|
An unsupported history, conditioning or announced-shock plan. |
47 |
|
Outer iteration limit reached before certification. |
48 |
|
A problem callback fails or returns an invalid numerical result. |
49 |
|
An unsupported simulation mode or consumer. |
Other model-evaluation and transition-law codes can propagate unchanged.
The failed solve envelope retains diagnostics at
m.model_data.state_space{1}.solution.diagnostics and .failure. A failed one-step evaluation
returns a code and NaN output; public simulation stops through its existing
SIMUL_INVALID code 704 rather than advancing on that output. Invalid
option names are input-validation errors, distinct from numerical failure.
29.5. Supported consumer and limits
The first consumer is unconditional simulation from the model steady state,
with surprise innovations and stochastic or numeric regime paths. Its
interface uses simul_order=1: one complete nonlinear policy component,
not a first-order Taylor approximation. The fixed certified policy is used
at each date; simulation does not re-solve it. The true compiled transition
matrix is evaluated at the current physical endogenous vector for the move
out of that date.
Pruning, moving-window/custom simulators, supplied histories or conditioning plans, announced shocks, measurement errors, and additional constraint or switch-rule consumers are refused by the current contract. The compiled adapter also refuses logged model coordinates, nonstationary growth, optimal-policy models and multiple simultaneous parameterizations. These limits are explicit; the implementation does not silently substitute a local or fixed-probability policy for the requested model.