casadi 3.6.5__cp310-none-macosx_11_0_arm64.whl → 3.6.7__cp310-none-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- casadi/_casadi.so +0 -0
- casadi/casadi-cli +0 -0
- casadi/casadi.py +739 -308
- casadi/cbc +0 -0
- casadi/clp +0 -0
- casadi/cmake/casadi-config-version.cmake +1 -1
- casadi/cmake/casadi-targets.cmake +10 -6
- casadi/cmake/highs/highs-config.cmake +6 -13
- casadi/cmake/highs/highs-targets-release.cmake +13 -13
- casadi/cmake/highs/highs-targets.cmake +25 -22
- casadi/cmake/osqp/osqp-targets.cmake +10 -6
- casadi/cmake/proxsuite/proxsuiteConfigVersion.cmake +0 -5
- casadi/cmake/proxsuite/proxsuiteTargets.cmake +12 -12
- casadi/cmake/qdldl/qdldl-targets.cmake +10 -6
- casadi/cmake/sleqp/sleqp-config-version.cmake +0 -5
- casadi/cmake/sleqp/sleqp-targets.cmake +10 -6
- casadi/cmake/trlib/trlib-config-release.cmake +1 -1
- casadi/cmake/trlib/trlib-config-version.cmake +0 -5
- casadi/cmake/trlib/trlib-config.cmake +12 -12
- casadi/highs +0 -0
- casadi/include/casadi/casadi.i +3 -0
- casadi/include/casadi/casadi_c.h +2 -0
- casadi/include/casadi/config.h +9 -9
- casadi/include/casadi/core/casadi_common.hpp +1 -0
- casadi/include/casadi/core/casadi_export.h +1 -0
- casadi/include/casadi/core/casadi_misc.hpp +52 -0
- casadi/include/casadi/core/casadi_types.hpp +3 -2
- casadi/include/casadi/core/code_generator.hpp +30 -1
- casadi/include/casadi/core/global_options.hpp +2 -0
- casadi/include/casadi/core/mx.hpp +18 -3
- casadi/include/casadi/core/optistack.hpp +23 -0
- casadi/include/casadi/core/runtime/casadi_nlp.hpp +19 -4
- casadi/include/casadi/core/runtime/casadi_ocp_block.hpp +55 -0
- casadi/include/casadi/core/runtime/casadi_oracle.hpp +44 -0
- casadi/include/casadi/core/runtime/casadi_oracle_callback.hpp +39 -0
- casadi/include/casadi/core/runtime/casadi_runtime.hpp +4 -1
- casadi/include/casadi/core/runtime/casadi_scaled_copy.hpp +31 -0
- casadi/include/casadi/core/serializing_stream.hpp +2 -2
- casadi/include/casadi/core/sparsity.hpp +7 -0
- casadi/include/casadi/doc.i +1513 -1016
- casadi/include/casadi/doc_merged.i +965 -719
- casadi/include/casadi/mem.h +1 -0
- casadi/include/daqp/api.h +46 -0
- casadi/include/daqp/auxiliary.h +29 -0
- casadi/include/daqp/bnb.h +32 -0
- casadi/include/daqp/codegen.h +18 -0
- casadi/include/daqp/constants.h +92 -0
- casadi/include/daqp/daqp.h +22 -0
- casadi/include/daqp/daqp_prox.h +18 -0
- casadi/include/daqp/factorization.h +18 -0
- casadi/include/daqp/types.h +161 -0
- casadi/include/daqp/utils.h +44 -0
- casadi/include/fatrop/auxiliary/Common.hpp +34 -0
- casadi/include/fatrop/auxiliary/DynamicLib.hpp +34 -0
- casadi/include/fatrop/auxiliary/FatropOptions.hpp +68 -0
- casadi/include/fatrop/auxiliary/FatropVector.hpp +143 -0
- casadi/include/fatrop/auxiliary/LinearAlgebra.hpp +88 -0
- casadi/include/fatrop/auxiliary/VectorUtils.hpp +54 -0
- casadi/include/fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp +493 -0
- casadi/include/fatrop/fatrop.hpp +39 -0
- casadi/include/fatrop/function_evaluation/CasadiCodegen.hpp +104 -0
- casadi/include/fatrop/function_evaluation/FunctionEvaluation.hpp +60 -0
- casadi/include/fatrop/json/json.h +946 -0
- casadi/include/fatrop/ocp/CasadiCApiUserdataWrap.hpp +87 -0
- casadi/include/fatrop/ocp/DuInfEvaluator.hpp +38 -0
- casadi/include/fatrop/ocp/FatropOCP.hpp +161 -0
- casadi/include/fatrop/ocp/FatropOCPBuilder.hpp +52 -0
- casadi/include/fatrop/ocp/FatropOCPResto.hpp +299 -0
- casadi/include/fatrop/ocp/OCP.hpp +82 -0
- casadi/include/fatrop/ocp/OCPAbstract.hpp +254 -0
- casadi/include/fatrop/ocp/OCPAdapter.hpp +197 -0
- casadi/include/fatrop/ocp/OCPCInterface.h +289 -0
- casadi/include/fatrop/ocp/OCPDims.hpp +60 -0
- casadi/include/fatrop/ocp/OCPInitializer.hpp +41 -0
- casadi/include/fatrop/ocp/OCPKKT.hpp +69 -0
- casadi/include/fatrop/ocp/OCPLSRiccati.hpp +198 -0
- casadi/include/fatrop/ocp/OCPLSScaler.hpp +66 -0
- casadi/include/fatrop/ocp/OCPLinearSolver.hpp +75 -0
- casadi/include/fatrop/ocp/OCPNoScaling.hpp +42 -0
- casadi/include/fatrop/ocp/OCPScalingMethod.hpp +42 -0
- casadi/include/fatrop/ocp/StageOCP.hpp +592 -0
- casadi/include/fatrop/ocp/StageOCPApplication.hpp +242 -0
- casadi/include/fatrop/ocp/StageOCPExpressions.hpp +182 -0
- casadi/include/fatrop/ocp/UStageEvalAbstract.hpp +168 -0
- casadi/include/fatrop/ocp/UStageOCPImpl.hpp +152 -0
- casadi/include/fatrop/quasi_newton/bfgs.hpp +159 -0
- casadi/include/fatrop/solver/AlgBuilder.hpp +76 -0
- casadi/include/fatrop/solver/AlgStrategy.hpp +33 -0
- casadi/include/fatrop/solver/FatropAlg.hpp +121 -0
- casadi/include/fatrop/solver/FatropData.hpp +188 -0
- casadi/include/fatrop/solver/FatropOptions.hpp +95 -0
- casadi/include/fatrop/solver/FatropPrinter.hpp +65 -0
- casadi/include/fatrop/solver/FatropStats.hpp +63 -0
- casadi/include/fatrop/solver/Filter.hpp +54 -0
- casadi/include/fatrop/solver/IterationData.hpp +56 -0
- casadi/include/fatrop/solver/LineSearch.hpp +86 -0
- casadi/include/fatrop/solver/NLPL1.hpp +263 -0
- casadi/include/fatrop/templates/NLPAlg.hpp +104 -0
- casadi/include/highs/HConfig.h +8 -7
- casadi/include/highs/Highs.h +93 -23
- casadi/include/highs/filereaderlp/def.hpp +19 -0
- casadi/include/highs/interfaces/highs_c_api.h +200 -24
- casadi/include/highs/io/Filereader.h +1 -1
- casadi/include/highs/io/FilereaderEms.h +1 -1
- casadi/include/highs/io/FilereaderLp.h +1 -1
- casadi/include/highs/io/FilereaderMps.h +1 -1
- casadi/include/highs/io/HMPSIO.h +1 -1
- casadi/include/highs/io/HMpsFF.h +5 -3
- casadi/include/highs/io/HighsIO.h +18 -8
- casadi/include/highs/io/LoadOptions.h +1 -1
- casadi/include/highs/ipm/IpxSolution.h +35 -0
- casadi/include/highs/ipm/IpxWrapper.h +1 -1
- casadi/include/highs/ipm/basiclu/basiclu.h +161 -0
- casadi/include/highs/ipm/basiclu/basiclu_factorize.h +247 -0
- casadi/include/highs/ipm/basiclu/basiclu_get_factors.h +108 -0
- casadi/include/highs/ipm/basiclu/basiclu_initialize.h +119 -0
- casadi/include/highs/ipm/basiclu/basiclu_obj_factorize.h +34 -0
- casadi/include/highs/ipm/basiclu/basiclu_obj_free.h +19 -0
- casadi/include/highs/ipm/basiclu/basiclu_obj_get_factors.h +34 -0
- casadi/include/highs/ipm/basiclu/basiclu_obj_initialize.h +46 -0
- casadi/include/highs/ipm/basiclu/basiclu_obj_solve_dense.h +29 -0
- casadi/include/highs/ipm/basiclu/basiclu_obj_solve_for_update.h +42 -0
- casadi/include/highs/ipm/basiclu/basiclu_obj_solve_sparse.h +32 -0
- casadi/include/highs/ipm/basiclu/basiclu_obj_update.h +31 -0
- casadi/include/highs/ipm/basiclu/basiclu_object.h +30 -0
- casadi/include/highs/ipm/basiclu/basiclu_solve_dense.h +75 -0
- casadi/include/highs/ipm/basiclu/basiclu_solve_for_update.h +169 -0
- casadi/include/highs/ipm/basiclu/basiclu_solve_sparse.h +112 -0
- casadi/include/highs/ipm/basiclu/basiclu_update.h +125 -0
- casadi/include/highs/ipm/basiclu/lu_def.h +39 -0
- casadi/include/highs/ipm/basiclu/lu_file.h +21 -0
- casadi/include/highs/ipm/basiclu/lu_internal.h +220 -0
- casadi/include/highs/ipm/basiclu/lu_list.h +168 -0
- casadi/include/highs/ipm/ipx/basiclu_kernel.h +20 -0
- casadi/include/highs/ipm/ipx/basiclu_wrapper.h +47 -0
- casadi/include/highs/ipm/ipx/basis.h +351 -0
- casadi/include/highs/ipm/ipx/conjugate_residuals.h +74 -0
- casadi/include/highs/ipm/ipx/control.h +163 -0
- casadi/include/highs/ipm/ipx/crossover.h +157 -0
- casadi/include/highs/ipm/ipx/diagonal_precond.h +45 -0
- casadi/include/highs/ipm/ipx/forrest_tomlin.h +102 -0
- casadi/include/highs/ipm/ipx/guess_basis.h +21 -0
- casadi/include/highs/ipm/ipx/indexed_vector.h +113 -0
- casadi/include/highs/ipm/ipx/info.h +27 -0
- casadi/include/highs/ipm/ipx/ipm.h +94 -0
- casadi/include/highs/ipm/ipx/ipx_c.h +47 -0
- casadi/include/highs/ipm/ipx/ipx_config.h +9 -0
- casadi/include/highs/ipm/ipx/ipx_info.h +111 -0
- casadi/include/highs/ipm/ipx/ipx_internal.h +88 -0
- casadi/include/highs/ipm/ipx/ipx_parameters.h +75 -0
- casadi/include/highs/ipm/ipx/ipx_status.h +57 -0
- casadi/include/highs/ipm/ipx/iterate.h +328 -0
- casadi/include/highs/ipm/ipx/kkt_solver.h +70 -0
- casadi/include/highs/ipm/ipx/kkt_solver_basis.h +66 -0
- casadi/include/highs/ipm/ipx/kkt_solver_diag.h +48 -0
- casadi/include/highs/ipm/ipx/linear_operator.h +26 -0
- casadi/include/highs/ipm/ipx/lp_solver.h +201 -0
- casadi/include/highs/ipm/ipx/lu_factorization.h +79 -0
- casadi/include/highs/ipm/ipx/lu_update.h +129 -0
- casadi/include/highs/ipm/ipx/maxvolume.h +54 -0
- casadi/include/highs/ipm/ipx/model.h +409 -0
- casadi/include/highs/ipm/ipx/multistream.h +52 -0
- casadi/include/highs/ipm/ipx/normal_matrix.h +44 -0
- casadi/include/highs/ipm/ipx/power_method.h +44 -0
- casadi/include/highs/ipm/ipx/sparse_matrix.h +195 -0
- casadi/include/highs/ipm/ipx/sparse_utils.h +58 -0
- casadi/include/highs/ipm/ipx/splitted_normal_matrix.h +63 -0
- casadi/include/highs/ipm/ipx/starting_basis.h +39 -0
- casadi/include/highs/ipm/ipx/symbolic_invert.h +29 -0
- casadi/include/highs/ipm/ipx/timer.h +24 -0
- casadi/include/highs/ipm/ipx/utils.h +39 -0
- casadi/include/highs/lp_data/HConst.h +20 -10
- casadi/include/highs/lp_data/HStruct.h +23 -1
- casadi/include/highs/lp_data/HighsAnalysis.h +1 -1
- casadi/include/highs/lp_data/HighsCallback.h +10 -3
- casadi/include/highs/lp_data/HighsCallbackStruct.h +31 -5
- casadi/include/highs/lp_data/HighsDebug.h +1 -1
- casadi/include/highs/lp_data/HighsInfo.h +20 -2
- casadi/include/highs/lp_data/HighsInfoDebug.h +1 -1
- casadi/include/highs/lp_data/HighsLp.h +17 -1
- casadi/include/highs/lp_data/HighsLpSolverObject.h +1 -1
- casadi/include/highs/lp_data/HighsLpUtils.h +19 -19
- casadi/include/highs/lp_data/HighsModelUtils.h +1 -1
- casadi/include/highs/lp_data/HighsOptions.h +237 -10
- casadi/include/highs/lp_data/HighsRanging.h +1 -1
- casadi/include/highs/lp_data/HighsRuntimeOptions.h +2 -2
- casadi/include/highs/lp_data/HighsSolution.h +2 -2
- casadi/include/highs/lp_data/HighsSolutionDebug.h +1 -1
- casadi/include/highs/lp_data/HighsSolve.h +3 -1
- casadi/include/highs/lp_data/HighsStatus.h +1 -1
- casadi/include/highs/mip/HighsCliqueTable.h +4 -4
- casadi/include/highs/mip/HighsConflictPool.h +1 -1
- casadi/include/highs/mip/HighsCutGeneration.h +1 -1
- casadi/include/highs/mip/HighsCutPool.h +2 -2
- casadi/include/highs/mip/HighsDebugSol.h +22 -29
- casadi/include/highs/mip/HighsDomain.h +10 -2
- casadi/include/highs/mip/HighsDomainChange.h +1 -1
- casadi/include/highs/mip/HighsDynamicRowMatrix.h +5 -3
- casadi/include/highs/mip/HighsGFkSolve.h +3 -3
- casadi/include/highs/mip/HighsImplications.h +3 -3
- casadi/include/highs/mip/HighsLpAggregator.h +1 -1
- casadi/include/highs/mip/HighsLpRelaxation.h +6 -1
- casadi/include/highs/mip/HighsMipSolver.h +4 -2
- casadi/include/highs/mip/HighsMipSolverData.h +47 -4
- casadi/include/highs/mip/HighsModkSeparator.h +2 -2
- casadi/include/highs/mip/HighsNodeQueue.h +5 -3
- casadi/include/highs/mip/HighsObjectiveFunction.h +1 -1
- casadi/include/highs/mip/HighsPathSeparator.h +2 -2
- casadi/include/highs/mip/HighsPrimalHeuristics.h +1 -1
- casadi/include/highs/mip/HighsPseudocost.h +35 -23
- casadi/include/highs/mip/HighsRedcostFixing.h +1 -1
- casadi/include/highs/mip/HighsSearch.h +2 -1
- casadi/include/highs/mip/HighsSeparation.h +1 -1
- casadi/include/highs/mip/HighsSeparator.h +1 -1
- casadi/include/highs/mip/HighsTableauSeparator.h +1 -1
- casadi/include/highs/mip/HighsTransformedLp.h +1 -1
- casadi/include/highs/model/HighsHessian.h +5 -0
- casadi/include/highs/model/HighsHessianUtils.h +2 -0
- casadi/include/highs/model/HighsModel.h +10 -1
- casadi/include/highs/parallel/HighsMutex.h +2 -1
- casadi/include/highs/parallel/HighsParallel.h +7 -2
- casadi/include/highs/parallel/HighsTask.h +1 -2
- casadi/include/highs/pdlp/CupdlpWrapper.h +93 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_cs.h +41 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_defs.h +423 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_linalg.h +183 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_proj.h +19 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_restart.h +31 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_scaling_cuda.h +28 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_solver.h +98 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_step.h +33 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_utils.c +1726 -0
- casadi/include/highs/pdqsort/pdqsort.h +532 -0
- casadi/include/highs/presolve/HPresolve.h +27 -14
- casadi/include/highs/presolve/HPresolveAnalysis.h +1 -1
- casadi/include/highs/presolve/HighsPostsolveStack.h +92 -68
- casadi/include/highs/presolve/HighsSymmetry.h +6 -5
- casadi/include/highs/presolve/ICrash.h +8 -2
- casadi/include/highs/presolve/ICrashUtil.h +1 -1
- casadi/include/highs/presolve/ICrashX.h +1 -1
- casadi/include/highs/presolve/PresolveComponent.h +1 -1
- casadi/include/highs/qpsolver/a_asm.hpp +23 -12
- casadi/include/highs/qpsolver/a_quass.hpp +8 -1
- casadi/include/highs/qpsolver/basis.hpp +150 -0
- casadi/include/highs/qpsolver/crashsolution.hpp +12 -0
- casadi/include/highs/qpsolver/dantzigpricing.hpp +72 -0
- casadi/include/highs/qpsolver/devexpricing.hpp +99 -0
- casadi/include/highs/qpsolver/eventhandler.hpp +23 -0
- casadi/include/highs/qpsolver/factor.hpp +400 -0
- casadi/include/highs/qpsolver/feasibility_bounded.hpp +105 -0
- casadi/include/highs/qpsolver/feasibility_highs.hpp +270 -0
- casadi/include/highs/qpsolver/gradient.hpp +39 -0
- casadi/include/highs/qpsolver/instance.hpp +63 -0
- casadi/include/highs/qpsolver/matrix.hpp +335 -0
- casadi/include/highs/qpsolver/pricing.hpp +15 -0
- casadi/include/highs/qpsolver/qpconst.hpp +27 -0
- casadi/include/highs/qpsolver/{vector.hpp → qpvector.hpp} +25 -25
- casadi/include/highs/qpsolver/quass.hpp +1 -1
- casadi/include/highs/qpsolver/ratiotest.hpp +19 -0
- casadi/include/highs/qpsolver/runtime.hpp +38 -0
- casadi/include/highs/qpsolver/settings.hpp +57 -0
- casadi/include/highs/qpsolver/snippets.hpp +29 -0
- casadi/include/highs/qpsolver/statistics.hpp +23 -0
- casadi/include/highs/qpsolver/steepestedgepricing.hpp +167 -0
- casadi/include/highs/simplex/HApp.h +1 -1
- casadi/include/highs/simplex/HEkk.h +52 -18
- casadi/include/highs/simplex/HEkkDual.h +1 -1
- casadi/include/highs/simplex/HEkkDualRHS.h +6 -7
- casadi/include/highs/simplex/HEkkDualRow.h +2 -2
- casadi/include/highs/simplex/HEkkPrimal.h +6 -1
- casadi/include/highs/simplex/HSimplex.h +1 -3
- casadi/include/highs/simplex/HSimplexDebug.h +1 -1
- casadi/include/highs/simplex/HSimplexNla.h +1 -1
- casadi/include/highs/simplex/HSimplexReport.h +1 -1
- casadi/include/highs/simplex/HighsSimplexAnalysis.h +228 -100
- casadi/include/highs/simplex/SimplexConst.h +1 -1
- casadi/include/highs/simplex/SimplexStruct.h +2 -2
- casadi/include/highs/simplex/SimplexTimer.h +1 -1
- casadi/include/highs/test/DevKkt.h +1 -1
- casadi/include/highs/test/KktCh2.h +1 -1
- casadi/include/highs/util/FactorTimer.h +1 -1
- casadi/include/highs/util/HFactor.h +35 -6
- casadi/include/highs/util/HFactorConst.h +1 -1
- casadi/include/highs/util/HFactorDebug.h +1 -1
- casadi/include/highs/util/HSet.h +1 -1
- casadi/include/highs/util/HVector.h +1 -1
- casadi/include/highs/util/HVectorBase.h +1 -1
- casadi/include/highs/util/HighsCDouble.h +3 -3
- casadi/include/highs/util/HighsComponent.h +1 -1
- casadi/include/highs/util/HighsDataStack.h +4 -4
- casadi/include/highs/util/HighsDisjointSets.h +1 -1
- casadi/include/highs/util/HighsHash.h +28 -21
- casadi/include/highs/util/HighsHashTree.h +63 -63
- casadi/include/highs/util/HighsInt.h +1 -1
- casadi/include/highs/util/HighsIntegers.h +8 -9
- casadi/include/highs/util/HighsLinearSumBounds.h +1 -1
- casadi/include/highs/util/HighsMatrixPic.h +1 -1
- casadi/include/highs/util/HighsMatrixSlice.h +9 -6
- casadi/include/highs/util/HighsMatrixUtils.h +1 -1
- casadi/include/highs/util/HighsMemoryAllocation.h +55 -0
- casadi/include/highs/util/HighsRandom.h +27 -15
- casadi/include/highs/util/HighsRbTree.h +2 -2
- casadi/include/highs/util/HighsSort.h +7 -7
- casadi/include/highs/util/HighsSparseMatrix.h +5 -2
- casadi/include/highs/util/HighsSparseVectorSum.h +2 -2
- casadi/include/highs/util/HighsSplay.h +1 -1
- casadi/include/highs/util/HighsTimer.h +18 -9
- casadi/include/highs/util/HighsUtils.h +15 -8
- casadi/include/highs/util/stringutil.h +9 -4
- casadi/include/highs/zstr/strict_fstream.hpp +237 -0
- casadi/include/highs/zstr/zstr.hpp +472 -0
- casadi/include/highs_export.h +43 -0
- casadi/include/licenses/daqp-external/LICENSE +21 -0
- casadi/include/licenses/{alpaqa-external/LICENSE → fatrop-external/LICENSE.txt} +2 -2
- casadi/include/licenses/fatrop-external/external/blasfeo/LICENSE.txt +26 -0
- casadi/include/licenses/fatrop-external/external/pybind11/LICENSE +29 -0
- casadi/include/licenses/fatrop-external/misc/license_header.txt +17 -0
- casadi/include/licenses/highs-external/{LICENSE → LICENSE.txt} +1 -1
- casadi/include/osqp/constants.h +2 -3
- casadi/include/osqp/version.h +9 -0
- casadi/include/sleqp/defs.h +4 -4
- casadi/include/sleqp/export.h +1 -0
- casadi/lib/cmake/tinyxml2/tinyxml2-config-version.cmake +0 -5
- casadi/lib/cmake/tinyxml2/tinyxml2-static-targets.cmake +10 -6
- casadi/lib/libtinyxml2.a +0 -0
- casadi/lib/pkgconfig/tinyxml2.pc +1 -1
- casadi/libCbc.3.10.11.dylib +0 -0
- casadi/libCbc.3.dylib +0 -0
- casadi/libCbc.dylib +0 -0
- casadi/libCbc.la +2 -2
- casadi/libCbcSolver.3.10.11.dylib +0 -0
- casadi/libCbcSolver.3.dylib +0 -0
- casadi/libCbcSolver.dylib +0 -0
- casadi/libCbcSolver.la +2 -2
- casadi/libCgl.1.10.8.dylib +0 -0
- casadi/libCgl.1.dylib +0 -0
- casadi/libCgl.dylib +0 -0
- casadi/libCgl.la +2 -2
- casadi/libClp.1.14.9.dylib +0 -0
- casadi/libClp.1.dylib +0 -0
- casadi/libClp.dylib +0 -0
- casadi/libClp.la +2 -2
- casadi/libClpSolver.1.14.9.dylib +0 -0
- casadi/libClpSolver.1.dylib +0 -0
- casadi/libClpSolver.dylib +0 -0
- casadi/libClpSolver.la +2 -2
- casadi/libCoinUtils.3.11.10.dylib +0 -0
- casadi/libCoinUtils.3.dylib +0 -0
- casadi/libCoinUtils.dylib +0 -0
- casadi/libCoinUtils.la +1 -1
- casadi/libOsi.1.13.9.dylib +0 -0
- casadi/libOsi.1.dylib +0 -0
- casadi/libOsi.dylib +0 -0
- casadi/libOsi.la +2 -2
- casadi/libOsiCbc.3.10.11.dylib +0 -0
- casadi/libOsiCbc.3.dylib +0 -0
- casadi/libOsiCbc.dylib +0 -0
- casadi/libOsiCbc.la +2 -2
- casadi/libOsiClp.1.14.9.dylib +0 -0
- casadi/libOsiClp.1.dylib +0 -0
- casadi/libOsiClp.dylib +0 -0
- casadi/libOsiClp.la +2 -2
- casadi/libOsiCommonTests.1.13.9.dylib +0 -0
- casadi/libOsiCommonTests.1.dylib +0 -0
- casadi/libOsiCommonTests.dylib +0 -0
- casadi/libOsiCommonTests.la +2 -2
- casadi/libblasfeo.dylib +0 -0
- casadi/libbonmin.4.8.9.dylib +0 -0
- casadi/libbonmin.4.dylib +0 -0
- casadi/libbonmin.dylib +0 -0
- casadi/libbonmin.la +2 -2
- casadi/libc++.1.0.dylib +0 -0
- casadi/libcasadi.3.7.dylib +0 -0
- casadi/libcasadi.dylib +0 -0
- casadi/libcasadi_conic_cbc.3.7.dylib +0 -0
- casadi/libcasadi_conic_cbc.dylib +0 -0
- casadi/libcasadi_conic_clp.3.7.dylib +0 -0
- casadi/libcasadi_conic_clp.dylib +0 -0
- casadi/libcasadi_conic_cplex.3.7.dylib +0 -0
- casadi/libcasadi_conic_cplex.dylib +0 -0
- casadi/libcasadi_conic_daqp.3.7.dylib +0 -0
- casadi/libcasadi_conic_daqp.dylib +0 -0
- casadi/libcasadi_conic_fatrop.3.7.dylib +0 -0
- casadi/libcasadi_conic_fatrop.dylib +0 -0
- casadi/libcasadi_conic_gurobi.3.7.dylib +0 -0
- casadi/libcasadi_conic_gurobi.dylib +0 -0
- casadi/libcasadi_conic_highs.3.7.dylib +0 -0
- casadi/libcasadi_conic_highs.dylib +0 -0
- casadi/libcasadi_conic_ipqp.3.7.dylib +0 -0
- casadi/libcasadi_conic_ipqp.dylib +0 -0
- casadi/libcasadi_conic_nlpsol.3.7.dylib +0 -0
- casadi/libcasadi_conic_nlpsol.dylib +0 -0
- casadi/libcasadi_conic_osqp.3.7.dylib +0 -0
- casadi/libcasadi_conic_osqp.dylib +0 -0
- casadi/libcasadi_conic_proxqp.3.7.dylib +0 -0
- casadi/libcasadi_conic_proxqp.dylib +0 -0
- casadi/libcasadi_conic_qpoases.3.7.dylib +0 -0
- casadi/libcasadi_conic_qpoases.dylib +0 -0
- casadi/libcasadi_conic_qrqp.3.7.dylib +0 -0
- casadi/libcasadi_conic_qrqp.dylib +0 -0
- casadi/libcasadi_conic_superscs.3.7.dylib +0 -0
- casadi/libcasadi_conic_superscs.dylib +0 -0
- casadi/libcasadi_importer_shell.3.7.dylib +0 -0
- casadi/libcasadi_importer_shell.dylib +0 -0
- casadi/libcasadi_integrator_collocation.3.7.dylib +0 -0
- casadi/libcasadi_integrator_collocation.dylib +0 -0
- casadi/libcasadi_integrator_cvodes.3.7.dylib +0 -0
- casadi/libcasadi_integrator_cvodes.dylib +0 -0
- casadi/libcasadi_integrator_idas.3.7.dylib +0 -0
- casadi/libcasadi_integrator_idas.dylib +0 -0
- casadi/libcasadi_integrator_rk.3.7.dylib +0 -0
- casadi/libcasadi_integrator_rk.dylib +0 -0
- casadi/libcasadi_interpolant_bspline.3.7.dylib +0 -0
- casadi/libcasadi_interpolant_bspline.dylib +0 -0
- casadi/libcasadi_interpolant_linear.3.7.dylib +0 -0
- casadi/libcasadi_interpolant_linear.dylib +0 -0
- casadi/libcasadi_linsol_csparse.3.7.dylib +0 -0
- casadi/libcasadi_linsol_csparse.dylib +0 -0
- casadi/libcasadi_linsol_csparsecholesky.3.7.dylib +0 -0
- casadi/libcasadi_linsol_csparsecholesky.dylib +0 -0
- casadi/libcasadi_linsol_lapacklu.3.7.dylib +0 -0
- casadi/libcasadi_linsol_lapacklu.dylib +0 -0
- casadi/libcasadi_linsol_lapackqr.3.7.dylib +0 -0
- casadi/libcasadi_linsol_lapackqr.dylib +0 -0
- casadi/libcasadi_linsol_ldl.3.7.dylib +0 -0
- casadi/libcasadi_linsol_ldl.dylib +0 -0
- casadi/libcasadi_linsol_lsqr.3.7.dylib +0 -0
- casadi/libcasadi_linsol_lsqr.dylib +0 -0
- casadi/libcasadi_linsol_ma27.3.7.dylib +0 -0
- casadi/libcasadi_linsol_ma27.dylib +0 -0
- casadi/libcasadi_linsol_mumps.3.7.dylib +0 -0
- casadi/libcasadi_linsol_mumps.dylib +0 -0
- casadi/libcasadi_linsol_qr.3.7.dylib +0 -0
- casadi/libcasadi_linsol_qr.dylib +0 -0
- casadi/libcasadi_linsol_symbolicqr.3.7.dylib +0 -0
- casadi/libcasadi_linsol_symbolicqr.dylib +0 -0
- casadi/libcasadi_linsol_tridiag.3.7.dylib +0 -0
- casadi/libcasadi_linsol_tridiag.dylib +0 -0
- casadi/libcasadi_nlpsol_ampl.3.7.dylib +0 -0
- casadi/libcasadi_nlpsol_ampl.dylib +0 -0
- casadi/libcasadi_nlpsol_blocksqp.3.7.dylib +0 -0
- casadi/libcasadi_nlpsol_blocksqp.dylib +0 -0
- casadi/libcasadi_nlpsol_bonmin.3.7.dylib +0 -0
- casadi/libcasadi_nlpsol_bonmin.dylib +0 -0
- casadi/libcasadi_nlpsol_fatrop.3.7.dylib +0 -0
- casadi/libcasadi_nlpsol_fatrop.dylib +0 -0
- casadi/libcasadi_nlpsol_feasiblesqpmethod.3.7.dylib +0 -0
- casadi/libcasadi_nlpsol_feasiblesqpmethod.dylib +0 -0
- casadi/libcasadi_nlpsol_ipopt.3.7.dylib +0 -0
- casadi/libcasadi_nlpsol_ipopt.dylib +0 -0
- casadi/libcasadi_nlpsol_knitro.3.7.dylib +0 -0
- casadi/libcasadi_nlpsol_knitro.dylib +0 -0
- casadi/libcasadi_nlpsol_madnlp.3.7.dylib +0 -0
- casadi/libcasadi_nlpsol_madnlp.dylib +0 -0
- casadi/libcasadi_nlpsol_qrsqp.3.7.dylib +0 -0
- casadi/libcasadi_nlpsol_qrsqp.dylib +0 -0
- casadi/libcasadi_nlpsol_scpgen.3.7.dylib +0 -0
- casadi/libcasadi_nlpsol_scpgen.dylib +0 -0
- casadi/libcasadi_nlpsol_sleqp.3.7.dylib +0 -0
- casadi/libcasadi_nlpsol_sleqp.dylib +0 -0
- casadi/libcasadi_nlpsol_snopt.3.7.dylib +0 -0
- casadi/libcasadi_nlpsol_snopt.dylib +0 -0
- casadi/libcasadi_nlpsol_sqpmethod.3.7.dylib +0 -0
- casadi/libcasadi_nlpsol_sqpmethod.dylib +0 -0
- casadi/libcasadi_rootfinder_fast_newton.3.7.dylib +0 -0
- casadi/libcasadi_rootfinder_fast_newton.dylib +0 -0
- casadi/libcasadi_rootfinder_kinsol.3.7.dylib +0 -0
- casadi/libcasadi_rootfinder_kinsol.dylib +0 -0
- casadi/libcasadi_rootfinder_newton.3.7.dylib +0 -0
- casadi/libcasadi_rootfinder_newton.dylib +0 -0
- casadi/libcasadi_rootfinder_nlpsol.3.7.dylib +0 -0
- casadi/libcasadi_rootfinder_nlpsol.dylib +0 -0
- casadi/libcasadi_sundials_common.3.7.dylib +0 -0
- casadi/libcasadi_sundials_common.dylib +0 -0
- casadi/libcasadi_xmlfile_tinyxml.3.7.dylib +0 -0
- casadi/libcasadi_xmlfile_tinyxml.dylib +0 -0
- casadi/libcoinmetis.2.dylib +0 -0
- casadi/libcoinmetis.dylib +0 -0
- casadi/libcoinmetis.la +1 -1
- casadi/libcoinmumps.3.dylib +0 -0
- casadi/libcoinmumps.dylib +0 -0
- casadi/libcoinmumps.la +2 -2
- casadi/libcplex_adaptor.dylib +0 -0
- casadi/{libamd.3.0.3.dylib → libdaqp.dylib} +0 -0
- casadi/libdaqpstat.a +0 -0
- casadi/libfatrop.dylib +0 -0
- casadi/libgcc_s.1.1.dylib +0 -0
- casadi/libgfortran.5.dylib +0 -0
- casadi/libgurobi_adaptor.dylib +0 -0
- casadi/libhighs.1.7.dylib +0 -0
- casadi/libhighs.1.dylib +0 -0
- casadi/libhighs.dylib +0 -0
- casadi/libindirect.a +0 -0
- casadi/libipopt.3.dylib +0 -0
- casadi/libipopt.dylib +0 -0
- casadi/libipopt.la +2 -2
- casadi/liblinsys.a +0 -0
- casadi/{libsuitesparseconfig.7.0.1.dylib → libmatlab_ipc.dylib} +0 -0
- casadi/libosqp.a +0 -0
- casadi/libosqp.dylib +0 -0
- casadi/libqdldl.a +0 -0
- casadi/libqdldl.dylib +0 -0
- casadi/libquadmath.0.dylib +0 -0
- casadi/libsipopt.3.dylib +0 -0
- casadi/libsipopt.dylib +0 -0
- casadi/libsipopt.la +2 -2
- casadi/libsleqp.1.0.1.dylib +0 -0
- casadi/libsleqp.dylib +0 -0
- casadi/libsuperscs.a +0 -0
- casadi/libtrlib.0.4.dylib +0 -0
- casadi/libtrlib.dylib +0 -0
- casadi/libz.1.2.13.dylib +0 -0
- casadi/pkgconfig/bonmin.pc +1 -1
- casadi/pkgconfig/casadi.pc +5 -5
- casadi/pkgconfig/cbc.pc +1 -1
- casadi/pkgconfig/cgl.pc +1 -1
- casadi/pkgconfig/clp.pc +1 -1
- casadi/pkgconfig/coinmetis.pc +1 -1
- casadi/pkgconfig/coinmumps.pc +2 -2
- casadi/pkgconfig/coinutils.pc +2 -2
- casadi/pkgconfig/highs.pc +4 -4
- casadi/pkgconfig/ipopt.pc +2 -2
- casadi/pkgconfig/osi-cbc.pc +1 -1
- casadi/pkgconfig/osi-clp.pc +1 -1
- casadi/pkgconfig/osi-unittests.pc +1 -1
- casadi/pkgconfig/osi.pc +1 -1
- casadi/pkgconfig/sleqp.pc +1 -1
- casadi/tools/__init__.py +4 -0
- casadi/tools/bounds.py +3 -3
- {casadi-3.6.5.dist-info → casadi-3.6.7.dist-info}/METADATA +2 -2
- {casadi-3.6.5.dist-info → casadi-3.6.7.dist-info}/RECORD +532 -477
- casadi/cmake/alpaqa/alpaqaConfig.cmake +0 -24
- casadi/cmake/alpaqa/alpaqaConfigVersion.cmake +0 -70
- casadi/cmake/alpaqa/alpaqaTargets-release.cmake +0 -19
- casadi/cmake/alpaqa/alpaqaTargets.cmake +0 -116
- casadi/include/alpaqa/accelerators/anderson.hpp +0 -133
- casadi/include/alpaqa/accelerators/internal/anderson-helpers.hpp +0 -92
- casadi/include/alpaqa/accelerators/internal/limited-memory-qr.hpp +0 -295
- casadi/include/alpaqa/accelerators/lbfgs.hpp +0 -244
- casadi/include/alpaqa/accelerators/steihaugcg.hpp +0 -143
- casadi/include/alpaqa/alpaqa.hpp +0 -3
- casadi/include/alpaqa/casadi/CasADiControlProblem.hpp +0 -185
- casadi/include/alpaqa/casadi/CasADiFunctionWrapper.hpp +0 -104
- casadi/include/alpaqa/casadi/CasADiProblem.hpp +0 -102
- casadi/include/alpaqa/casadi-loader-export.hpp +0 -15
- casadi/include/alpaqa/casadi-ocp-loader-export.hpp +0 -15
- casadi/include/alpaqa/config/config.hpp +0 -165
- casadi/include/alpaqa/dl/dl-problem.h +0 -476
- casadi/include/alpaqa/dl/dl-problem.hpp +0 -301
- casadi/include/alpaqa/export.h +0 -42
- casadi/include/alpaqa/export.hpp +0 -30
- casadi/include/alpaqa/implementation/accelerators/lbfgs.tpp +0 -240
- casadi/include/alpaqa/implementation/casadi/CasADiControlProblem.tpp +0 -594
- casadi/include/alpaqa/implementation/casadi/CasADiLoader-util.hpp +0 -50
- casadi/include/alpaqa/implementation/casadi/CasADiProblem.tpp +0 -425
- casadi/include/alpaqa/implementation/inner/directions/panoc/structured-lbfgs.tpp +0 -164
- casadi/include/alpaqa/implementation/inner/panoc-helpers.tpp +0 -389
- casadi/include/alpaqa/implementation/inner/panoc-ocp.tpp +0 -798
- casadi/include/alpaqa/implementation/inner/panoc.tpp +0 -448
- casadi/include/alpaqa/implementation/inner/pantr.tpp +0 -474
- casadi/include/alpaqa/implementation/inner/zerofpr.tpp +0 -482
- casadi/include/alpaqa/implementation/outer/alm.tpp +0 -228
- casadi/include/alpaqa/implementation/outer/internal/alm-helpers.tpp +0 -80
- casadi/include/alpaqa/implementation/params/params.tpp +0 -158
- casadi/include/alpaqa/implementation/problem/ocproblem.tpp +0 -56
- casadi/include/alpaqa/implementation/problem/type-erased-problem.tpp +0 -211
- casadi/include/alpaqa/implementation/util/io/csv.tpp +0 -120
- casadi/include/alpaqa/implementation/util/print.tpp +0 -151
- casadi/include/alpaqa/inner/directions/panoc/anderson.hpp +0 -98
- casadi/include/alpaqa/inner/directions/panoc/lbfgs.hpp +0 -94
- casadi/include/alpaqa/inner/directions/panoc/structured-lbfgs.hpp +0 -146
- casadi/include/alpaqa/inner/directions/panoc/structured-newton.hpp +0 -264
- casadi/include/alpaqa/inner/directions/panoc-direction-update.hpp +0 -96
- casadi/include/alpaqa/inner/directions/panoc-ocp/lqr.hpp +0 -181
- casadi/include/alpaqa/inner/directions/panoc-ocp/ocp-vars.hpp +0 -492
- casadi/include/alpaqa/inner/directions/pantr/newton-tr.hpp +0 -192
- casadi/include/alpaqa/inner/directions/pantr/pantr-direction.hpp +0 -99
- casadi/include/alpaqa/inner/inner-solve-options.hpp +0 -30
- casadi/include/alpaqa/inner/internal/lipschitz.hpp +0 -27
- casadi/include/alpaqa/inner/internal/panoc-helpers.hpp +0 -10
- casadi/include/alpaqa/inner/internal/panoc-stop-crit.hpp +0 -124
- casadi/include/alpaqa/inner/internal/solverstatus.hpp +0 -42
- casadi/include/alpaqa/inner/panoc-ocp.hpp +0 -302
- casadi/include/alpaqa/inner/panoc.hpp +0 -274
- casadi/include/alpaqa/inner/pantr.hpp +0 -284
- casadi/include/alpaqa/inner/zerofpr.hpp +0 -274
- casadi/include/alpaqa/ipopt/ipopt-adapter.hpp +0 -81
- casadi/include/alpaqa/ipopt/ipopt-enums.hpp +0 -35
- casadi/include/alpaqa/lbfgsb/lbfgsb-adapter.hpp +0 -111
- casadi/include/alpaqa/newton-tr-pantr-alm.hpp +0 -27
- casadi/include/alpaqa/outer/alm.hpp +0 -190
- casadi/include/alpaqa/outer/internal/alm-helpers.hpp +0 -10
- casadi/include/alpaqa/panoc-alm.hpp +0 -27
- casadi/include/alpaqa/panoc-anderson-alm.hpp +0 -27
- casadi/include/alpaqa/params/params.hpp +0 -60
- casadi/include/alpaqa/problem/box-constr-problem.hpp +0 -220
- casadi/include/alpaqa/problem/box.hpp +0 -82
- casadi/include/alpaqa/problem/functional-problem.hpp +0 -73
- casadi/include/alpaqa/problem/kkt-error.hpp +0 -43
- casadi/include/alpaqa/problem/ocproblem-counters.hpp +0 -116
- casadi/include/alpaqa/problem/ocproblem.hpp +0 -662
- casadi/include/alpaqa/problem/problem-counters.hpp +0 -116
- casadi/include/alpaqa/problem/problem-with-counters.hpp +0 -141
- casadi/include/alpaqa/problem/type-erased-problem.hpp +0 -874
- casadi/include/alpaqa/problem/unconstr-problem.hpp +0 -37
- casadi/include/alpaqa/structured-panoc-alm.hpp +0 -27
- casadi/include/alpaqa/structured-zerofpr-alm.hpp +0 -27
- casadi/include/alpaqa/util/alloc-check.hpp +0 -23
- casadi/include/alpaqa/util/atomic-stop-signal.hpp +0 -24
- casadi/include/alpaqa/util/check-dim.hpp +0 -64
- casadi/include/alpaqa/util/copyable_unique_ptr.hpp +0 -32
- casadi/include/alpaqa/util/demangled-typename.hpp +0 -9
- casadi/include/alpaqa/util/enumerate.hpp +0 -70
- casadi/include/alpaqa/util/float.hpp +0 -25
- casadi/include/alpaqa/util/index-set.hpp +0 -97
- casadi/include/alpaqa/util/io/csv.hpp +0 -43
- casadi/include/alpaqa/util/iter-adapter.hpp +0 -68
- casadi/include/alpaqa/util/max-history.hpp +0 -47
- casadi/include/alpaqa/util/noop-delete.hpp +0 -15
- casadi/include/alpaqa/util/not-implemented.hpp +0 -12
- casadi/include/alpaqa/util/print.hpp +0 -78
- casadi/include/alpaqa/util/quadmath/quadmath-print.hpp +0 -20
- casadi/include/alpaqa/util/quadmath/quadmath.hpp +0 -137
- casadi/include/alpaqa/util/required-method.hpp +0 -29
- casadi/include/alpaqa/util/ringbuffer.hpp +0 -212
- casadi/include/alpaqa/util/set-intersection.hpp +0 -129
- casadi/include/alpaqa/util/sparse-ops.hpp +0 -164
- casadi/include/alpaqa/util/timed.hpp +0 -22
- casadi/include/alpaqa/util/type-erasure.hpp +0 -568
- casadi/include/alpaqa/util/type-traits.hpp +0 -58
- casadi/include/alpaqa/zerofpr-alm.hpp +0 -27
- casadi/include/alpaqa/zerofpr-anderson-alm.hpp +0 -27
- casadi/include/alpaqa-version.h +0 -8
- casadi/include/highs/fortran/highs_fortran_api.mod +0 -0
- casadi/include/licenses/alpaqa-external/src/thirdparty/lbfgsb/Lbfgsb.3.0/License.txt +0 -71
- casadi/libFortranHighs.dylib +0 -0
- casadi/libalpaqa.1.0.0.dylib +0 -0
- casadi/libalpaqa.dylib +0 -0
- casadi/libcamd.3.0.3.dylib +0 -0
- casadi/libcasadi_nlpsol_alpaqa.3.7.dylib +0 -0
- casadi/libcasadi_nlpsol_alpaqa.dylib +0 -0
- casadi/libccolamd.3.0.3.dylib +0 -0
- casadi/libcholmod.4.0.3.dylib +0 -0
- casadi/libcholmod_cuda.4.0.3.dylib +0 -0
- casadi/libcolamd.3.0.3.dylib +0 -0
- casadi/libhighs.1.6.0.dylib +0 -0
- casadi/libhighs.1.6.dylib +0 -0
- casadi/libumfpack.6.1.0.dylib +0 -0
- {casadi-3.6.5.dist-info → casadi-3.6.7.dist-info}/WHEEL +0 -0
@@ -1,295 +0,0 @@
|
|
1
|
-
#include <alpaqa/config/config.hpp>
|
2
|
-
#include <alpaqa/util/ringbuffer.hpp>
|
3
|
-
#include <Eigen/Jacobi>
|
4
|
-
#include <type_traits>
|
5
|
-
|
6
|
-
namespace alpaqa {
|
7
|
-
|
8
|
-
/// Incremental QR factorization using modified Gram-Schmidt with
|
9
|
-
/// reorthogonalization.
|
10
|
-
///
|
11
|
-
/// Computes A = QR while allowing efficient removal of the first
|
12
|
-
/// column of A or adding new columns at the end of A.
|
13
|
-
template <Config Conf = DefaultConfig>
|
14
|
-
class LimitedMemoryQR {
|
15
|
-
public:
|
16
|
-
USING_ALPAQA_CONFIG(Conf);
|
17
|
-
LimitedMemoryQR() = default;
|
18
|
-
|
19
|
-
/// @param n
|
20
|
-
/// The size of the vectors, the number of rows of A.
|
21
|
-
/// @param m
|
22
|
-
/// The maximum number of columns of A.
|
23
|
-
///
|
24
|
-
/// The maximum dimensions of Q are n×m and the maximum dimensions of R are
|
25
|
-
/// m×m.
|
26
|
-
LimitedMemoryQR(length_t n, length_t m) : Q(n, m), R(m, m) {}
|
27
|
-
|
28
|
-
length_t n() const { return Q.rows(); }
|
29
|
-
length_t m() const { return Q.cols(); }
|
30
|
-
length_t size() const { return n(); }
|
31
|
-
length_t history() const { return m(); }
|
32
|
-
|
33
|
-
/// Add the given column to the right.
|
34
|
-
template <class VecV>
|
35
|
-
void add_column(const VecV &v) {
|
36
|
-
assert(num_columns() < m());
|
37
|
-
|
38
|
-
auto q = Q.col(q_idx);
|
39
|
-
auto r = R.col(r_idx_end);
|
40
|
-
|
41
|
-
// Modified Gram-Schmidt to make q orthogonal to Q
|
42
|
-
q = v;
|
43
|
-
for (index_t i = 0; i < q_idx; ++i) {
|
44
|
-
real_t s = Q.col(i).dot(q);
|
45
|
-
r(i) = s;
|
46
|
-
q -= s * Q.col(i);
|
47
|
-
}
|
48
|
-
|
49
|
-
// Compute the norms of orthogonalized q and original v
|
50
|
-
real_t norm_q = q.norm();
|
51
|
-
real_t norm_v = v.norm();
|
52
|
-
|
53
|
-
// If ‖q‖ is significantly smaller than ‖v‖, perform
|
54
|
-
// reorthogonalization
|
55
|
-
auto η = real_t(0.7);
|
56
|
-
while (norm_q < η * norm_v) {
|
57
|
-
++reorth_count;
|
58
|
-
for (index_t i = 0; i < q_idx; ++i) {
|
59
|
-
real_t s = Q.col(i).dot(q);
|
60
|
-
r(i) += s;
|
61
|
-
q -= s * Q.col(i);
|
62
|
-
}
|
63
|
-
norm_v = norm_q;
|
64
|
-
norm_q = q.norm();
|
65
|
-
}
|
66
|
-
|
67
|
-
// Normalize q such that new matrix (Q q) remains orthogonal (i.e. has
|
68
|
-
// orthonormal columns)
|
69
|
-
r(q_idx) = norm_q;
|
70
|
-
q /= norm_q;
|
71
|
-
// Keep track of the minimum/maximum diagonal element of R
|
72
|
-
min_eig = std::min(min_eig, norm_q);
|
73
|
-
max_eig = std::max(max_eig, norm_q);
|
74
|
-
|
75
|
-
// Increment indices, add a column to Q and R.
|
76
|
-
++q_idx;
|
77
|
-
r_idx_end = r_succ(r_idx_end);
|
78
|
-
}
|
79
|
-
|
80
|
-
/// Remove the leftmost column.
|
81
|
-
void remove_column() {
|
82
|
-
assert(num_columns() > 0);
|
83
|
-
|
84
|
-
// After removing the first column of the upper triangular matrix R,
|
85
|
-
// it becomes upper Hessenberg. Givens rotations are used to make it
|
86
|
-
// triangular again.
|
87
|
-
Eigen::JacobiRotation<real_t> G;
|
88
|
-
index_t r = 0; // row index of R
|
89
|
-
index_t c = r_succ(r_idx_start); // column index of R in storage
|
90
|
-
// Loop over the diagonal elements of R:
|
91
|
-
while (r < q_idx - 1) {
|
92
|
-
// Compute the Givens rotation that makes the subdiagonal element
|
93
|
-
// of column c of R zero.
|
94
|
-
G.makeGivens(R(r, c), R(r + 1, c), &R(r, c));
|
95
|
-
// Apply it to the remaining columns of R.
|
96
|
-
// Not the current column, because the diagonal element was updated
|
97
|
-
// by the makeGivens function, and the subdiagonal element doesn't
|
98
|
-
// have to be set to zero explicitly, it's implicit.
|
99
|
-
// Also not the previous columns, because they are already
|
100
|
-
// implicitly zero below the diagonal and this rotation wouldn't
|
101
|
-
// have any effect there.
|
102
|
-
// TODO: can this be sped up by applying it in two blocks instead
|
103
|
-
// of column by column?
|
104
|
-
for (index_t cc = r_succ(c); cc != r_idx_end; cc = r_succ(cc))
|
105
|
-
R.col(cc).applyOnTheLeft(r, r + 1, G.adjoint());
|
106
|
-
// Apply the inverse of the Givens rotation to Q.
|
107
|
-
Q.block(0, 0, Q.rows(), q_idx).applyOnTheRight(r, r + 1, G);
|
108
|
-
// Keep track of the minimum/maximum diagonal element of R
|
109
|
-
min_eig = std::min(min_eig, R(r, c));
|
110
|
-
max_eig = std::max(max_eig, R(r, c));
|
111
|
-
// Advance indices to next diagonal element of R.
|
112
|
-
++r;
|
113
|
-
c = r_succ(c);
|
114
|
-
}
|
115
|
-
// Remove rightmost column of Q, since it corresponds to the bottom row
|
116
|
-
// of R, which was set to zero by the Givens rotations
|
117
|
-
--q_idx;
|
118
|
-
// Remove the first column of R.
|
119
|
-
r_idx_start = r_succ(r_idx_start);
|
120
|
-
}
|
121
|
-
|
122
|
-
/// Solve the least squares problem Ax = b.
|
123
|
-
/// Do not divide by elements that are smaller in absolute value than @p tol.
|
124
|
-
template <class VecB, class VecX>
|
125
|
-
void solve_col(const VecB &b, VecX &x, real_t tol = 0) const {
|
126
|
-
// Iterate over the diagonal of R, starting at the bottom right,
|
127
|
-
// this is standard back substitution
|
128
|
-
// (recall that R is stored in a circular buffer, so R.col(i) is
|
129
|
-
// not the mathematical i-th column)
|
130
|
-
auto rev_bgn = ring_reverse_iter().begin();
|
131
|
-
auto rev_end = ring_reverse_iter().end();
|
132
|
-
auto fwd_end = ring_iter().end();
|
133
|
-
for (auto it_d = rev_bgn; it_d != rev_end; ++it_d) {
|
134
|
-
// Row/column index of diagonal element of R
|
135
|
-
auto [rR, cR] = *it_d;
|
136
|
-
// Don't divide by very small diagonal elements
|
137
|
-
if (std::abs(R(rR, cR)) < tol) {
|
138
|
-
x(rR) = real_t{0};
|
139
|
-
continue;
|
140
|
-
}
|
141
|
-
// (r is the zero-based mathematical index, c is the index in
|
142
|
-
// the circular buffer)
|
143
|
-
x(rR) = Q.col(rR).transpose() * b; // Compute rhs Qᵀb
|
144
|
-
// In the current row of R, iterate over the elements to the
|
145
|
-
// right of the diagonal
|
146
|
-
// Iterating from left to right seems to give better results
|
147
|
-
for (auto it_c = it_d.forwardit; it_c != fwd_end; ++it_c) {
|
148
|
-
auto [rX2, cR2] = *it_c;
|
149
|
-
x(rR) -= R(rR, cR2) * x(rX2);
|
150
|
-
}
|
151
|
-
x(rR) /= R(rR, cR); // Divide by diagonal element
|
152
|
-
}
|
153
|
-
}
|
154
|
-
|
155
|
-
/// Solve the least squares problem AX = B.
|
156
|
-
/// Do not divide by elements that are smaller in absolute value than @p tol.
|
157
|
-
template <class MatB, class MatX>
|
158
|
-
void solve(const MatB &B, MatX &X, real_t tol = 0) const {
|
159
|
-
assert(B.cols() <= X.cols());
|
160
|
-
assert(B.rows() >= Q.rows());
|
161
|
-
assert(X.rows() >= Eigen::Index(num_columns()));
|
162
|
-
// Each column of the right hand side is solved as an individual system
|
163
|
-
for (Eigen::Index cB = 0; cB < B.cols(); ++cB) {
|
164
|
-
auto b = B.col(cB);
|
165
|
-
auto x = X.col(cB);
|
166
|
-
solve_col(b, x, tol);
|
167
|
-
}
|
168
|
-
}
|
169
|
-
|
170
|
-
template <class Derived>
|
171
|
-
using solve_ret_t = std::conditional_t<
|
172
|
-
Eigen::internal::traits<Derived>::ColsAtCompileTime == 1, vec, mat>;
|
173
|
-
|
174
|
-
/// Solve the least squares problem AX = B.
|
175
|
-
template <class Derived>
|
176
|
-
solve_ret_t<Derived> solve(const Eigen::DenseBase<Derived> &B) {
|
177
|
-
solve_ret_t<Derived> X(m(), B.cols());
|
178
|
-
solve(B, X);
|
179
|
-
return X;
|
180
|
-
}
|
181
|
-
|
182
|
-
/// Get the full, raw storage for the orthogonal matrix Q.
|
183
|
-
const mat &get_raw_Q() const { return Q; }
|
184
|
-
/// Get the full, raw storage for the upper triangular matrix R.
|
185
|
-
/// The columns of this matrix are permuted because it's stored as a
|
186
|
-
/// circular buffer for efficiently appending columns to the end and
|
187
|
-
/// popping columns from the front.
|
188
|
-
const mat &get_raw_R() const { return R; }
|
189
|
-
|
190
|
-
/// Get the full storage for the upper triangular matrix R but with the
|
191
|
-
/// columns in the correct order.
|
192
|
-
/// @note Meant for tests only, creates a permuted copy.
|
193
|
-
mat get_full_R() const {
|
194
|
-
if (r_idx_start == 0)
|
195
|
-
return R;
|
196
|
-
// Using a permutation matrix here isn't as efficient as rotating the
|
197
|
-
// matrix manually, but this function is only used in tests, so it
|
198
|
-
// shouldn't matter.
|
199
|
-
Eigen::PermutationMatrix<Eigen::Dynamic> P(R.cols());
|
200
|
-
P.setIdentity();
|
201
|
-
std::rotate(P.indices().data(), P.indices().data() + r_idx_start,
|
202
|
-
P.indices().data() + P.size());
|
203
|
-
return R * P;
|
204
|
-
}
|
205
|
-
/// Get the matrix R such that Q times R is the original matrix.
|
206
|
-
/// @note Meant for tests only, creates a permuted copy.
|
207
|
-
mat get_R() const {
|
208
|
-
return get_full_R()
|
209
|
-
.block(0, 0, q_idx, q_idx)
|
210
|
-
.template triangularView<Eigen::Upper>();
|
211
|
-
}
|
212
|
-
/// Get the matrix Q such that Q times R is the original matrix.
|
213
|
-
/// @note Meant for tests only, creates a copy.
|
214
|
-
mat get_Q() const { return Q.block(0, 0, n(), q_idx); }
|
215
|
-
|
216
|
-
/// Multiply the matrix R by a scalar.
|
217
|
-
void scale_R(real_t scal) {
|
218
|
-
for (auto [i, r_idx] : ring_iter())
|
219
|
-
R.col(r_idx).topRows(i + 1) *= scal;
|
220
|
-
min_eig *= scal;
|
221
|
-
max_eig *= scal;
|
222
|
-
}
|
223
|
-
|
224
|
-
/// Get the number of MGS reorthogonalizations.
|
225
|
-
unsigned long get_reorth_count() const { return reorth_count; }
|
226
|
-
/// Reset the number of MGS reorthogonalizations.
|
227
|
-
void clear_reorth_count() { reorth_count = 0; }
|
228
|
-
|
229
|
-
/// Get the minimum eigenvalue of R.
|
230
|
-
real_t get_min_eig() const { return min_eig; }
|
231
|
-
/// Get the maximum eigenvalue of R.
|
232
|
-
real_t get_max_eig() const { return max_eig; }
|
233
|
-
|
234
|
-
/// Reset all indices, clearing the Q and R matrices.
|
235
|
-
void reset() {
|
236
|
-
q_idx = 0;
|
237
|
-
r_idx_start = 0;
|
238
|
-
r_idx_end = 0;
|
239
|
-
reorth_count = 0;
|
240
|
-
min_eig = +inf<config_t>;
|
241
|
-
max_eig = -inf<config_t>;
|
242
|
-
}
|
243
|
-
|
244
|
-
/// Re-allocate storage for a problem with a different size. Causes
|
245
|
-
/// a @ref reset.
|
246
|
-
void resize(length_t n, length_t m) {
|
247
|
-
Q.resize(n, m);
|
248
|
-
R.resize(m, m);
|
249
|
-
reset();
|
250
|
-
}
|
251
|
-
|
252
|
-
/// Get the number of columns that are currently stored.
|
253
|
-
length_t num_columns() const { return q_idx; }
|
254
|
-
/// Get the head index of the circular buffer (points to the oldest
|
255
|
-
/// element).
|
256
|
-
index_t ring_head() const { return r_idx_start; }
|
257
|
-
/// Get the tail index of the circular buffer (points to one past the most
|
258
|
-
/// recent element).
|
259
|
-
index_t ring_tail() const { return r_idx_end; }
|
260
|
-
/// Get the next index in the circular buffer.
|
261
|
-
index_t ring_next(index_t i) const { return r_succ(i); }
|
262
|
-
/// Get the previous index in the circular buffer.
|
263
|
-
index_t ring_prev(index_t i) const { return r_pred(i); }
|
264
|
-
/// Get the number of columns currently stored in the buffer.
|
265
|
-
length_t current_history() const { return q_idx; }
|
266
|
-
|
267
|
-
/// Get iterators in the circular buffer.
|
268
|
-
CircularRange<index_t> ring_iter() const {
|
269
|
-
return {q_idx, r_idx_start, r_idx_end, m()};
|
270
|
-
}
|
271
|
-
/// Get reverse iterators in the circular buffer.
|
272
|
-
ReverseCircularRange<index_t> ring_reverse_iter() const {
|
273
|
-
return ring_iter();
|
274
|
-
}
|
275
|
-
|
276
|
-
private:
|
277
|
-
mat Q; ///< Storage for orthogonal factor Q.
|
278
|
-
mat R; ///< Storage for upper triangular factor R.
|
279
|
-
|
280
|
-
index_t q_idx = 0; ///< Number of columns of Q being stored.
|
281
|
-
index_t r_idx_start = 0; ///< Index of the first column of R.
|
282
|
-
index_t r_idx_end = 0; ///< Index of the one-past-last column of R.
|
283
|
-
|
284
|
-
unsigned long reorth_count = 0; ///< Number of MGS reorthogonalizations.
|
285
|
-
|
286
|
-
real_t min_eig = +inf<config_t>; ///< Minimum eigenvalue of R.
|
287
|
-
real_t max_eig = -inf<config_t>; ///< Maximum eigenvalue of R.
|
288
|
-
|
289
|
-
/// Get the next index in the circular storage for R.
|
290
|
-
index_t r_succ(index_t i) const { return i + 1 < m() ? i + 1 : 0; }
|
291
|
-
/// Get the previous index in the circular storage for R.
|
292
|
-
index_t r_pred(index_t i) const { return i == 0 ? m() - 1 : i - 1; }
|
293
|
-
};
|
294
|
-
|
295
|
-
} // namespace alpaqa
|
@@ -1,244 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
#include <alpaqa/config/config.hpp>
|
4
|
-
#include <alpaqa/export.hpp>
|
5
|
-
|
6
|
-
#include <cmath>
|
7
|
-
#include <limits>
|
8
|
-
#include <string>
|
9
|
-
#include <utility>
|
10
|
-
#include <vector>
|
11
|
-
|
12
|
-
namespace alpaqa {
|
13
|
-
|
14
|
-
/// Cautious BFGS update.
|
15
|
-
/// @see @ref LBFGSParams::cbfgs
|
16
|
-
template <Config Conf = DefaultConfig>
|
17
|
-
struct CBFGSParams {
|
18
|
-
USING_ALPAQA_CONFIG(Conf);
|
19
|
-
real_t α = 1;
|
20
|
-
real_t ϵ = 0; ///< Set to zero to disable CBFGS check.
|
21
|
-
explicit operator bool() const { return ϵ > 0; }
|
22
|
-
};
|
23
|
-
|
24
|
-
/// Which method to use to select the L-BFGS step size.
|
25
|
-
enum class LBFGSStepSize {
|
26
|
-
/// Initial inverse Hessian approximation is set to
|
27
|
-
/// @f$ H_0 = \gamma I @f$.
|
28
|
-
BasedOnExternalStepSize = 0,
|
29
|
-
/// Initial inverse Hessian approximation is set to
|
30
|
-
/// @f$ H_0 = \frac{s^\top y}{y^\top y} I @f$.
|
31
|
-
BasedOnCurvature = 1,
|
32
|
-
BasedOnGradientStepSize
|
33
|
-
[[deprecated("use BasedOnExternalStepSize instead")]] =
|
34
|
-
BasedOnExternalStepSize,
|
35
|
-
};
|
36
|
-
|
37
|
-
/// Parameters for the @ref LBFGS class.
|
38
|
-
template <Config Conf = DefaultConfig>
|
39
|
-
struct LBFGSParams {
|
40
|
-
USING_ALPAQA_CONFIG(Conf);
|
41
|
-
|
42
|
-
/// Length of the history to keep.
|
43
|
-
length_t memory = 10;
|
44
|
-
/// Reject update if @f$ y^\top s \le \text{min_div_fac} \cdot s^\top s @f$.
|
45
|
-
real_t min_div_fac = std::numeric_limits<real_t>::epsilon();
|
46
|
-
/// Reject update if @f$ s^\top s \le \text{min_abs_s} @f$.
|
47
|
-
real_t min_abs_s =
|
48
|
-
std::pow(std::numeric_limits<real_t>::epsilon(), real_t(2));
|
49
|
-
/// Parameters in the cautious BFGS update condition
|
50
|
-
/// @f[ \frac{y^\top s}{s^\top s} \ge \epsilon \| g \|^\alpha @f]
|
51
|
-
/// @see https://epubs.siam.org/doi/10.1137/S1052623499354242
|
52
|
-
CBFGSParams<config_t> cbfgs = {};
|
53
|
-
/// If set to true, the inverse Hessian estimate should remain definite,
|
54
|
-
/// i.e. a check is performed that rejects the update if
|
55
|
-
/// @f$ y^\top s \le \text{min_div_fac} \cdot s^\top s @f$.
|
56
|
-
/// If set to false, just try to prevent a singular Hessian by rejecting the
|
57
|
-
/// update if
|
58
|
-
/// @f$ \left| y^\top s \right| \le \text{min_div_fac} \cdot s^\top s @f$.
|
59
|
-
bool force_pos_def = true;
|
60
|
-
/// @see LBFGSStepSize
|
61
|
-
LBFGSStepSize stepsize = LBFGSStepSize::BasedOnCurvature;
|
62
|
-
};
|
63
|
-
|
64
|
-
/// Layout:
|
65
|
-
/// ~~~
|
66
|
-
/// ┌───── 2 m ─────┐
|
67
|
-
/// ┌ ┌───┬───┬───┬───┐
|
68
|
-
/// │ │ │ │ │ │
|
69
|
-
/// │ │ s │ y │ s │ y │
|
70
|
-
/// n+1 │ │ │ │ │ │
|
71
|
-
/// │ ├───┼───┼───┼───┤
|
72
|
-
/// │ │ ρ │ α │ ρ │ α │
|
73
|
-
/// └ └───┴───┴───┴───┘
|
74
|
-
/// ~~~
|
75
|
-
template <Config Conf = DefaultConfig>
|
76
|
-
struct LBFGSStorage {
|
77
|
-
USING_ALPAQA_CONFIG(Conf);
|
78
|
-
|
79
|
-
/// Re-allocate storage for a problem with a different size.
|
80
|
-
void resize(length_t n, length_t history);
|
81
|
-
|
82
|
-
/// Get the size of the s and y vectors in the buffer.
|
83
|
-
length_t n() const { return sto.rows() - 1; }
|
84
|
-
/// Get the number of previous vectors s and y stored in the buffer.
|
85
|
-
length_t history() const { return sto.cols() / 2; }
|
86
|
-
|
87
|
-
auto s(index_t i) { return sto.col(2 * i).topRows(n()); }
|
88
|
-
auto s(index_t i) const {
|
89
|
-
return std::as_const(sto).col(2 * i).topRows(n());
|
90
|
-
}
|
91
|
-
auto y(index_t i) { return sto.col(2 * i + 1).topRows(n()); }
|
92
|
-
auto y(index_t i) const {
|
93
|
-
return std::as_const(sto).col(2 * i + 1).topRows(n());
|
94
|
-
}
|
95
|
-
real_t &ρ(index_t i) { return sto.coeffRef(n(), 2 * i); }
|
96
|
-
real_t &ρ(index_t i) const { return sto.coeffRef(n(), 2 * i); }
|
97
|
-
real_t &α(index_t i) { return sto.coeffRef(n(), 2 * i + 1); }
|
98
|
-
real_t &α(index_t i) const { return sto.coeffRef(n(), 2 * i + 1); }
|
99
|
-
|
100
|
-
using storage_t = mat;
|
101
|
-
static_assert(!storage_t::IsRowMajor);
|
102
|
-
mutable storage_t sto;
|
103
|
-
};
|
104
|
-
|
105
|
-
/// Limited memory Broyden–Fletcher–Goldfarb–Shanno (L-BFGS) algorithm
|
106
|
-
/// @ingroup grp_Accelerators
|
107
|
-
template <Config Conf = DefaultConfig>
|
108
|
-
class ALPAQA_EXPORT LBFGS {
|
109
|
-
public:
|
110
|
-
USING_ALPAQA_CONFIG(Conf);
|
111
|
-
|
112
|
-
using Params = LBFGSParams<config_t>;
|
113
|
-
|
114
|
-
/// The sign of the vectors @f$ p @f$ passed to the @ref update method.
|
115
|
-
enum class Sign {
|
116
|
-
Positive, ///< @f$ p \sim \nabla \psi(x) @f$
|
117
|
-
Negative, ///< @f$ p \sim -\nabla \psi(x) @f$
|
118
|
-
};
|
119
|
-
|
120
|
-
LBFGS() = default;
|
121
|
-
LBFGS(Params params) : params(params) {}
|
122
|
-
LBFGS(Params params, length_t n) : params(params) { resize(n); }
|
123
|
-
|
124
|
-
/// Check if the new vectors s and y allow for a valid BFGS update that
|
125
|
-
/// preserves the positive definiteness of the Hessian approximation.
|
126
|
-
static bool update_valid(const Params ¶ms, real_t yᵀs, real_t sᵀs,
|
127
|
-
real_t pᵀp);
|
128
|
-
|
129
|
-
/// Update the inverse Hessian approximation using the new vectors
|
130
|
-
/// sₖ = xₙₑₓₜ - xₖ and yₖ = pₙₑₓₜ - pₖ.
|
131
|
-
bool update_sy(crvec s, crvec y, real_t pₙₑₓₜᵀpₙₑₓₜ, bool forced = false);
|
132
|
-
/// @see @ref update_sy
|
133
|
-
bool update_sy_impl(const auto &s, const auto &y, real_t pₙₑₓₜᵀpₙₑₓₜ,
|
134
|
-
bool forced = false);
|
135
|
-
|
136
|
-
/// Update the inverse Hessian approximation using the new vectors xₙₑₓₜ
|
137
|
-
/// and pₙₑₓₜ.
|
138
|
-
bool update(crvec xₖ, crvec xₙₑₓₜ, crvec pₖ, crvec pₙₑₓₜ,
|
139
|
-
Sign sign = Sign::Positive, bool forced = false);
|
140
|
-
|
141
|
-
/// Apply the inverse Hessian approximation to the given vector q.
|
142
|
-
/// Initial inverse Hessian approximation is set to @f$ H_0 = \gamma I @f$.
|
143
|
-
/// If @p γ is negative, @f$ H_0 = \frac{s^\top y}{y^\top y} I @f$.
|
144
|
-
bool apply(rvec q, real_t γ = -1) const;
|
145
|
-
|
146
|
-
/// Apply the inverse Hessian approximation to the given vector q, applying
|
147
|
-
/// only the columns and rows of the Hessian in the index set J.
|
148
|
-
bool apply_masked(rvec q, real_t γ, crindexvec J) const;
|
149
|
-
/// @copydoc apply_masked(rvec, real_t, crindexvec) const
|
150
|
-
bool apply_masked(rvec q, real_t γ, const std::vector<index_t> &J) const;
|
151
|
-
/// @copydoc apply_masked(rvec, real_t, crindexvec) const
|
152
|
-
bool apply_masked_impl(rvec q, real_t γ, const auto &J) const;
|
153
|
-
|
154
|
-
/// Throw away the approximation and all previous vectors s and y.
|
155
|
-
void reset();
|
156
|
-
/// Re-allocate storage for a problem with a different size. Causes
|
157
|
-
/// a @ref reset.
|
158
|
-
void resize(length_t n);
|
159
|
-
|
160
|
-
/// Scale the stored y vectors by the given factor.
|
161
|
-
void scale_y(real_t factor);
|
162
|
-
|
163
|
-
/// Get a string identifier for this accelerator.
|
164
|
-
std::string get_name() const {
|
165
|
-
return "LBFGS<" + std::string(config_t::get_name()) + '>';
|
166
|
-
}
|
167
|
-
/// Get the parameters.
|
168
|
-
const Params &get_params() const { return params; }
|
169
|
-
|
170
|
-
/// Get the size of the s and y vectors in the buffer.
|
171
|
-
length_t n() const { return sto.n(); }
|
172
|
-
/// Get the number of previous vectors s and y stored in the buffer.
|
173
|
-
length_t history() const { return sto.history(); }
|
174
|
-
/// Get the next index in the circular buffer of previous s and y vectors.
|
175
|
-
index_t succ(index_t i) const { return i + 1 < history() ? i + 1 : 0; }
|
176
|
-
/// Get the previous index in the circular buffer of s and y vectors.
|
177
|
-
index_t pred(index_t i) const { return i > 0 ? i - 1 : history() - 1; }
|
178
|
-
/// Get the number of previous s and y vectors currently stored in the
|
179
|
-
/// buffer.
|
180
|
-
length_t current_history() const { return full ? history() : idx; }
|
181
|
-
|
182
|
-
auto s(index_t i) { return sto.s(i); }
|
183
|
-
auto s(index_t i) const { return sto.s(i); }
|
184
|
-
auto y(index_t i) { return sto.y(i); }
|
185
|
-
auto y(index_t i) const { return sto.y(i); }
|
186
|
-
real_t &ρ(index_t i) { return sto.ρ(i); }
|
187
|
-
real_t &ρ(index_t i) const { return sto.ρ(i); }
|
188
|
-
real_t &α(index_t i) { return sto.α(i); }
|
189
|
-
real_t &α(index_t i) const { return sto.α(i); }
|
190
|
-
|
191
|
-
/// Iterate over the indices in the history buffer, oldest first.
|
192
|
-
template <class F>
|
193
|
-
void foreach_fwd(const F &fun) const {
|
194
|
-
if (full)
|
195
|
-
for (index_t i = idx; i < history(); ++i)
|
196
|
-
fun(i);
|
197
|
-
if (idx)
|
198
|
-
for (index_t i = 0; i < idx; ++i)
|
199
|
-
fun(i);
|
200
|
-
}
|
201
|
-
|
202
|
-
/// Iterate over the indices in the history buffer, newest first.
|
203
|
-
template <class F>
|
204
|
-
void foreach_rev(const F &fun) const {
|
205
|
-
if (idx)
|
206
|
-
for (index_t i = idx; i-- > 0;)
|
207
|
-
fun(i);
|
208
|
-
if (full)
|
209
|
-
for (index_t i = history(); i-- > idx;)
|
210
|
-
fun(i);
|
211
|
-
}
|
212
|
-
|
213
|
-
private:
|
214
|
-
LBFGSStorage<config_t> sto;
|
215
|
-
index_t idx = 0;
|
216
|
-
bool full = false;
|
217
|
-
Params params;
|
218
|
-
};
|
219
|
-
|
220
|
-
ALPAQA_EXPORT_EXTERN_TEMPLATE(struct, CBFGSParams, DefaultConfig);
|
221
|
-
ALPAQA_EXPORT_EXTERN_TEMPLATE(struct, CBFGSParams, EigenConfigf);
|
222
|
-
ALPAQA_EXPORT_EXTERN_TEMPLATE(struct, CBFGSParams, EigenConfigd);
|
223
|
-
ALPAQA_EXPORT_EXTERN_TEMPLATE(struct, CBFGSParams, EigenConfigl);
|
224
|
-
#ifdef ALPAQA_WITH_QUAD_PRECISION
|
225
|
-
ALPAQA_EXPORT_EXTERN_TEMPLATE(struct, CBFGSParams, EigenConfigq);
|
226
|
-
#endif
|
227
|
-
|
228
|
-
ALPAQA_EXPORT_EXTERN_TEMPLATE(struct, LBFGSParams, DefaultConfig);
|
229
|
-
ALPAQA_EXPORT_EXTERN_TEMPLATE(struct, LBFGSParams, EigenConfigf);
|
230
|
-
ALPAQA_EXPORT_EXTERN_TEMPLATE(struct, LBFGSParams, EigenConfigd);
|
231
|
-
ALPAQA_EXPORT_EXTERN_TEMPLATE(struct, LBFGSParams, EigenConfigl);
|
232
|
-
#ifdef ALPAQA_WITH_QUAD_PRECISION
|
233
|
-
ALPAQA_EXPORT_EXTERN_TEMPLATE(struct, LBFGSParams, EigenConfigq);
|
234
|
-
#endif
|
235
|
-
|
236
|
-
ALPAQA_EXPORT_EXTERN_TEMPLATE(class, LBFGS, DefaultConfig);
|
237
|
-
ALPAQA_EXPORT_EXTERN_TEMPLATE(class, LBFGS, EigenConfigf);
|
238
|
-
ALPAQA_EXPORT_EXTERN_TEMPLATE(class, LBFGS, EigenConfigd);
|
239
|
-
ALPAQA_EXPORT_EXTERN_TEMPLATE(class, LBFGS, EigenConfigl);
|
240
|
-
#ifdef ALPAQA_WITH_QUAD_PRECISION
|
241
|
-
ALPAQA_EXPORT_EXTERN_TEMPLATE(class, LBFGS, EigenConfigq);
|
242
|
-
#endif
|
243
|
-
|
244
|
-
} // namespace alpaqa
|
@@ -1,143 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
#include <alpaqa/config/config.hpp>
|
4
|
-
#include <alpaqa/util/alloc-check.hpp>
|
5
|
-
|
6
|
-
namespace alpaqa {
|
7
|
-
|
8
|
-
template <Config Conf>
|
9
|
-
struct SteihaugCGParams {
|
10
|
-
USING_ALPAQA_CONFIG(Conf);
|
11
|
-
real_t tol_scale = 1;
|
12
|
-
real_t tol_scale_root = real_t(0.5);
|
13
|
-
real_t tol_max = inf<config_t>;
|
14
|
-
real_t max_iter_factor = 1;
|
15
|
-
};
|
16
|
-
|
17
|
-
/// Steihaug conjugate gradients procedure based on
|
18
|
-
/// https://github.com/scipy/scipy/blob/583e70a50573169fc352b5dc6d94588a97c7389a/scipy/optimize/_trustregion_ncg.py#L44
|
19
|
-
template <Config Conf>
|
20
|
-
struct SteihaugCG {
|
21
|
-
USING_ALPAQA_CONFIG(Conf);
|
22
|
-
|
23
|
-
using Params = SteihaugCGParams<config_t>;
|
24
|
-
Params params;
|
25
|
-
|
26
|
-
SteihaugCG() = default;
|
27
|
-
SteihaugCG(const Params ¶ms) : params{params} {}
|
28
|
-
|
29
|
-
mutable vec z, r, d, Bd, work_eval;
|
30
|
-
|
31
|
-
void resize(length_t n) {
|
32
|
-
z.resize(n);
|
33
|
-
r.resize(n);
|
34
|
-
d.resize(n);
|
35
|
-
Bd.resize(n);
|
36
|
-
work_eval.resize(n);
|
37
|
-
}
|
38
|
-
|
39
|
-
template <class HessFun>
|
40
|
-
real_t solve(const auto &grad, const HessFun &hess_prod,
|
41
|
-
real_t trust_radius, rvec step) const {
|
42
|
-
length_t n = grad.size();
|
43
|
-
// get the norm of jacobian and define the origin
|
44
|
-
auto v = [n](auto &v) { return v.topRows(n); };
|
45
|
-
auto z = v(this->z), r = v(this->r), d = v(this->d), Bd = v(this->Bd);
|
46
|
-
auto g = v(grad);
|
47
|
-
auto s = v(step);
|
48
|
-
// init the state for the first iteration
|
49
|
-
z.setZero();
|
50
|
-
r = g;
|
51
|
-
d = -r;
|
52
|
-
real_t r_sq = r.squaredNorm();
|
53
|
-
real_t grad_mag = g.norm();
|
54
|
-
|
55
|
-
// define a default tolerance
|
56
|
-
real_t tolerance =
|
57
|
-
std::fmin(params.tol_max, params.tol_scale * grad_mag *
|
58
|
-
std::fmin(params.tol_scale_root,
|
59
|
-
std::sqrt(grad_mag)));
|
60
|
-
|
61
|
-
// Workspaces and function evaluation
|
62
|
-
auto eval = [&](crvec p) {
|
63
|
-
hess_prod(p, work_eval);
|
64
|
-
return p.dot(g) + real_t(0.5) * p.dot(v(work_eval));
|
65
|
-
};
|
66
|
-
|
67
|
-
// Search for the min of the approximation of the objective function.
|
68
|
-
index_t i = 0;
|
69
|
-
const auto max_iter = static_cast<index_t>(
|
70
|
-
std::round(static_cast<real_t>(n) * params.max_iter_factor));
|
71
|
-
while (true) {
|
72
|
-
// do an iteration
|
73
|
-
hess_prod(d, Bd);
|
74
|
-
real_t dBd = d.dot(Bd);
|
75
|
-
if (dBd <= 0) {
|
76
|
-
// Look at the two boundary points.
|
77
|
-
// Find both values of t to get the boundary points such that
|
78
|
-
// ||z + t d|| == trust_radius
|
79
|
-
// and then choose the one with the predicted min value.
|
80
|
-
auto [ta, tb] =
|
81
|
-
get_boundaries_intersections(z, d, trust_radius);
|
82
|
-
auto &pa = r; // Reuse storage
|
83
|
-
auto &pb = d; // Reuse storage
|
84
|
-
pa = z + ta * d;
|
85
|
-
pb = z + tb * d;
|
86
|
-
real_t q_a = eval(pa), q_b = eval(pb);
|
87
|
-
real_t q_min = std::fmin(q_a, q_b);
|
88
|
-
if (q_a == q_min) {
|
89
|
-
s = pa;
|
90
|
-
return q_a;
|
91
|
-
} else {
|
92
|
-
s = pb;
|
93
|
-
return q_b;
|
94
|
-
}
|
95
|
-
}
|
96
|
-
|
97
|
-
real_t alpha = r_sq / dBd;
|
98
|
-
s = z + alpha * d;
|
99
|
-
if (s.norm() >= trust_radius) {
|
100
|
-
// Find t >= 0 to get the boundary point such that
|
101
|
-
// ||z + t d|| == trust_radius
|
102
|
-
auto [ta, tb] =
|
103
|
-
get_boundaries_intersections(z, d, trust_radius);
|
104
|
-
s = z + tb * d;
|
105
|
-
return eval(s);
|
106
|
-
}
|
107
|
-
r += alpha * Bd;
|
108
|
-
real_t r_next_sq = r.squaredNorm();
|
109
|
-
if (std::sqrt(r_next_sq) < tolerance || i > max_iter)
|
110
|
-
return eval(s);
|
111
|
-
real_t beta_next = r_next_sq / r_sq;
|
112
|
-
r_sq = r_next_sq;
|
113
|
-
d = beta_next * d - r;
|
114
|
-
z = s;
|
115
|
-
++i;
|
116
|
-
}
|
117
|
-
}
|
118
|
-
|
119
|
-
/// Solve the scalar quadratic equation ||z + t d|| == trust_radius.
|
120
|
-
/// This is like a line-sphere intersection.
|
121
|
-
/// Return the two values of t, sorted from low to high.
|
122
|
-
static auto get_boundaries_intersections(crvec z, crvec d,
|
123
|
-
real_t trust_radius) {
|
124
|
-
real_t a = d.squaredNorm();
|
125
|
-
real_t b = 2 * z.dot(d);
|
126
|
-
real_t c = z.squaredNorm() - trust_radius * trust_radius;
|
127
|
-
real_t sqrt_discriminant = std::sqrt(b * b - 4 * a * c);
|
128
|
-
|
129
|
-
// The following calculation is mathematically
|
130
|
-
// equivalent to:
|
131
|
-
// ta = (-b - sqrt_discriminant) / (2*a)
|
132
|
-
// tb = (-b + sqrt_discriminant) / (2*a)
|
133
|
-
// but produce smaller round off errors.
|
134
|
-
// Look at Matrix Computation p.97
|
135
|
-
// for a better justification.
|
136
|
-
real_t aux = b + std::copysign(sqrt_discriminant, b);
|
137
|
-
real_t ta = -aux / (2 * a);
|
138
|
-
real_t tb = -2 * c / aux;
|
139
|
-
return std::make_tuple(std::fmin(ta, tb), std::fmax(ta, tb));
|
140
|
-
}
|
141
|
-
};
|
142
|
-
|
143
|
-
} // namespace alpaqa
|
casadi/include/alpaqa/alpaqa.hpp
DELETED