Algorithms and numerical examples for the TTRISK paper by Harbir Antil, Sergey Dolgov and Akwum Onwunta. These methods approximate the Conditional Value at Risk (CVaR) by using Tensor Train approximations and adaptively smoothed indicator functions to compute expectations over random variables in CVaR.
These codes require MATLAB (any version above 2016 should be fine) and TT-Toolbox.
Numerical experiment scripts (starting with test_) will try to download the TT-Toolbox and add it to the path automatically using a check_tt function. However, if this procedure fails, you need to download and setup the TT-Toolbox and certain quadrature rules yourself before running these codes.
Each script will ask interactively to enter certain parameters (grid size, stopping tolerance, etc.). Default values are advised to reproduce the experiments in the paper and/or reduce the running time.
test_1d_elliptic.mOne-dimensional elliptic PDE example. Fast enough for playing around.test_2d_elliptic_reduced.m2D elliptic PDE in the reduced-space formulation. Slow.test_2d_elliptic_lagrangian.m2D elliptic PDE in the Lagrangian (full-space) formulation. Slow.test_SEIR_det.mDeterministic optimization of the SEIR ODE model. Fast.test_SEIR.mCVaR optimization of the SEIR model. Slow.
ttrisk.mTTRISK algorithm in the reduced space formulation. Should be used as a first attempt. The model content is defined in the model structure (see examples above how it can be set up) and the forward solution procedures are defined by a g_grad_fun parameter. Examples of those are provided ing_grad_fun_1d.mandg_grad_fun_2d.mfor the elliptic PDEs.ttrisk_lagrangian_uzawa.mTTRISK algorithm in the Lagrangian formulation. More difficult and restrictive to model specifications.amen_cross_s.mStable rank-adaptive AMEn TT-Cross version for building TT approximations. Forked from TT-IRT.
g_grad_fun_1d.mForward solution function for 1D Elliptic PDE example in the reduced-space formulation
Elliptic_Example_5_setup.mA function to set up the discretization and model for 2D Elliptic PDE.g_grad_fun_2d.mForward solution function for 2D Elliptic PDE example in the reduced-space formulation.Anonzeros.mComputes a vector of nonzeros of the stiffness matrix on given TT-Cross samples.Assemble_A.mAssembles the stiffness finite element matrix.Assemble_F.mAssembles the finite element right hand side vector.Dirichlet_BC.mApplies the boundary conditionsSolve_FEM.mSolves the forward problem.Ex5model.mat2D Elliptic PDE model structure (can be regenerated byElliptic_Example_5_setup.m)mesh_coarse.mshTriangular mesh for the 2D domains.plot_nodalfield.mAux function to plot the finite element solution.
SEIRcost.mA function to compute the cost function of SEIR model on given samplesSEIRFDGrad.mFinite Difference approximation of the gradient of the SEIR cost.SEIRIEuler.mImplicit Euler method to solve the forward SEIR ODE problem.SEIRData/Historic England data for SEIR model.
check_quadratures.mwill check and if necessary download quadrature rules from external repositories. Those are:lgwt.mLegendre-Gauss Quadrature Weights and Nodes.hermite.mHermite polynomials from SGLib.gauss_hermite_rule.mGauss-Hermite quadrature rule from SGLib.
If the automatic download fails, you need to download these quadrature rules yourself before using the other codes.
logsmooth.mLog-sigmoid smoothing function, applied to data elementwise.grad_logsmooth.mFirst derivative of Log-sigmoid.hess_logsmooth.mSecond derivative of Log-sigmoid.
cvar_localsolve.mPreconditioned solver for reduced KKT systems in the Lagrangian formulation@lrmatrixA class of low-rank matrices for fast Matrix-Vector products with those.lagrange_interpolant.mA function to interpolate a Lagrangian polynomial.parse_parameter.mA function to read parameters from the keyboard.check_tt.mCheck/download/add-to-path for TT-Toolbox.
Additional information is available in the comments in the beginning of each file.