casadi 3.6.7__cp313-none-macosx_11_0_arm64.whl → 3.7.1__cp313-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 +6531 -3039
- casadi/cbc +0 -0
- casadi/clp +0 -0
- casadi/cmake/casadi-config-version.cmake +1 -1
- casadi/cmake/casadi-config.cmake +1 -1
- casadi/cmake/casadi-targets-release.cmake +5 -5
- casadi/cmake/casadi-targets.cmake +7 -7
- casadi/{lib/cmake/tinyxml2/tinyxml2-config-version.cmake → cmake/ghc_filesystem/ghc_filesystem-config-version.cmake} +30 -10
- casadi/cmake/ghc_filesystem/ghc_filesystem-config.cmake +30 -0
- casadi/{lib/cmake/tinyxml2/tinyxml2-static-targets.cmake → cmake/ghc_filesystem/ghc_filesystem-targets.cmake} +10 -10
- casadi/cmake/highs/highs-targets-release.cmake +2 -2
- casadi/cmake/highs/highs-targets.cmake +3 -3
- casadi/cmake/libzip/libzip-config-version.cmake +43 -0
- casadi/cmake/libzip/libzip-config.cmake +69 -0
- casadi/cmake/libzip/libzip-targets-release.cmake +19 -0
- casadi/cmake/libzip/libzip-targets.cmake +107 -0
- casadi/cmake/libzip/modules/FindMbedTLS.cmake +141 -0
- casadi/cmake/libzip/modules/FindNettle.cmake +141 -0
- casadi/cmake/libzip/modules/Findzstd.cmake +186 -0
- casadi/cmake/osqp/osqp-targets.cmake +2 -2
- casadi/cmake/proxsuite/proxsuiteTargets.cmake +2 -2
- casadi/cmake/qdldl/qdldl-targets.cmake +2 -2
- casadi/cmake/sleqp/sleqp-targets.cmake +2 -2
- casadi/cmake/trlib/trlib-config.cmake +2 -2
- casadi/highs +0 -0
- casadi/include/casadi/casadi.i +276 -47
- casadi/include/casadi/config.h +11 -11
- casadi/include/casadi/core/archiver.hpp +58 -0
- casadi/include/casadi/core/blazing_spline.hpp +47 -0
- casadi/include/casadi/core/calculus.hpp +57 -2
- casadi/include/casadi/core/callback.hpp +9 -0
- casadi/include/casadi/core/casadi_common.hpp +37 -0
- casadi/include/casadi/core/casadi_meta.hpp +15 -0
- casadi/include/casadi/core/casadi_misc.hpp +21 -0
- casadi/include/casadi/core/code_generator.hpp +115 -19
- casadi/include/casadi/core/core.hpp +5 -0
- casadi/include/casadi/core/dae_builder.hpp +303 -141
- casadi/include/casadi/core/dm.hpp +3 -0
- casadi/include/casadi/core/filesystem.hpp +58 -0
- casadi/include/casadi/core/fmu.hpp +62 -16
- casadi/include/casadi/core/function.hpp +24 -0
- casadi/include/casadi/core/generic_matrix.hpp +214 -7
- casadi/include/casadi/core/generic_shared.hpp +395 -0
- casadi/include/casadi/core/generic_shared_impl.hpp +218 -0
- casadi/include/casadi/core/generic_shared_internal.hpp +215 -0
- casadi/include/casadi/core/generic_type.hpp +3 -0
- casadi/include/casadi/core/global_options.hpp +10 -0
- casadi/include/casadi/core/integrator.hpp +41 -7
- casadi/include/casadi/core/matrix_decl.hpp +71 -0
- casadi/include/casadi/core/mx.hpp +63 -2
- casadi/include/casadi/core/nlp_builder.hpp +2 -1
- casadi/include/casadi/core/options.hpp +6 -3
- casadi/include/casadi/core/optistack.hpp +43 -9
- casadi/include/casadi/core/printable.hpp +8 -0
- casadi/include/casadi/core/resource.hpp +107 -0
- casadi/include/casadi/core/runtime/casadi_blazing_1d_boor_eval.hpp +112 -0
- casadi/include/casadi/core/runtime/casadi_blazing_2d_boor_eval.hpp +311 -0
- casadi/include/casadi/core/runtime/casadi_blazing_3d_boor_eval.hpp +645 -0
- casadi/include/casadi/core/runtime/casadi_blazing_de_boor.hpp +101 -0
- casadi/include/casadi/core/runtime/casadi_finite_diff.hpp +1 -1
- casadi/include/casadi/core/runtime/casadi_nlp.hpp +8 -2
- casadi/include/casadi/core/runtime/casadi_print_canonical.hpp +55 -0
- casadi/include/casadi/core/runtime/casadi_print_scalar.hpp +25 -0
- casadi/include/casadi/core/runtime/casadi_print_vector.hpp +32 -0
- casadi/include/casadi/core/runtime/casadi_printme.hpp +26 -0
- casadi/include/casadi/core/serializer.hpp +13 -5
- casadi/include/casadi/core/serializing_stream.hpp +9 -2
- casadi/include/casadi/core/shared_object.hpp +73 -161
- casadi/include/casadi/core/sparsity.hpp +13 -1
- casadi/include/casadi/core/sparsity_interface.hpp +19 -1
- casadi/include/casadi/core/sx.hpp +41 -0
- casadi/include/casadi/core/sx_elem.hpp +25 -0
- casadi/include/casadi/core/xml_node.hpp +5 -0
- casadi/include/casadi/doc.i +10026 -6513
- casadi/include/casadi/doc_merged.i +6744 -4449
- casadi/include/casadi/valgrind-casadi.supp +138 -0
- casadi/include/casadi/valgrind-python.supp +2470 -0
- casadi/include/fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp +4 -1
- casadi/include/ghc/filesystem.hpp +6083 -0
- casadi/include/ghc/fs_fwd.hpp +38 -0
- casadi/include/ghc/fs_impl.hpp +35 -0
- casadi/include/ghc/fs_std.hpp +60 -0
- casadi/include/ghc/fs_std_fwd.hpp +63 -0
- casadi/include/ghc/fs_std_impl.hpp +46 -0
- casadi/include/highs/HConfig.h +6 -4
- casadi/include/highs/Highs.h +260 -86
- casadi/include/highs/filereaderlp/reader.hpp +10 -10
- casadi/include/highs/interfaces/highs_c_api.h +195 -22
- casadi/include/highs/io/Filereader.h +4 -6
- casadi/include/highs/io/FilereaderEms.h +0 -3
- casadi/include/highs/io/FilereaderLp.h +0 -3
- casadi/include/highs/io/FilereaderMps.h +0 -3
- casadi/include/highs/io/HMPSIO.h +1 -4
- casadi/include/highs/io/HMpsFF.h +8 -5
- casadi/include/highs/io/HighsIO.h +10 -5
- casadi/include/highs/io/LoadOptions.h +0 -3
- casadi/include/highs/ipm/IpxSolution.h +0 -3
- casadi/include/highs/ipm/IpxWrapper.h +4 -7
- casadi/include/highs/ipm/ipx/control.h +1 -0
- casadi/include/highs/ipm/ipx/ipx_parameters.h +1 -0
- casadi/include/highs/ipm/ipx/lp_solver.h +3 -2
- casadi/include/highs/ipm/ipx/model.h +7 -3
- casadi/include/highs/lp_data/HConst.h +21 -6
- casadi/include/highs/lp_data/HStruct.h +40 -4
- casadi/include/highs/lp_data/HighsAnalysis.h +0 -3
- casadi/include/highs/lp_data/HighsCallback.h +10 -3
- casadi/include/highs/lp_data/HighsCallbackStruct.h +3 -3
- casadi/include/highs/lp_data/HighsDebug.h +0 -3
- casadi/include/highs/lp_data/HighsIis.h +62 -0
- casadi/include/highs/lp_data/HighsInfo.h +50 -43
- casadi/include/highs/lp_data/HighsInfoDebug.h +0 -3
- casadi/include/highs/lp_data/HighsLp.h +2 -3
- casadi/include/highs/lp_data/HighsLpSolverObject.h +0 -3
- casadi/include/highs/lp_data/HighsLpUtils.h +38 -6
- casadi/include/highs/lp_data/HighsModelUtils.h +21 -18
- casadi/include/highs/lp_data/HighsOptions.h +134 -22
- casadi/include/highs/lp_data/HighsRanging.h +0 -3
- casadi/include/highs/lp_data/HighsSolution.h +10 -3
- casadi/include/highs/lp_data/HighsSolutionDebug.h +0 -3
- casadi/include/highs/lp_data/HighsSolve.h +0 -3
- casadi/include/highs/lp_data/HighsStatus.h +0 -3
- casadi/include/highs/mip/HighsCliqueTable.h +3 -3
- casadi/include/highs/mip/HighsConflictPool.h +0 -3
- casadi/include/highs/mip/HighsCutGeneration.h +13 -3
- casadi/include/highs/mip/HighsCutPool.h +0 -3
- casadi/include/highs/mip/HighsDebugSol.h +0 -3
- casadi/include/highs/mip/HighsDomain.h +16 -4
- casadi/include/highs/mip/HighsDomainChange.h +0 -3
- casadi/include/highs/mip/HighsDynamicRowMatrix.h +0 -3
- casadi/include/highs/mip/HighsGFkSolve.h +3 -6
- casadi/include/highs/mip/HighsImplications.h +29 -5
- casadi/include/highs/mip/HighsLpAggregator.h +0 -3
- casadi/include/highs/mip/HighsLpRelaxation.h +0 -3
- casadi/include/highs/mip/HighsMipAnalysis.h +52 -0
- casadi/include/highs/mip/HighsMipSolver.h +11 -4
- casadi/include/highs/mip/HighsMipSolverData.h +67 -6
- casadi/include/highs/mip/HighsModkSeparator.h +1 -4
- casadi/include/highs/mip/HighsNodeQueue.h +0 -3
- casadi/include/highs/mip/HighsObjectiveFunction.h +0 -3
- casadi/include/highs/mip/HighsPathSeparator.h +1 -4
- casadi/include/highs/mip/HighsPrimalHeuristics.h +7 -5
- casadi/include/highs/mip/HighsPseudocost.h +0 -3
- casadi/include/highs/mip/HighsRedcostFixing.h +0 -3
- casadi/include/highs/mip/HighsSearch.h +0 -3
- casadi/include/highs/mip/HighsSeparation.h +0 -3
- casadi/include/highs/mip/HighsSeparator.h +1 -5
- casadi/include/highs/mip/HighsTableauSeparator.h +1 -4
- casadi/include/highs/mip/HighsTransformedLp.h +0 -3
- casadi/include/highs/mip/MipTimer.h +471 -0
- casadi/include/highs/parallel/HighsBinarySemaphore.h +1 -1
- casadi/include/highs/parallel/HighsCacheAlign.h +1 -1
- casadi/include/highs/parallel/HighsCombinable.h +1 -1
- casadi/include/highs/parallel/HighsMutex.h +1 -1
- casadi/include/highs/parallel/HighsRaceTimer.h +1 -1
- casadi/include/highs/parallel/HighsSchedulerConstants.h +1 -1
- casadi/include/highs/parallel/HighsSplitDeque.h +1 -1
- casadi/include/highs/parallel/HighsTaskExecutor.h +68 -55
- casadi/include/highs/pdlp/CupdlpWrapper.h +18 -7
- casadi/include/highs/pdlp/cupdlp/cupdlp_cs.h +2 -3
- casadi/include/highs/pdlp/cupdlp/cupdlp_defs.h +16 -6
- casadi/include/highs/pdlp/cupdlp/cupdlp_linalg.h +10 -4
- casadi/include/highs/pdlp/cupdlp/cupdlp_proj.h +3 -3
- casadi/include/highs/pdlp/cupdlp/cupdlp_restart.h +6 -6
- casadi/include/highs/pdlp/cupdlp/cupdlp_scaling.h +26 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_solver.h +11 -11
- casadi/include/highs/pdlp/cupdlp/cupdlp_step.h +8 -4
- casadi/include/highs/pdlp/cupdlp/cupdlp_utils.c +253 -172
- casadi/include/highs/presolve/HPresolve.h +50 -10
- casadi/include/highs/presolve/HPresolveAnalysis.h +0 -3
- casadi/include/highs/presolve/HighsPostsolveStack.h +39 -6
- casadi/include/highs/presolve/HighsSymmetry.h +0 -3
- casadi/include/highs/presolve/ICrash.h +0 -3
- casadi/include/highs/presolve/ICrashUtil.h +1 -4
- casadi/include/highs/presolve/ICrashX.h +0 -3
- casadi/include/highs/presolve/PresolveComponent.h +0 -3
- casadi/include/highs/qpsolver/a_asm.hpp +20 -17
- casadi/include/highs/qpsolver/a_quass.hpp +5 -9
- casadi/include/highs/qpsolver/basis.hpp +12 -10
- casadi/include/highs/qpsolver/crashsolution.hpp +4 -3
- casadi/include/highs/qpsolver/dantzigpricing.hpp +3 -2
- casadi/include/highs/qpsolver/devexpricing.hpp +3 -1
- casadi/include/highs/qpsolver/factor.hpp +6 -5
- casadi/include/highs/qpsolver/feasibility_bounded.hpp +31 -29
- casadi/include/highs/qpsolver/feasibility_highs.hpp +94 -70
- casadi/include/highs/qpsolver/gradient.hpp +1 -1
- casadi/include/highs/qpsolver/instance.hpp +1 -1
- casadi/include/highs/qpsolver/pricing.hpp +2 -2
- casadi/include/highs/qpsolver/qpconst.hpp +2 -2
- casadi/include/highs/qpsolver/quass.hpp +2 -2
- casadi/include/highs/qpsolver/runtime.hpp +2 -2
- casadi/include/highs/qpsolver/settings.hpp +20 -8
- casadi/include/highs/qpsolver/steepestedgepricing.hpp +38 -39
- casadi/include/highs/simplex/HApp.h +88 -34
- casadi/include/highs/simplex/HEkk.h +24 -11
- casadi/include/highs/simplex/HEkkDual.h +2 -4
- casadi/include/highs/simplex/HEkkDualRHS.h +0 -3
- casadi/include/highs/simplex/HEkkDualRow.h +0 -3
- casadi/include/highs/simplex/HEkkPrimal.h +1 -5
- casadi/include/highs/simplex/HSimplex.h +0 -3
- casadi/include/highs/simplex/HSimplexDebug.h +0 -3
- casadi/include/highs/simplex/HSimplexNla.h +0 -26
- casadi/include/highs/simplex/HSimplexReport.h +0 -3
- casadi/include/highs/simplex/HighsSimplexAnalysis.h +5 -8
- casadi/include/highs/simplex/SimplexConst.h +10 -11
- casadi/include/highs/simplex/SimplexStruct.h +9 -12
- casadi/include/highs/simplex/SimplexTimer.h +83 -101
- casadi/include/highs/test/DevKkt.h +0 -3
- casadi/include/highs/test/KktCh2.h +0 -3
- casadi/include/highs/util/FactorTimer.h +39 -64
- casadi/include/highs/util/HFactor.h +4 -4
- casadi/include/highs/util/HFactorConst.h +0 -3
- casadi/include/highs/util/HFactorDebug.h +0 -3
- casadi/include/highs/util/HSet.h +0 -3
- casadi/include/highs/util/HVector.h +0 -3
- casadi/include/highs/util/HVectorBase.h +1 -4
- casadi/include/highs/util/HighsCDouble.h +12 -3
- casadi/include/highs/util/HighsComponent.h +0 -3
- casadi/include/highs/util/HighsDataStack.h +0 -3
- casadi/include/highs/util/HighsDisjointSets.h +0 -3
- casadi/include/highs/util/HighsHash.h +9 -12
- casadi/include/highs/util/HighsHashTree.h +15 -11
- casadi/include/highs/util/HighsInt.h +0 -3
- casadi/include/highs/util/HighsIntegers.h +0 -3
- casadi/include/highs/util/HighsLinearSumBounds.h +0 -3
- casadi/include/highs/util/HighsMatrixPic.h +0 -3
- casadi/include/highs/util/HighsMatrixSlice.h +3 -6
- casadi/include/highs/util/HighsMatrixUtils.h +0 -3
- casadi/include/highs/util/HighsMemoryAllocation.h +11 -3
- casadi/include/highs/util/HighsRandom.h +3 -6
- casadi/include/highs/util/HighsRbTree.h +0 -3
- casadi/include/highs/util/HighsSort.h +0 -3
- casadi/include/highs/util/HighsSparseMatrix.h +6 -3
- casadi/include/highs/util/HighsSparseVectorSum.h +0 -3
- casadi/include/highs/util/HighsSplay.h +0 -3
- casadi/include/highs/util/HighsTimer.h +94 -56
- casadi/include/highs/util/HighsUtils.h +10 -3
- casadi/include/highs/util/stringutil.h +14 -12
- casadi/include/licenses/LICENSE.bzip2.txt +42 -0
- casadi/include/licenses/ghc-external/LICENSE +19 -0
- casadi/include/licenses/libz-external/LICENSE +22 -0
- casadi/include/licenses/libz-external/contrib/dotzlib/LICENSE_1_0.txt +23 -0
- casadi/include/licenses/libzip-external/LICENSE +31 -0
- casadi/include/zconf.h +545 -0
- casadi/include/zip.h +528 -0
- casadi/include/zipconf.h +48 -0
- casadi/include/zlib.h +1938 -0
- casadi/libCbc.3.10.11.dylib +0 -0
- casadi/libCbc.3.dylib +0 -0
- casadi/libCbc.dylib +0 -0
- casadi/libCbc.la +1 -1
- casadi/libCbcSolver.3.10.11.dylib +0 -0
- casadi/libCbcSolver.3.dylib +0 -0
- casadi/libCbcSolver.dylib +0 -0
- casadi/libCbcSolver.la +1 -1
- casadi/libCgl.1.10.8.dylib +0 -0
- casadi/libCgl.1.dylib +0 -0
- casadi/libCgl.dylib +0 -0
- casadi/libCgl.la +1 -1
- casadi/libClp.1.14.9.dylib +0 -0
- casadi/libClp.1.dylib +0 -0
- casadi/libClp.dylib +0 -0
- casadi/libClp.la +1 -1
- casadi/libClpSolver.1.14.9.dylib +0 -0
- casadi/libClpSolver.1.dylib +0 -0
- casadi/libClpSolver.dylib +0 -0
- casadi/libClpSolver.la +1 -1
- casadi/libCoinUtils.3.11.10.dylib +0 -0
- casadi/libCoinUtils.3.dylib +0 -0
- casadi/libCoinUtils.dylib +0 -0
- casadi/libOsi.1.13.9.dylib +0 -0
- casadi/libOsi.1.dylib +0 -0
- casadi/libOsi.dylib +0 -0
- casadi/libOsiCbc.3.10.11.dylib +0 -0
- casadi/libOsiCbc.3.dylib +0 -0
- casadi/libOsiCbc.dylib +0 -0
- casadi/libOsiCbc.la +1 -1
- casadi/libOsiClp.1.14.9.dylib +0 -0
- casadi/libOsiClp.1.dylib +0 -0
- casadi/libOsiClp.dylib +0 -0
- casadi/libOsiClp.la +1 -1
- casadi/libOsiCommonTests.1.13.9.dylib +0 -0
- casadi/libOsiCommonTests.1.dylib +0 -0
- casadi/libOsiCommonTests.dylib +0 -0
- 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 +1 -1
- casadi/libbz2.1.0.8.dylib +0 -0
- casadi/libc++.1.0.dylib +0 -0
- casadi/libcasadi.3.7.dylib +0 -0
- casadi/libcasadi.dylib +0 -0
- casadi/libcasadi_archiver_libzip.3.7.dylib +0 -0
- casadi/libcasadi_archiver_libzip.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_filesystem_ghc.3.7.dylib +0 -0
- casadi/libcasadi_filesystem_ghc.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/libcoinmumps.3.dylib +0 -0
- casadi/libcoinmumps.dylib +0 -0
- casadi/libcoinmumps.la +1 -1
- casadi/libcplex_adaptor.dylib +0 -0
- casadi/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.10.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 +1 -1
- casadi/liblinsys.a +0 -0
- casadi/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 +1 -1
- 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/libz.1.3.1.dylib +0 -0
- casadi/libz.1.dylib +0 -0
- casadi/libz.a +0 -0
- casadi/libz.dylib +0 -0
- casadi/libzip.a +0 -0
- casadi/pkgconfig/casadi.pc +1 -1
- casadi/pkgconfig/coinmumps.pc +1 -1
- casadi/pkgconfig/highs.pc +1 -1
- casadi/pkgconfig/libzip.pc +14 -0
- casadi/tools/__init__.py +3 -1
- casadi/tools/graph/graph.py +1 -1
- casadi/tools/structure3.py +7 -7
- {casadi-3.6.7.dist-info → casadi-3.7.1.dist-info}/METADATA +1 -1
- {casadi-3.6.7.dist-info → casadi-3.7.1.dist-info}/RECORD +450 -405
- casadi/include/highs/lp_data/HighsRuntimeOptions.h +0 -276
- casadi/include/highs/pdlp/cupdlp/cupdlp_scaling_cuda.h +0 -28
- casadi/include/tinyxml2.h +0 -2380
- casadi/lib/cmake/tinyxml2/tinyxml2-config.cmake +0 -57
- casadi/lib/cmake/tinyxml2/tinyxml2-static-targets-release.cmake +0 -19
- casadi/lib/libtinyxml2.a +0 -0
- casadi/lib/pkgconfig/tinyxml2.pc +0 -10
- casadi/libhighs.1.7.dylib +0 -0
- casadi/tools/structure.py +0 -1446
- {casadi-3.6.7.dist-info → casadi-3.7.1.dist-info}/WHEEL +0 -0
@@ -0,0 +1,395 @@
|
|
1
|
+
/*
|
2
|
+
* This file is part of CasADi.
|
3
|
+
*
|
4
|
+
* CasADi -- A symbolic framework for dynamic optimization.
|
5
|
+
* Copyright (C) 2010-2023 Joel Andersson, Joris Gillis, Moritz Diehl,
|
6
|
+
* KU Leuven. All rights reserved.
|
7
|
+
* Copyright (C) 2011-2014 Greg Horn
|
8
|
+
*
|
9
|
+
* CasADi is free software; you can redistribute it and/or
|
10
|
+
* modify it under the terms of the GNU Lesser General Public
|
11
|
+
* License as published by the Free Software Foundation; either
|
12
|
+
* version 3 of the License, or (at your option) any later version.
|
13
|
+
*
|
14
|
+
* CasADi is distributed in the hope that it will be useful,
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
+
* Lesser General Public License for more details.
|
18
|
+
*
|
19
|
+
* You should have received a copy of the GNU Lesser General Public
|
20
|
+
* License along with CasADi; if not, write to the Free Software
|
21
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
22
|
+
*
|
23
|
+
*/
|
24
|
+
|
25
|
+
|
26
|
+
#ifndef CASADI_GENERIC_SHARED_HPP
|
27
|
+
#define CASADI_GENERIC_SHARED_HPP
|
28
|
+
|
29
|
+
#include "casadi_common.hpp"
|
30
|
+
#include "exception.hpp"
|
31
|
+
#include <unordered_map>
|
32
|
+
#include <vector>
|
33
|
+
#include <cstdint>
|
34
|
+
#ifdef CASADI_WITH_THREAD
|
35
|
+
#ifdef CASADI_WITH_THREAD_MINGW
|
36
|
+
#include <mingw.mutex.h>
|
37
|
+
#else // CASADI_WITH_THREAD_MINGW
|
38
|
+
#include <mutex>
|
39
|
+
#endif // CASADI_WITH_THREAD_MINGW
|
40
|
+
#endif //CASADI_WITH_THREAD
|
41
|
+
|
42
|
+
#include <memory>
|
43
|
+
|
44
|
+
namespace casadi {
|
45
|
+
|
46
|
+
// Forward declaration of weak reference class
|
47
|
+
template<typename Shared, typename Internal>
|
48
|
+
class GenericWeakRef;
|
49
|
+
|
50
|
+
/// \cond INTERNAL
|
51
|
+
// Forward declaration of internal classes
|
52
|
+
template<typename Shared, typename Internal>
|
53
|
+
class GenericSharedInternal;
|
54
|
+
|
55
|
+
template<typename Shared, typename Internal>
|
56
|
+
class GenericWeakRefInternal;
|
57
|
+
/// \endcond
|
58
|
+
|
59
|
+
template<typename Shared, typename Internal>
|
60
|
+
class CASADI_EXPORT GenericShared {
|
61
|
+
#ifndef SWIG
|
62
|
+
template<class B, class S> friend B shared_cast(S& A);
|
63
|
+
template<class B, class S> friend const B shared_cast(const S& A);
|
64
|
+
#endif // SWIG
|
65
|
+
|
66
|
+
public:
|
67
|
+
#ifndef SWIG
|
68
|
+
/// Default constructor
|
69
|
+
GenericShared() {
|
70
|
+
node = nullptr;
|
71
|
+
}
|
72
|
+
|
73
|
+
/// Copy constructor (shallow copy)
|
74
|
+
GenericShared(const GenericShared& ref) {
|
75
|
+
node = ref.node;
|
76
|
+
count_up();
|
77
|
+
}
|
78
|
+
|
79
|
+
/// Destructor
|
80
|
+
~GenericShared() {
|
81
|
+
count_down();
|
82
|
+
}
|
83
|
+
|
84
|
+
/// Assignment operator
|
85
|
+
GenericShared& operator=(const GenericShared& ref);
|
86
|
+
|
87
|
+
/// \cond INTERNAL
|
88
|
+
/// Assign the node to a node class pointer (or null)
|
89
|
+
void own(Internal* node);
|
90
|
+
|
91
|
+
/** \brief Assign the node to a node class pointer without reference counting
|
92
|
+
*
|
93
|
+
* improper use will cause memory leaks!
|
94
|
+
|
95
|
+
\identifier{at} */
|
96
|
+
void assign(Internal* node);
|
97
|
+
|
98
|
+
/// Get a const pointer to the node
|
99
|
+
Internal* get() const;
|
100
|
+
|
101
|
+
/// Get the reference count
|
102
|
+
casadi_int getCount() const;
|
103
|
+
|
104
|
+
/// Swap content with another instance
|
105
|
+
void swap(GenericShared& other);
|
106
|
+
|
107
|
+
/// Access a member function or object
|
108
|
+
Internal* operator->() const;
|
109
|
+
/// \endcond
|
110
|
+
#endif // SWIG
|
111
|
+
|
112
|
+
std::string debug_repr() const;
|
113
|
+
|
114
|
+
|
115
|
+
/// Is a null pointer?
|
116
|
+
bool is_null() const;
|
117
|
+
|
118
|
+
/** \brief Returns a number that is unique for a given Node.
|
119
|
+
|
120
|
+
* If the Object does not point to any node, "0" is returned.
|
121
|
+
|
122
|
+
\identifier{av} */
|
123
|
+
casadi_int __hash__() const;
|
124
|
+
|
125
|
+
/// \cond INTERNAL
|
126
|
+
#ifndef SWIG
|
127
|
+
/** \brief Get a weak reference to the object
|
128
|
+
|
129
|
+
\identifier{aw} */
|
130
|
+
GenericWeakRef<Shared, Internal>* weak();
|
131
|
+
protected:
|
132
|
+
void count_up(); // increase counter of the node
|
133
|
+
void count_down(); // decrease counter of the node
|
134
|
+
private:
|
135
|
+
Internal *node;
|
136
|
+
#endif // SWIG
|
137
|
+
/// \endcond
|
138
|
+
};
|
139
|
+
|
140
|
+
template<typename Shared, typename Internal>
|
141
|
+
class CASADI_EXPORT GenericWeakRef : public GenericShared<Shared, Internal> {
|
142
|
+
public:
|
143
|
+
friend class GenericSharedInternal<Shared, Internal>;
|
144
|
+
|
145
|
+
using GenericShared<Shared, Internal>::is_null;
|
146
|
+
|
147
|
+
/** \brief Default constructor
|
148
|
+
|
149
|
+
\identifier{ay} */
|
150
|
+
GenericWeakRef(int dummy=0);
|
151
|
+
|
152
|
+
/** \brief Construct from a shared object (also implicit type conversion)
|
153
|
+
|
154
|
+
\identifier{az} */
|
155
|
+
GenericWeakRef(Shared shared);
|
156
|
+
|
157
|
+
/** \brief Get a shared (owning) reference
|
158
|
+
|
159
|
+
\identifier{b0} */
|
160
|
+
Shared shared() const;
|
161
|
+
|
162
|
+
/** \brief Check if alive
|
163
|
+
|
164
|
+
\identifier{b1} */
|
165
|
+
bool alive() const;
|
166
|
+
|
167
|
+
/** \brief Thread-safe alternative to alive()/shared()
|
168
|
+
|
169
|
+
\identifier{29i} */
|
170
|
+
bool shared_if_alive(Shared& shared) const;
|
171
|
+
|
172
|
+
/** \brief Access functions of the node
|
173
|
+
|
174
|
+
\identifier{b2} */
|
175
|
+
GenericWeakRefInternal<Shared, Internal>* operator->();
|
176
|
+
|
177
|
+
/** \brief Const access functions of the node
|
178
|
+
|
179
|
+
\identifier{b3} */
|
180
|
+
const GenericWeakRefInternal<Shared, Internal>* operator->() const;
|
181
|
+
|
182
|
+
#ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
|
183
|
+
std::shared_ptr<std::mutex> get_mutex() const;
|
184
|
+
#endif // CASADI_WITH_THREADSAFE_SYMBOLICS
|
185
|
+
|
186
|
+
#ifndef SWIG
|
187
|
+
private:
|
188
|
+
/** \brief Construct from a shared object (internal)
|
189
|
+
|
190
|
+
\identifier{b4} */
|
191
|
+
explicit GenericWeakRef(Internal* raw);
|
192
|
+
|
193
|
+
/** \brief The shared object has been deleted
|
194
|
+
|
195
|
+
\identifier{b5} */
|
196
|
+
void kill();
|
197
|
+
#endif // SWIG
|
198
|
+
};
|
199
|
+
|
200
|
+
#ifndef SWIG
|
201
|
+
|
202
|
+
/** \brief Typecast a shared object to a base class to a shared object to a derived class,
|
203
|
+
|
204
|
+
* cf. dynamic_cast
|
205
|
+
|
206
|
+
\identifier{b6} */
|
207
|
+
template<class B, class S>
|
208
|
+
B shared_cast(S& A) {
|
209
|
+
|
210
|
+
/// Get a pointer to the node
|
211
|
+
typename S::internal_base_type* ptr = A.get();
|
212
|
+
|
213
|
+
/// Create a return object
|
214
|
+
B ret;
|
215
|
+
|
216
|
+
/// Quick return if not allowed
|
217
|
+
if (!B::test_cast(ptr)) return ret;
|
218
|
+
|
219
|
+
/// Assign node of B and return
|
220
|
+
ret.own(ptr);
|
221
|
+
return ret;
|
222
|
+
}
|
223
|
+
|
224
|
+
/** \brief Typecast a shared object to a base class to a shared object to a derived class,
|
225
|
+
|
226
|
+
* cf. dynamic_cast (const)
|
227
|
+
|
228
|
+
\identifier{b7} */
|
229
|
+
template<class B, class S>
|
230
|
+
const B shared_cast(const S& A) {
|
231
|
+
S A_copy = A;
|
232
|
+
return shared_cast<B, S>(A_copy);
|
233
|
+
}
|
234
|
+
|
235
|
+
#endif // SWIG
|
236
|
+
|
237
|
+
/**
|
238
|
+
* Key is stored as a regular ref
|
239
|
+
* Value is stored as weakref
|
240
|
+
*/
|
241
|
+
template<typename K, typename T>
|
242
|
+
class CASADI_EXPORT WeakCache {
|
243
|
+
public:
|
244
|
+
void tocache(const K& key, const T& f, bool needs_lock=true) {
|
245
|
+
#ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
|
246
|
+
// Safe access to cache_
|
247
|
+
casadi::conditional_lock_guard<std::mutex> lock(mtx_, needs_lock);
|
248
|
+
#endif // CASADI_WITH_THREADSAFE_SYMBOLICS
|
249
|
+
// Add to cache
|
250
|
+
cache_.insert(std::make_pair(key, f));
|
251
|
+
// Remove a lost reference, if any, to prevent uncontrolled growth
|
252
|
+
for (auto it = cache_.begin(); it!=cache_.end(); ++it) {
|
253
|
+
if (!it->second.alive()) {
|
254
|
+
cache_.erase(it);
|
255
|
+
break; // just one dead reference is enough
|
256
|
+
}
|
257
|
+
}
|
258
|
+
}
|
259
|
+
/* \brief Thread-safe unique caching
|
260
|
+
* While an incache/tocache pair in multi-threaded context is safe
|
261
|
+
* it may lead to fresh cache entries being overwritten.
|
262
|
+
*
|
263
|
+
* A mutex lock_guard on the scope of an incache/tocache pair
|
264
|
+
* may lead to deadlocks.
|
265
|
+
*
|
266
|
+
*/
|
267
|
+
void tocache_if_missing(const K& key, T& f) {
|
268
|
+
#ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
|
269
|
+
// Safe access to cache_
|
270
|
+
std::lock_guard<std::mutex> lock(mtx_);
|
271
|
+
#endif // CASADI_WITH_THREADSAFE_SYMBOLICS
|
272
|
+
if (!incache(key, f, false)) {
|
273
|
+
tocache(key, f, false);
|
274
|
+
}
|
275
|
+
}
|
276
|
+
bool incache(const K& key, T& f, bool needs_lock=true) const {
|
277
|
+
#ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
|
278
|
+
// Safe access to cache_
|
279
|
+
casadi::conditional_lock_guard<std::mutex> lock(mtx_, needs_lock);
|
280
|
+
#endif // CASADI_WITH_THREADSAFE_SYMBOLICS
|
281
|
+
auto it = cache_.find(key);
|
282
|
+
typename T::base_type temp;
|
283
|
+
if (it!=cache_.end() && it->second.shared_if_alive(temp)) {
|
284
|
+
f = shared_cast<T>(temp);
|
285
|
+
return true;
|
286
|
+
} else {
|
287
|
+
return false;
|
288
|
+
}
|
289
|
+
}
|
290
|
+
void cache(std::vector<K>& keys, std::vector<T>& entries) const {
|
291
|
+
#ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
|
292
|
+
// Safe access to cache_
|
293
|
+
std::lock_guard<std::mutex> lock(mtx_);
|
294
|
+
#endif // CASADI_WITH_THREADSAFE_SYMBOLICS
|
295
|
+
keys.clear();
|
296
|
+
entries.clear();
|
297
|
+
// Add all entries that haven't been deleted
|
298
|
+
for (auto&& cf : cache_) {
|
299
|
+
typename T::base_type temp;
|
300
|
+
if (cf.second.shared_if_alive(temp)) {
|
301
|
+
keys.push_back(cf.first);
|
302
|
+
entries.push_back(shared_cast<T>(temp));
|
303
|
+
}
|
304
|
+
}
|
305
|
+
}
|
306
|
+
private:
|
307
|
+
std::unordered_map<K,
|
308
|
+
GenericWeakRef<typename T::base_type, typename T::internal_base_type>
|
309
|
+
> cache_;
|
310
|
+
#ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
|
311
|
+
mutable std::mutex mtx_;
|
312
|
+
#endif // CASADI_WITH_THREADSAFE_SYMBOLICS
|
313
|
+
};
|
314
|
+
|
315
|
+
// gcc-12 is overzealous about use-after-free warnings
|
316
|
+
// <12 or >12 works fine
|
317
|
+
#pragma GCC diagnostic push
|
318
|
+
#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ == 12)
|
319
|
+
#pragma GCC diagnostic ignored "-Wuse-after-free"
|
320
|
+
#endif
|
321
|
+
|
322
|
+
/**
|
323
|
+
* Key is stored as a weakref
|
324
|
+
* Value is stored as regular ref
|
325
|
+
*/
|
326
|
+
template<typename K, typename T>
|
327
|
+
class CASADI_EXPORT RevWeakCache {
|
328
|
+
public:
|
329
|
+
void tocache(const K& key, const T& f, bool needs_lock=true) {
|
330
|
+
#ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
|
331
|
+
// Safe access to cache_
|
332
|
+
casadi::conditional_lock_guard<std::mutex> lock(mtx_, needs_lock);
|
333
|
+
#endif // CASADI_WITH_THREADSAFE_SYMBOLICS
|
334
|
+
// Add to cache
|
335
|
+
const void* k = key.get();
|
336
|
+
pre_cache_.insert(std::make_pair(k, key));
|
337
|
+
cache_.insert(std::make_pair(k, f));
|
338
|
+
// Remove a lost reference, if any, to prevent uncontrolled growth
|
339
|
+
for (auto it = pre_cache_.begin(); it!=pre_cache_.end(); ++it) {
|
340
|
+
if (!it->second.alive()) {
|
341
|
+
pre_cache_.erase(it);
|
342
|
+
cache_.erase(it->first);
|
343
|
+
break; // just one dead reference is enough
|
344
|
+
}
|
345
|
+
}
|
346
|
+
}
|
347
|
+
/* \brief Thread-safe unique caching
|
348
|
+
* While an incache/tocache pair in multi-threaded context is safe
|
349
|
+
* it may lead to fresh cache entries being overwritten.
|
350
|
+
*
|
351
|
+
* A mutex lock_guard on the scope of an incache/tocache pair
|
352
|
+
* may lead to deadlocks.
|
353
|
+
*
|
354
|
+
*/
|
355
|
+
void tocache_if_missing(const K& key, T& f) {
|
356
|
+
#ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
|
357
|
+
// Safe access to cache_
|
358
|
+
std::lock_guard<std::mutex> lock(mtx_);
|
359
|
+
#endif // CASADI_WITH_THREADSAFE_SYMBOLICS
|
360
|
+
if (!incache(key, f, false)) {
|
361
|
+
tocache(key, f, false);
|
362
|
+
}
|
363
|
+
}
|
364
|
+
bool incache(const K& key, T& f, bool needs_lock=true) const {
|
365
|
+
#ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
|
366
|
+
// Safe access to cache_
|
367
|
+
casadi::conditional_lock_guard<std::mutex> lock(mtx_, needs_lock);
|
368
|
+
#endif // CASADI_WITH_THREADSAFE_SYMBOLICS
|
369
|
+
const void* k = key.get();
|
370
|
+
auto it = pre_cache_.find(k);
|
371
|
+
K temp;
|
372
|
+
if (it!=pre_cache_.end() && it->second.shared_if_alive(temp)) {
|
373
|
+
auto it2 = cache_.find(k);
|
374
|
+
f = it2->second;
|
375
|
+
return true;
|
376
|
+
} else {
|
377
|
+
return false;
|
378
|
+
}
|
379
|
+
}
|
380
|
+
private:
|
381
|
+
std::unordered_map<const void*,
|
382
|
+
GenericWeakRef<typename K::base_type, typename K::internal_base_type>
|
383
|
+
> pre_cache_;
|
384
|
+
std::unordered_map<const void*, T> cache_;
|
385
|
+
#ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
|
386
|
+
mutable std::mutex mtx_;
|
387
|
+
#endif // CASADI_WITH_THREADSAFE_SYMBOLICS
|
388
|
+
};
|
389
|
+
|
390
|
+
#pragma GCC diagnostic pop
|
391
|
+
|
392
|
+
} // namespace casadi
|
393
|
+
|
394
|
+
|
395
|
+
#endif // CASADI_GENERIC_SHARED_HPP
|
@@ -0,0 +1,218 @@
|
|
1
|
+
/*
|
2
|
+
* This file is part of CasADi.
|
3
|
+
*
|
4
|
+
* CasADi -- A symbolic framework for dynamic optimization.
|
5
|
+
* Copyright (C) 2010-2023 Joel Andersson, Joris Gillis, Moritz Diehl,
|
6
|
+
* KU Leuven. All rights reserved.
|
7
|
+
* Copyright (C) 2011-2014 Greg Horn
|
8
|
+
*
|
9
|
+
* CasADi is free software; you can redistribute it and/or
|
10
|
+
* modify it under the terms of the GNU Lesser General Public
|
11
|
+
* License as published by the Free Software Foundation; either
|
12
|
+
* version 3 of the License, or (at your option) any later version.
|
13
|
+
*
|
14
|
+
* CasADi is distributed in the hope that it will be useful,
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
+
* Lesser General Public License for more details.
|
18
|
+
*
|
19
|
+
* You should have received a copy of the GNU Lesser General Public
|
20
|
+
* License along with CasADi; if not, write to the Free Software
|
21
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
22
|
+
*
|
23
|
+
*/
|
24
|
+
|
25
|
+
|
26
|
+
#ifndef CASADI_GENERIC_SHARED_IMPL_HPP
|
27
|
+
#define CASADI_GENERIC_SHARED_IMPL_HPP
|
28
|
+
|
29
|
+
#ifdef WITH_EXTRA_CHECKS
|
30
|
+
#include "function.hpp"
|
31
|
+
#endif // WITH_EXTRA_CHECKS
|
32
|
+
|
33
|
+
namespace casadi {
|
34
|
+
|
35
|
+
template<typename Shared, typename Internal>
|
36
|
+
void GenericShared<Shared, Internal>::count_up() {
|
37
|
+
#ifdef WITH_EXTRA_CHECKS
|
38
|
+
casadi_assert_dev(Function::call_depth_==0);
|
39
|
+
#endif // WITH_EXTRA_CHECKS
|
40
|
+
|
41
|
+
if (node) static_cast<Internal*>(node)->count++;
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
template<typename Shared, typename Internal>
|
46
|
+
void GenericShared<Shared, Internal>::count_down() {
|
47
|
+
#ifdef WITH_EXTRA_CHECKS
|
48
|
+
casadi_assert_dev(Function::call_depth_==0);
|
49
|
+
#endif // WITH_EXTRA_CHECKS
|
50
|
+
if (!node) return;
|
51
|
+
if (node->weak_ref_) {
|
52
|
+
#ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
|
53
|
+
auto mutex = node->weak_ref_->get_mutex();
|
54
|
+
// Avoid triggering a delete while a weak_ref.shared_if_alive is being called
|
55
|
+
std::lock_guard<std::mutex> lock(*mutex);
|
56
|
+
// Could it be that this mutex is destroyed when the lock goes out of scope?
|
57
|
+
#endif // CASADI_WITH_THREADSAFE_SYMBOLICS
|
58
|
+
|
59
|
+
if (--static_cast<Internal*>(node)->count == 0) {
|
60
|
+
delete node;
|
61
|
+
node = nullptr;
|
62
|
+
}
|
63
|
+
} else {
|
64
|
+
if (--static_cast<Internal*>(node)->count == 0) {
|
65
|
+
delete node;
|
66
|
+
node = nullptr;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
template<typename Shared, typename Internal>
|
72
|
+
void GenericShared<Shared, Internal>::own(Internal* node_) {
|
73
|
+
count_down();
|
74
|
+
node = node_;
|
75
|
+
count_up();
|
76
|
+
}
|
77
|
+
|
78
|
+
template<typename Shared, typename Internal>
|
79
|
+
void GenericShared<Shared, Internal>::assign(Internal* node_) {
|
80
|
+
node = node_;
|
81
|
+
}
|
82
|
+
|
83
|
+
template<typename Shared, typename Internal>
|
84
|
+
std::string GenericShared<Shared, Internal>::debug_repr() const {
|
85
|
+
if (node) {
|
86
|
+
return node->debug_repr(node);
|
87
|
+
} else {
|
88
|
+
return "NULL";
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
template<typename Shared, typename Internal>
|
93
|
+
GenericShared<Shared, Internal>&
|
94
|
+
GenericShared<Shared, Internal>::operator=(const GenericShared& ref) {
|
95
|
+
// quick return if the old and new pointers point to the same object
|
96
|
+
if (node == ref.node) return *this;
|
97
|
+
|
98
|
+
// decrease the counter and delete if this was the last pointer
|
99
|
+
count_down();
|
100
|
+
|
101
|
+
// save the new pointer
|
102
|
+
node = ref.node;
|
103
|
+
count_up();
|
104
|
+
return *this;
|
105
|
+
}
|
106
|
+
|
107
|
+
template<typename Shared, typename Internal>
|
108
|
+
Internal* GenericShared<Shared, Internal>::get() const {
|
109
|
+
return node;
|
110
|
+
}
|
111
|
+
|
112
|
+
template<typename Shared, typename Internal>
|
113
|
+
bool GenericShared<Shared, Internal>::is_null() const {
|
114
|
+
return node==nullptr;
|
115
|
+
}
|
116
|
+
|
117
|
+
template<typename Shared, typename Internal>
|
118
|
+
Internal* GenericShared<Shared, Internal>::operator->() const {
|
119
|
+
casadi_assert_dev(!is_null());
|
120
|
+
return node;
|
121
|
+
}
|
122
|
+
|
123
|
+
template<typename Shared, typename Internal>
|
124
|
+
void GenericShared<Shared, Internal>::swap(GenericShared& other) {
|
125
|
+
GenericShared<Shared, Internal> temp = *this;
|
126
|
+
*this = other;
|
127
|
+
other = temp;
|
128
|
+
}
|
129
|
+
|
130
|
+
template<typename Shared, typename Internal>
|
131
|
+
casadi_int GenericShared<Shared, Internal>::getCount() const {
|
132
|
+
return (*this)->getCount();
|
133
|
+
}
|
134
|
+
|
135
|
+
template<typename Shared, typename Internal>
|
136
|
+
GenericWeakRef<Shared, Internal>* GenericShared<Shared, Internal>::weak() {
|
137
|
+
return (*this)->weak();
|
138
|
+
}
|
139
|
+
|
140
|
+
template<typename Shared, typename Internal>
|
141
|
+
casadi_int GenericShared<Shared, Internal>::__hash__() const {
|
142
|
+
return reinterpret_cast<casadi_int>(get());
|
143
|
+
}
|
144
|
+
|
145
|
+
template<typename Shared, typename Internal>
|
146
|
+
GenericWeakRef<Shared, Internal>::GenericWeakRef(int dummy) {
|
147
|
+
casadi_assert_dev(dummy==0);
|
148
|
+
}
|
149
|
+
|
150
|
+
template<typename Shared, typename Internal>
|
151
|
+
bool GenericWeakRef<Shared, Internal>::alive() const {
|
152
|
+
return !is_null() && (*this)->raw_ != nullptr;
|
153
|
+
}
|
154
|
+
|
155
|
+
template<typename Shared, typename Internal>
|
156
|
+
Shared GenericWeakRef<Shared, Internal>::shared() const {
|
157
|
+
Shared ret;
|
158
|
+
if (alive()) {
|
159
|
+
ret.own((*this)->raw_);
|
160
|
+
}
|
161
|
+
return ret;
|
162
|
+
}
|
163
|
+
|
164
|
+
template<typename Shared, typename Internal>
|
165
|
+
bool GenericWeakRef<Shared, Internal>::shared_if_alive(Shared& shared) const {
|
166
|
+
if (is_null()) return false;
|
167
|
+
#ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
|
168
|
+
// Safe access to ...
|
169
|
+
std::lock_guard<std::mutex> lock(*(*this)->mutex_);
|
170
|
+
#endif // CASADI_WITH_THREADSAFE_SYMBOLICS
|
171
|
+
if (alive()) {
|
172
|
+
shared.own((*this)->raw_);
|
173
|
+
return true;
|
174
|
+
}
|
175
|
+
return false;
|
176
|
+
}
|
177
|
+
|
178
|
+
template<typename Shared, typename Internal>
|
179
|
+
const GenericWeakRefInternal<Shared, Internal>*
|
180
|
+
GenericWeakRef<Shared, Internal>::operator->() const {
|
181
|
+
return static_cast<const GenericWeakRefInternal<Shared, Internal>*>(
|
182
|
+
GenericShared<Shared, Internal>::operator->());
|
183
|
+
}
|
184
|
+
|
185
|
+
template<typename Shared, typename Internal>
|
186
|
+
GenericWeakRefInternal<Shared, Internal>*
|
187
|
+
GenericWeakRef<Shared, Internal>::operator->() {
|
188
|
+
return static_cast<GenericWeakRefInternal<Shared, Internal>*>(
|
189
|
+
GenericShared<Shared, Internal>::operator->());
|
190
|
+
}
|
191
|
+
|
192
|
+
template<typename Shared, typename Internal>
|
193
|
+
GenericWeakRef<Shared, Internal>::GenericWeakRef(Shared shared) {
|
194
|
+
this->own(shared.weak()->get());
|
195
|
+
}
|
196
|
+
|
197
|
+
template<typename Shared, typename Internal>
|
198
|
+
GenericWeakRef<Shared, Internal>::GenericWeakRef(Internal* raw) {
|
199
|
+
this->own(new typename Internal::weak_ref_type(raw));
|
200
|
+
}
|
201
|
+
|
202
|
+
template<typename Shared, typename Internal>
|
203
|
+
void GenericWeakRef<Shared, Internal>::kill() {
|
204
|
+
casadi_assert_dev((*this)->raw_);
|
205
|
+
(*this)->raw_ = nullptr;
|
206
|
+
}
|
207
|
+
|
208
|
+
#ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
|
209
|
+
template<typename Shared, typename Internal>
|
210
|
+
std::shared_ptr<std::mutex> GenericWeakRef<Shared, Internal>::get_mutex() const {
|
211
|
+
return (*this)->mutex_;
|
212
|
+
}
|
213
|
+
#endif // CASADI_WITH_THREADSAFE_SYMBOLICS
|
214
|
+
|
215
|
+
} // namespace casadi
|
216
|
+
|
217
|
+
|
218
|
+
#endif // CASADI_GENERIC_SHARED_IMPL_HPP
|