casadi 3.6.5__cp311-none-win_amd64.whl → 3.6.7__cp311-none-win_amd64.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.pyd +0 -0
- casadi/bin/libtinyxml2.dll +0 -0
- casadi/blasfeo.lib +0 -0
- casadi/casadi-cli.exe +0 -0
- casadi/casadi.lib +0 -0
- casadi/casadi.py +739 -308
- casadi/cbc.exe +0 -0
- casadi/clp.exe +0 -0
- casadi/cmake/casadi-config-version.cmake +1 -1
- casadi/cmake/highs/highs-config.cmake +7 -14
- casadi/cmake/highs/highs-targets-release.cmake +13 -13
- casadi/cmake/highs/highs-targets.cmake +11 -9
- casadi/daqp.lib +0 -0
- casadi/fatrop.lib +0 -0
- casadi/highs.exe +0 -0
- casadi/highs.lib +0 -0
- casadi/hpipm.lib +0 -0
- casadi/include/casadi/casadi.i +3 -0
- casadi/include/casadi/casadi_c.h +2 -0
- casadi/include/casadi/config.h +8 -8
- casadi/include/casadi/core/casadi_common.hpp +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/dlfcn.h +94 -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 +6 -5
- 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 +42 -0
- casadi/include/licenses/daqp-external/LICENSE +21 -0
- casadi/include/licenses/fatrop-external/LICENSE.txt +165 -0
- casadi/include/licenses/fatrop-external/external/blasfeo/LICENSE.txt +26 -0
- casadi/include/licenses/fatrop-external/external/pybind11/LICENSE +29 -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 +2 -2
- casadi/ipopt.lib +0 -0
- casadi/lapack.lib +0 -0
- casadi/lib/libtinyxml2.dll.a +0 -0
- casadi/libCbc-3.dll +0 -0
- casadi/libCbc.dll.a +0 -0
- casadi/libCbcSolver-3.dll +0 -0
- casadi/libCbcSolver.dll.a +0 -0
- casadi/libCgl-1.dll +0 -0
- casadi/libCgl.dll.a +0 -0
- casadi/libClp-1.dll +0 -0
- casadi/libClp.dll.a +0 -0
- casadi/libClpSolver-1.dll +0 -0
- casadi/libClpSolver.dll.a +0 -0
- casadi/libCoinUtils-3.dll +0 -0
- casadi/libCoinUtils.dll.a +0 -0
- casadi/libOsi-1.dll +0 -0
- casadi/libOsi.dll.a +0 -0
- casadi/libOsiCbc-3.dll +0 -0
- casadi/libOsiCbc.dll.a +0 -0
- casadi/libOsiClp-1.dll +0 -0
- casadi/libOsiClp.dll.a +0 -0
- casadi/libOsiCommonTests-1.dll +0 -0
- casadi/libOsiCommonTests.dll.a +0 -0
- casadi/libalpaqa.dll +0 -0
- casadi/libalpaqa.dll.a +0 -0
- casadi/libblasfeo.dll +0 -0
- casadi/libblasfeo.dll.a +0 -0
- casadi/libbonmin-4.dll +0 -0
- casadi/libbonmin.dll.a +0 -0
- casadi/libcasadi-tp-openblas.dll +0 -0
- casadi/libcasadi-tp-openblas.dll.a +0 -0
- casadi/libcasadi.dll +0 -0
- casadi/libcasadi.dll.a +0 -0
- casadi/libcasadi_conic_cbc.dll +0 -0
- casadi/libcasadi_conic_cbc.dll.a +0 -0
- casadi/libcasadi_conic_clp.dll +0 -0
- casadi/libcasadi_conic_clp.dll.a +0 -0
- casadi/libcasadi_conic_cplex.dll +0 -0
- casadi/libcasadi_conic_cplex.dll.a +0 -0
- casadi/libcasadi_conic_daqp.dll +0 -0
- casadi/libcasadi_conic_daqp.dll.a +0 -0
- casadi/libcasadi_conic_fatrop.dll +0 -0
- casadi/libcasadi_conic_fatrop.dll.a +0 -0
- casadi/libcasadi_conic_gurobi.dll +0 -0
- casadi/libcasadi_conic_gurobi.dll.a +0 -0
- casadi/libcasadi_conic_highs.dll +0 -0
- casadi/libcasadi_conic_highs.dll.a +0 -0
- casadi/libcasadi_conic_hpipm.dll +0 -0
- casadi/libcasadi_conic_hpipm.dll.a +0 -0
- casadi/libcasadi_conic_ipqp.dll +0 -0
- casadi/libcasadi_conic_ipqp.dll.a +0 -0
- casadi/libcasadi_conic_nlpsol.dll +0 -0
- casadi/libcasadi_conic_nlpsol.dll.a +0 -0
- casadi/libcasadi_conic_osqp.dll +0 -0
- casadi/libcasadi_conic_osqp.dll.a +0 -0
- casadi/libcasadi_conic_proxqp.dll +0 -0
- casadi/libcasadi_conic_proxqp.dll.a +0 -0
- casadi/libcasadi_conic_qpoases.dll +0 -0
- casadi/libcasadi_conic_qpoases.dll.a +0 -0
- casadi/libcasadi_conic_qrqp.dll +0 -0
- casadi/libcasadi_conic_qrqp.dll.a +0 -0
- casadi/libcasadi_conic_superscs.dll +0 -0
- casadi/libcasadi_conic_superscs.dll.a +0 -0
- casadi/libcasadi_importer_shell.dll +0 -0
- casadi/libcasadi_importer_shell.dll.a +0 -0
- casadi/libcasadi_integrator_collocation.dll +0 -0
- casadi/libcasadi_integrator_collocation.dll.a +0 -0
- casadi/libcasadi_integrator_cvodes.dll +0 -0
- casadi/libcasadi_integrator_cvodes.dll.a +0 -0
- casadi/libcasadi_integrator_idas.dll +0 -0
- casadi/libcasadi_integrator_idas.dll.a +0 -0
- casadi/libcasadi_integrator_rk.dll +0 -0
- casadi/libcasadi_integrator_rk.dll.a +0 -0
- casadi/libcasadi_interpolant_bspline.dll +0 -0
- casadi/libcasadi_interpolant_bspline.dll.a +0 -0
- casadi/libcasadi_interpolant_linear.dll +0 -0
- casadi/libcasadi_interpolant_linear.dll.a +0 -0
- casadi/libcasadi_linsol_csparse.dll +0 -0
- casadi/libcasadi_linsol_csparse.dll.a +0 -0
- casadi/libcasadi_linsol_csparsecholesky.dll +0 -0
- casadi/libcasadi_linsol_csparsecholesky.dll.a +0 -0
- casadi/libcasadi_linsol_lapacklu.dll +0 -0
- casadi/libcasadi_linsol_lapacklu.dll.a +0 -0
- casadi/libcasadi_linsol_lapackqr.dll +0 -0
- casadi/libcasadi_linsol_lapackqr.dll.a +0 -0
- casadi/libcasadi_linsol_ldl.dll +0 -0
- casadi/libcasadi_linsol_ldl.dll.a +0 -0
- casadi/libcasadi_linsol_lsqr.dll +0 -0
- casadi/libcasadi_linsol_lsqr.dll.a +0 -0
- casadi/libcasadi_linsol_ma27.dll +0 -0
- casadi/libcasadi_linsol_ma27.dll.a +0 -0
- casadi/libcasadi_linsol_mumps.dll +0 -0
- casadi/libcasadi_linsol_mumps.dll.a +0 -0
- casadi/libcasadi_linsol_qr.dll +0 -0
- casadi/libcasadi_linsol_qr.dll.a +0 -0
- casadi/libcasadi_linsol_symbolicqr.dll +0 -0
- casadi/libcasadi_linsol_symbolicqr.dll.a +0 -0
- casadi/libcasadi_linsol_tridiag.dll +0 -0
- casadi/libcasadi_linsol_tridiag.dll.a +0 -0
- casadi/libcasadi_nlpsol_alpaqa.dll +0 -0
- casadi/libcasadi_nlpsol_alpaqa.dll.a +0 -0
- casadi/libcasadi_nlpsol_ampl.dll +0 -0
- casadi/libcasadi_nlpsol_ampl.dll.a +0 -0
- casadi/libcasadi_nlpsol_blocksqp.dll +0 -0
- casadi/libcasadi_nlpsol_blocksqp.dll.a +0 -0
- casadi/libcasadi_nlpsol_bonmin.dll +0 -0
- casadi/libcasadi_nlpsol_bonmin.dll.a +0 -0
- casadi/libcasadi_nlpsol_fatrop.dll +0 -0
- casadi/libcasadi_nlpsol_fatrop.dll.a +0 -0
- casadi/libcasadi_nlpsol_feasiblesqpmethod.dll +0 -0
- casadi/libcasadi_nlpsol_feasiblesqpmethod.dll.a +0 -0
- casadi/libcasadi_nlpsol_ipopt.dll +0 -0
- casadi/libcasadi_nlpsol_ipopt.dll.a +0 -0
- casadi/libcasadi_nlpsol_knitro.dll +0 -0
- casadi/libcasadi_nlpsol_knitro.dll.a +0 -0
- casadi/libcasadi_nlpsol_madnlp.dll +0 -0
- casadi/libcasadi_nlpsol_madnlp.dll.a +0 -0
- casadi/libcasadi_nlpsol_qrsqp.dll +0 -0
- casadi/libcasadi_nlpsol_qrsqp.dll.a +0 -0
- casadi/libcasadi_nlpsol_scpgen.dll +0 -0
- casadi/libcasadi_nlpsol_scpgen.dll.a +0 -0
- casadi/libcasadi_nlpsol_sleqp.dll +0 -0
- casadi/libcasadi_nlpsol_sleqp.dll.a +0 -0
- casadi/libcasadi_nlpsol_snopt.dll +0 -0
- casadi/libcasadi_nlpsol_snopt.dll.a +0 -0
- casadi/libcasadi_nlpsol_sqpmethod.dll +0 -0
- casadi/libcasadi_nlpsol_sqpmethod.dll.a +0 -0
- casadi/libcasadi_nlpsol_worhp.dll +0 -0
- casadi/libcasadi_nlpsol_worhp.dll.a +0 -0
- casadi/libcasadi_rootfinder_fast_newton.dll +0 -0
- casadi/libcasadi_rootfinder_fast_newton.dll.a +0 -0
- casadi/libcasadi_rootfinder_kinsol.dll +0 -0
- casadi/libcasadi_rootfinder_kinsol.dll.a +0 -0
- casadi/libcasadi_rootfinder_newton.dll +0 -0
- casadi/libcasadi_rootfinder_newton.dll.a +0 -0
- casadi/libcasadi_rootfinder_nlpsol.dll +0 -0
- casadi/libcasadi_rootfinder_nlpsol.dll.a +0 -0
- casadi/libcasadi_sundials_common.dll +0 -0
- casadi/libcasadi_sundials_common.dll.a +0 -0
- casadi/libcasadi_xmlfile_tinyxml.dll +0 -0
- casadi/libcasadi_xmlfile_tinyxml.dll.a +0 -0
- casadi/libcoinmetis-2.dll +0 -0
- casadi/libcoinmetis.dll.a +0 -0
- casadi/libcoinmetis.la +1 -1
- casadi/libcoinmumps-3.dll +0 -0
- casadi/libcoinmumps.dll.a +0 -0
- casadi/libcplex_adaptor.dll +0 -0
- casadi/libdaqp.dll +0 -0
- casadi/libdaqp.dll.a +0 -0
- casadi/libdaqpstat.a +0 -0
- casadi/{libFortranHighs.dll → libdl.dll} +0 -0
- casadi/libdl.dll.a +0 -0
- casadi/libfatrop.dll +0 -0
- casadi/libfatrop.dll.a +0 -0
- casadi/libgurobi_adaptor.dll +0 -0
- casadi/libhighs.dll +0 -0
- casadi/libhighs.dll.a +0 -0
- casadi/libhpipm.dll +0 -0
- casadi/libhpipm.dll.a +0 -0
- casadi/libipopt-3.dll +0 -0
- casadi/libipopt.dll.a +0 -0
- casadi/libmatlab_ipc.dll +0 -0
- casadi/libmatlab_ipc.dll.a +0 -0
- casadi/libosqp.a +0 -0
- casadi/libosqp.dll +0 -0
- casadi/libosqp.dll.a +0 -0
- casadi/libqdldl.dll +0 -0
- casadi/libqdldl.dll.a +0 -0
- casadi/libsipopt-3.dll +0 -0
- casadi/libsipopt.dll.a +0 -0
- casadi/libsleqp.dll +0 -0
- casadi/libsleqp.dll.a +0 -0
- casadi/libtinyxml2.dll +0 -0
- casadi/libtrlib.dll +0 -0
- casadi/libtrlib.dll.a +0 -0
- casadi/matlab_ipc.lib +0 -0
- casadi/osqp.lib +0 -0
- casadi/pkgconfig/casadi.pc +1 -1
- casadi/pkgconfig/highs.pc +1 -1
- casadi/sleqp.lib +0 -0
- casadi/spral_ssids.exe +0 -0
- 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 +503 -325
- casadi/include/highs/fortran/highs_fortran_api.mod +0 -0
- casadi/libFortranHighs.dll.a +0 -0
- {casadi-3.6.5.dist-info → casadi-3.6.7.dist-info}/WHEEL +0 -0
@@ -0,0 +1,237 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <cassert>
|
4
|
+
#include <fstream>
|
5
|
+
#include <cstring>
|
6
|
+
#include <string>
|
7
|
+
#include <vector>
|
8
|
+
|
9
|
+
/**
|
10
|
+
* This namespace defines wrappers for std::ifstream, std::ofstream, and
|
11
|
+
* std::fstream objects. The wrappers perform the following steps:
|
12
|
+
* - check the open modes make sense
|
13
|
+
* - check that the call to open() is successful
|
14
|
+
* - (for input streams) check that the opened file is peek-able
|
15
|
+
* - turn on the badbit in the exception mask
|
16
|
+
*/
|
17
|
+
namespace strict_fstream
|
18
|
+
{
|
19
|
+
|
20
|
+
// Help people out a bit, it seems like this is a common recommendation since
|
21
|
+
// musl breaks all over the place.
|
22
|
+
#if defined(__NEED_size_t) && !defined(__MUSL__)
|
23
|
+
#warning "It seems to be recommended to patch in a define for __MUSL__ if you use musl globally: https://www.openwall.com/lists/musl/2013/02/10/5"
|
24
|
+
#define __MUSL__
|
25
|
+
#endif
|
26
|
+
|
27
|
+
// Workaround for broken musl implementation
|
28
|
+
// Since musl insists that they are perfectly compatible, ironically enough,
|
29
|
+
// they don't officially have a __musl__ or similar. But __NEED_size_t is defined in their
|
30
|
+
// relevant header (and not in working implementations), so we can use that.
|
31
|
+
#ifdef __MUSL__
|
32
|
+
#warning "Working around broken strerror_r() implementation in musl, remove when musl is fixed"
|
33
|
+
#endif
|
34
|
+
|
35
|
+
// Non-gnu variants of strerror_* don't necessarily null-terminate if
|
36
|
+
// truncating, so we have to do things manually.
|
37
|
+
inline std::string trim_to_null(const std::vector<char> &buff)
|
38
|
+
{
|
39
|
+
std::string ret(buff.begin(), buff.end());
|
40
|
+
|
41
|
+
const std::string::size_type pos = ret.find('\0');
|
42
|
+
if (pos == std::string::npos) {
|
43
|
+
ret += " [...]"; // it has been truncated
|
44
|
+
} else {
|
45
|
+
ret.resize(pos);
|
46
|
+
}
|
47
|
+
return ret;
|
48
|
+
}
|
49
|
+
|
50
|
+
/// Overload of error-reporting function, to enable use with VS and non-GNU
|
51
|
+
/// POSIX libc's
|
52
|
+
/// Ref:
|
53
|
+
/// - http://stackoverflow.com/a/901316/717706
|
54
|
+
static std::string strerror()
|
55
|
+
{
|
56
|
+
// Can't use std::string since we're pre-C++17
|
57
|
+
std::vector<char> buff(256, '\0');
|
58
|
+
|
59
|
+
#ifdef _WIN32
|
60
|
+
// Since strerror_s might set errno itself, we need to store it.
|
61
|
+
const int err_num = errno;
|
62
|
+
if (strerror_s(buff.data(), buff.size(), err_num) != 0) {
|
63
|
+
return trim_to_null(buff);
|
64
|
+
} else {
|
65
|
+
return "Unknown error (" + std::to_string(err_num) + ")";
|
66
|
+
}
|
67
|
+
#elif ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)) && ! _GNU_SOURCE) || defined(__MUSL__)
|
68
|
+
// XSI-compliant strerror_r()
|
69
|
+
const int err_num = errno; // See above
|
70
|
+
if (strerror_r(err_num, buff.data(), buff.size()) == 0) {
|
71
|
+
return trim_to_null(buff);
|
72
|
+
} else {
|
73
|
+
return "Unknown error (" + std::to_string(err_num) + ")";
|
74
|
+
}
|
75
|
+
#else
|
76
|
+
// GNU-specific strerror_r()
|
77
|
+
char * p = strerror_r(errno, &buff[0], buff.size());
|
78
|
+
return std::string(p, std::strlen(p));
|
79
|
+
#endif
|
80
|
+
}
|
81
|
+
|
82
|
+
/// Exception class thrown by failed operations.
|
83
|
+
class Exception
|
84
|
+
: public std::exception
|
85
|
+
{
|
86
|
+
public:
|
87
|
+
Exception(const std::string& msg) : _msg(msg) {}
|
88
|
+
const char * what() const noexcept { return _msg.c_str(); }
|
89
|
+
private:
|
90
|
+
std::string _msg;
|
91
|
+
}; // class Exception
|
92
|
+
|
93
|
+
namespace detail
|
94
|
+
{
|
95
|
+
|
96
|
+
struct static_method_holder
|
97
|
+
{
|
98
|
+
static std::string mode_to_string(std::ios_base::openmode mode)
|
99
|
+
{
|
100
|
+
static const int n_modes = 6;
|
101
|
+
static const std::ios_base::openmode mode_val_v[n_modes] =
|
102
|
+
{
|
103
|
+
std::ios_base::in,
|
104
|
+
std::ios_base::out,
|
105
|
+
std::ios_base::app,
|
106
|
+
std::ios_base::ate,
|
107
|
+
std::ios_base::trunc,
|
108
|
+
std::ios_base::binary
|
109
|
+
};
|
110
|
+
|
111
|
+
static const char * mode_name_v[n_modes] =
|
112
|
+
{
|
113
|
+
"in",
|
114
|
+
"out",
|
115
|
+
"app",
|
116
|
+
"ate",
|
117
|
+
"trunc",
|
118
|
+
"binary"
|
119
|
+
};
|
120
|
+
std::string res;
|
121
|
+
for (int i = 0; i < n_modes; ++i)
|
122
|
+
{
|
123
|
+
if (mode & mode_val_v[i])
|
124
|
+
{
|
125
|
+
res += (! res.empty()? "|" : "");
|
126
|
+
res += mode_name_v[i];
|
127
|
+
}
|
128
|
+
}
|
129
|
+
if (res.empty()) res = "none";
|
130
|
+
return res;
|
131
|
+
}
|
132
|
+
static void check_mode(const std::string& filename, std::ios_base::openmode mode)
|
133
|
+
{
|
134
|
+
if ((mode & std::ios_base::trunc) && ! (mode & std::ios_base::out))
|
135
|
+
{
|
136
|
+
throw Exception(std::string("strict_fstream: open('") + filename + "'): mode error: trunc and not out");
|
137
|
+
}
|
138
|
+
else if ((mode & std::ios_base::app) && ! (mode & std::ios_base::out))
|
139
|
+
{
|
140
|
+
throw Exception(std::string("strict_fstream: open('") + filename + "'): mode error: app and not out");
|
141
|
+
}
|
142
|
+
else if ((mode & std::ios_base::trunc) && (mode & std::ios_base::app))
|
143
|
+
{
|
144
|
+
throw Exception(std::string("strict_fstream: open('") + filename + "'): mode error: trunc and app");
|
145
|
+
}
|
146
|
+
}
|
147
|
+
static void check_open(std::ios * s_p, const std::string& filename, std::ios_base::openmode mode)
|
148
|
+
{
|
149
|
+
if (s_p->fail())
|
150
|
+
{
|
151
|
+
throw Exception(std::string("strict_fstream: open('")
|
152
|
+
+ filename + "'," + mode_to_string(mode) + "): open failed: "
|
153
|
+
+ strerror());
|
154
|
+
}
|
155
|
+
}
|
156
|
+
static void check_peek(std::istream * is_p, const std::string& filename, std::ios_base::openmode mode)
|
157
|
+
{
|
158
|
+
bool peek_failed = true;
|
159
|
+
try
|
160
|
+
{
|
161
|
+
is_p->peek();
|
162
|
+
peek_failed = is_p->fail();
|
163
|
+
}
|
164
|
+
catch (const std::ios_base::failure &) {}
|
165
|
+
if (peek_failed)
|
166
|
+
{
|
167
|
+
throw Exception(std::string("strict_fstream: open('")
|
168
|
+
+ filename + "'," + mode_to_string(mode) + "): peek failed: "
|
169
|
+
+ strerror());
|
170
|
+
}
|
171
|
+
is_p->clear();
|
172
|
+
}
|
173
|
+
}; // struct static_method_holder
|
174
|
+
|
175
|
+
} // namespace detail
|
176
|
+
|
177
|
+
class ifstream
|
178
|
+
: public std::ifstream
|
179
|
+
{
|
180
|
+
public:
|
181
|
+
ifstream() = default;
|
182
|
+
ifstream(const std::string& filename, std::ios_base::openmode mode = std::ios_base::in)
|
183
|
+
{
|
184
|
+
open(filename, mode);
|
185
|
+
}
|
186
|
+
void open(const std::string& filename, std::ios_base::openmode mode = std::ios_base::in)
|
187
|
+
{
|
188
|
+
mode |= std::ios_base::in;
|
189
|
+
exceptions(std::ios_base::badbit);
|
190
|
+
detail::static_method_holder::check_mode(filename, mode);
|
191
|
+
std::ifstream::open(filename, mode);
|
192
|
+
detail::static_method_holder::check_open(this, filename, mode);
|
193
|
+
detail::static_method_holder::check_peek(this, filename, mode);
|
194
|
+
}
|
195
|
+
}; // class ifstream
|
196
|
+
|
197
|
+
class ofstream
|
198
|
+
: public std::ofstream
|
199
|
+
{
|
200
|
+
public:
|
201
|
+
ofstream() = default;
|
202
|
+
ofstream(const std::string& filename, std::ios_base::openmode mode = std::ios_base::out)
|
203
|
+
{
|
204
|
+
open(filename, mode);
|
205
|
+
}
|
206
|
+
void open(const std::string& filename, std::ios_base::openmode mode = std::ios_base::out)
|
207
|
+
{
|
208
|
+
mode |= std::ios_base::out;
|
209
|
+
exceptions(std::ios_base::badbit);
|
210
|
+
detail::static_method_holder::check_mode(filename, mode);
|
211
|
+
std::ofstream::open(filename, mode);
|
212
|
+
detail::static_method_holder::check_open(this, filename, mode);
|
213
|
+
}
|
214
|
+
}; // class ofstream
|
215
|
+
|
216
|
+
class fstream
|
217
|
+
: public std::fstream
|
218
|
+
{
|
219
|
+
public:
|
220
|
+
fstream() = default;
|
221
|
+
fstream(const std::string& filename, std::ios_base::openmode mode = std::ios_base::in)
|
222
|
+
{
|
223
|
+
open(filename, mode);
|
224
|
+
}
|
225
|
+
void open(const std::string& filename, std::ios_base::openmode mode = std::ios_base::in)
|
226
|
+
{
|
227
|
+
if (! (mode & std::ios_base::out)) mode |= std::ios_base::in;
|
228
|
+
exceptions(std::ios_base::badbit);
|
229
|
+
detail::static_method_holder::check_mode(filename, mode);
|
230
|
+
std::fstream::open(filename, mode);
|
231
|
+
detail::static_method_holder::check_open(this, filename, mode);
|
232
|
+
detail::static_method_holder::check_peek(this, filename, mode);
|
233
|
+
}
|
234
|
+
}; // class fstream
|
235
|
+
|
236
|
+
} // namespace strict_fstream
|
237
|
+
|
@@ -0,0 +1,472 @@
|
|
1
|
+
//---------------------------------------------------------
|
2
|
+
// Copyright 2015 Ontario Institute for Cancer Research
|
3
|
+
// Written by Matei David (matei@cs.toronto.edu)
|
4
|
+
//---------------------------------------------------------
|
5
|
+
|
6
|
+
// Reference:
|
7
|
+
// http://stackoverflow.com/questions/14086417/how-to-write-custom-input-stream-in-c
|
8
|
+
|
9
|
+
#pragma once
|
10
|
+
|
11
|
+
#include <zlib.h>
|
12
|
+
|
13
|
+
#include <cassert>
|
14
|
+
#include <fstream>
|
15
|
+
#include <iostream>
|
16
|
+
#include <memory>
|
17
|
+
#include <sstream>
|
18
|
+
|
19
|
+
#include "../extern/zstr/strict_fstream.hpp"
|
20
|
+
|
21
|
+
namespace zstr {
|
22
|
+
|
23
|
+
static const std::size_t default_buff_size = static_cast<std::size_t>(1 << 20);
|
24
|
+
|
25
|
+
/// Exception class thrown by failed zlib operations.
|
26
|
+
class Exception : public std::ios_base::failure {
|
27
|
+
public:
|
28
|
+
static std::string error_to_message(z_stream* zstrm_p, int ret) {
|
29
|
+
std::string msg = "zlib: ";
|
30
|
+
switch (ret) {
|
31
|
+
case Z_STREAM_ERROR:
|
32
|
+
msg += "Z_STREAM_ERROR: ";
|
33
|
+
break;
|
34
|
+
case Z_DATA_ERROR:
|
35
|
+
msg += "Z_DATA_ERROR: ";
|
36
|
+
break;
|
37
|
+
case Z_MEM_ERROR:
|
38
|
+
msg += "Z_MEM_ERROR: ";
|
39
|
+
break;
|
40
|
+
case Z_VERSION_ERROR:
|
41
|
+
msg += "Z_VERSION_ERROR: ";
|
42
|
+
break;
|
43
|
+
case Z_BUF_ERROR:
|
44
|
+
msg += "Z_BUF_ERROR: ";
|
45
|
+
break;
|
46
|
+
default:
|
47
|
+
std::ostringstream oss;
|
48
|
+
oss << ret;
|
49
|
+
msg += "[" + oss.str() + "]: ";
|
50
|
+
break;
|
51
|
+
}
|
52
|
+
if (zstrm_p->msg) {
|
53
|
+
msg += zstrm_p->msg;
|
54
|
+
}
|
55
|
+
msg +=
|
56
|
+
" ("
|
57
|
+
"next_in: " +
|
58
|
+
std::to_string(uintptr_t(zstrm_p->next_in)) +
|
59
|
+
", avail_in: " + std::to_string(uintptr_t(zstrm_p->avail_in)) +
|
60
|
+
", next_out: " + std::to_string(uintptr_t(zstrm_p->next_out)) +
|
61
|
+
", avail_out: " + std::to_string(uintptr_t(zstrm_p->avail_out)) + ")";
|
62
|
+
return msg;
|
63
|
+
}
|
64
|
+
|
65
|
+
Exception(z_stream* zstrm_p, int ret)
|
66
|
+
: std::ios_base::failure(error_to_message(zstrm_p, ret)) {}
|
67
|
+
}; // class Exception
|
68
|
+
|
69
|
+
namespace detail {
|
70
|
+
|
71
|
+
class z_stream_wrapper : public z_stream {
|
72
|
+
public:
|
73
|
+
z_stream_wrapper(bool _is_input, int _level, int _window_bits)
|
74
|
+
: is_input(_is_input) {
|
75
|
+
this->zalloc = nullptr; // Z_NULL
|
76
|
+
this->zfree = nullptr; // Z_NULL
|
77
|
+
this->opaque = nullptr; // Z_NULL
|
78
|
+
int ret;
|
79
|
+
if (is_input) {
|
80
|
+
this->avail_in = 0;
|
81
|
+
this->next_in = nullptr; // Z_NULL
|
82
|
+
ret = inflateInit2(this, _window_bits ? _window_bits : 15 + 32);
|
83
|
+
} else {
|
84
|
+
ret = deflateInit2(this, _level, Z_DEFLATED,
|
85
|
+
_window_bits ? _window_bits : 15 + 16, 8,
|
86
|
+
Z_DEFAULT_STRATEGY);
|
87
|
+
}
|
88
|
+
if (ret != Z_OK) throw Exception(this, ret);
|
89
|
+
}
|
90
|
+
~z_stream_wrapper() {
|
91
|
+
if (is_input) {
|
92
|
+
inflateEnd(this);
|
93
|
+
} else {
|
94
|
+
deflateEnd(this);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
private:
|
99
|
+
bool is_input;
|
100
|
+
}; // class z_stream_wrapper
|
101
|
+
|
102
|
+
} // namespace detail
|
103
|
+
|
104
|
+
class istreambuf : public std::streambuf {
|
105
|
+
public:
|
106
|
+
istreambuf(std::streambuf* _sbuf_p,
|
107
|
+
std::size_t _buff_size = default_buff_size,
|
108
|
+
bool _auto_detect = true, int _window_bits = 0)
|
109
|
+
: sbuf_p(_sbuf_p),
|
110
|
+
in_buff(),
|
111
|
+
in_buff_start(nullptr),
|
112
|
+
in_buff_end(nullptr),
|
113
|
+
out_buff(),
|
114
|
+
zstrm_p(nullptr),
|
115
|
+
buff_size(_buff_size),
|
116
|
+
auto_detect(_auto_detect),
|
117
|
+
auto_detect_run(false),
|
118
|
+
is_text(false),
|
119
|
+
window_bits(_window_bits) {
|
120
|
+
assert(sbuf_p);
|
121
|
+
in_buff = std::unique_ptr<char[]>(new char[buff_size]);
|
122
|
+
in_buff_start = in_buff.get();
|
123
|
+
in_buff_end = in_buff.get();
|
124
|
+
out_buff = std::unique_ptr<char[]>(new char[buff_size]);
|
125
|
+
setg(out_buff.get(), out_buff.get(), out_buff.get());
|
126
|
+
}
|
127
|
+
|
128
|
+
istreambuf(const istreambuf&) = delete;
|
129
|
+
istreambuf& operator=(const istreambuf&) = delete;
|
130
|
+
|
131
|
+
pos_type seekoff(off_type off, std::ios_base::seekdir dir,
|
132
|
+
std::ios_base::openmode which) override {
|
133
|
+
if (off != 0 || dir != std::ios_base::cur) {
|
134
|
+
return std::streambuf::seekoff(off, dir, which);
|
135
|
+
}
|
136
|
+
|
137
|
+
if (!zstrm_p) {
|
138
|
+
return 0;
|
139
|
+
}
|
140
|
+
|
141
|
+
return static_cast<long int>(zstrm_p->total_out -
|
142
|
+
static_cast<uLong>(in_avail()));
|
143
|
+
}
|
144
|
+
|
145
|
+
std::streambuf::int_type underflow() override {
|
146
|
+
if (this->gptr() == this->egptr()) {
|
147
|
+
// pointers for free region in output buffer
|
148
|
+
char* out_buff_free_start = out_buff.get();
|
149
|
+
int tries = 0;
|
150
|
+
do {
|
151
|
+
if (++tries > 1000) {
|
152
|
+
throw std::ios_base::failure(
|
153
|
+
"Failed to fill buffer after 1000 tries");
|
154
|
+
}
|
155
|
+
|
156
|
+
// read more input if none available
|
157
|
+
if (in_buff_start == in_buff_end) {
|
158
|
+
// empty input buffer: refill from the start
|
159
|
+
in_buff_start = in_buff.get();
|
160
|
+
std::streamsize sz = sbuf_p->sgetn(
|
161
|
+
in_buff.get(), static_cast<std::streamsize>(buff_size));
|
162
|
+
in_buff_end = in_buff_start + sz;
|
163
|
+
if (in_buff_end == in_buff_start) break; // end of input
|
164
|
+
}
|
165
|
+
// auto detect if the stream contains text or deflate data
|
166
|
+
if (auto_detect && !auto_detect_run) {
|
167
|
+
auto_detect_run = true;
|
168
|
+
unsigned char b0 = *reinterpret_cast<unsigned char*>(in_buff_start);
|
169
|
+
unsigned char b1 =
|
170
|
+
*reinterpret_cast<unsigned char*>(in_buff_start + 1);
|
171
|
+
// Ref:
|
172
|
+
// http://en.wikipedia.org/wiki/Gzip
|
173
|
+
// http://stackoverflow.com/questions/9050260/what-does-a-zlib-header-look-like
|
174
|
+
is_text = !(in_buff_start + 2 <= in_buff_end &&
|
175
|
+
((b0 == 0x1F && b1 == 0x8B) // gzip header
|
176
|
+
|| (b0 == 0x78 && (b1 == 0x01 // zlib header
|
177
|
+
|| b1 == 0x9C || b1 == 0xDA))));
|
178
|
+
}
|
179
|
+
if (is_text) {
|
180
|
+
// simply swap in_buff and out_buff, and adjust pointers
|
181
|
+
assert(in_buff_start == in_buff.get());
|
182
|
+
std::swap(in_buff, out_buff);
|
183
|
+
out_buff_free_start = in_buff_end;
|
184
|
+
in_buff_start = in_buff.get();
|
185
|
+
in_buff_end = in_buff.get();
|
186
|
+
} else {
|
187
|
+
// run inflate() on input
|
188
|
+
if (!zstrm_p)
|
189
|
+
zstrm_p = std::unique_ptr<detail::z_stream_wrapper>(
|
190
|
+
new detail::z_stream_wrapper(true, Z_DEFAULT_COMPRESSION,
|
191
|
+
window_bits));
|
192
|
+
zstrm_p->next_in =
|
193
|
+
reinterpret_cast<decltype(zstrm_p->next_in)>(in_buff_start);
|
194
|
+
zstrm_p->avail_in = uint32_t(in_buff_end - in_buff_start);
|
195
|
+
zstrm_p->next_out = reinterpret_cast<decltype(zstrm_p->next_out)>(
|
196
|
+
out_buff_free_start);
|
197
|
+
zstrm_p->avail_out =
|
198
|
+
uint32_t((out_buff.get() + buff_size) - out_buff_free_start);
|
199
|
+
int ret = inflate(zstrm_p.get(), Z_NO_FLUSH);
|
200
|
+
// process return code
|
201
|
+
if (ret != Z_OK && ret != Z_STREAM_END)
|
202
|
+
throw Exception(zstrm_p.get(), ret);
|
203
|
+
// update in&out pointers following inflate()
|
204
|
+
in_buff_start =
|
205
|
+
reinterpret_cast<decltype(in_buff_start)>(zstrm_p->next_in);
|
206
|
+
in_buff_end = in_buff_start + zstrm_p->avail_in;
|
207
|
+
out_buff_free_start = reinterpret_cast<decltype(out_buff_free_start)>(
|
208
|
+
zstrm_p->next_out);
|
209
|
+
assert(out_buff_free_start + zstrm_p->avail_out ==
|
210
|
+
out_buff.get() + buff_size);
|
211
|
+
|
212
|
+
if (ret == Z_STREAM_END) {
|
213
|
+
// if stream ended, deallocate inflator
|
214
|
+
zstrm_p.reset();
|
215
|
+
}
|
216
|
+
}
|
217
|
+
} while (out_buff_free_start == out_buff.get());
|
218
|
+
// 2 exit conditions:
|
219
|
+
// - end of input: there might or might not be output available
|
220
|
+
// - out_buff_free_start != out_buff: output available
|
221
|
+
this->setg(out_buff.get(), out_buff.get(), out_buff_free_start);
|
222
|
+
}
|
223
|
+
return this->gptr() == this->egptr()
|
224
|
+
? traits_type::eof()
|
225
|
+
: traits_type::to_int_type(*this->gptr());
|
226
|
+
}
|
227
|
+
|
228
|
+
private:
|
229
|
+
std::streambuf* sbuf_p;
|
230
|
+
std::unique_ptr<char[]> in_buff;
|
231
|
+
char* in_buff_start;
|
232
|
+
char* in_buff_end;
|
233
|
+
std::unique_ptr<char[]> out_buff;
|
234
|
+
std::unique_ptr<detail::z_stream_wrapper> zstrm_p;
|
235
|
+
std::size_t buff_size;
|
236
|
+
bool auto_detect;
|
237
|
+
bool auto_detect_run;
|
238
|
+
bool is_text;
|
239
|
+
int window_bits;
|
240
|
+
|
241
|
+
}; // class istreambuf
|
242
|
+
|
243
|
+
class ostreambuf : public std::streambuf {
|
244
|
+
public:
|
245
|
+
ostreambuf(std::streambuf* _sbuf_p,
|
246
|
+
std::size_t _buff_size = default_buff_size,
|
247
|
+
int _level = Z_DEFAULT_COMPRESSION, int _window_bits = 0)
|
248
|
+
: sbuf_p(_sbuf_p),
|
249
|
+
in_buff(),
|
250
|
+
out_buff(),
|
251
|
+
zstrm_p(new detail::z_stream_wrapper(false, _level, _window_bits)),
|
252
|
+
buff_size(_buff_size) {
|
253
|
+
assert(sbuf_p);
|
254
|
+
in_buff = std::unique_ptr<char[]>(new char[buff_size]);
|
255
|
+
out_buff = std::unique_ptr<char[]>(new char[buff_size]);
|
256
|
+
setp(in_buff.get(), in_buff.get() + buff_size);
|
257
|
+
}
|
258
|
+
|
259
|
+
ostreambuf(const ostreambuf&) = delete;
|
260
|
+
ostreambuf& operator=(const ostreambuf&) = delete;
|
261
|
+
|
262
|
+
int deflate_loop(int flush) {
|
263
|
+
while (true) {
|
264
|
+
zstrm_p->next_out =
|
265
|
+
reinterpret_cast<decltype(zstrm_p->next_out)>(out_buff.get());
|
266
|
+
zstrm_p->avail_out = uint32_t(buff_size);
|
267
|
+
int ret = deflate(zstrm_p.get(), flush);
|
268
|
+
if (ret != Z_OK && ret != Z_STREAM_END && ret != Z_BUF_ERROR) {
|
269
|
+
failed = true;
|
270
|
+
throw Exception(zstrm_p.get(), ret);
|
271
|
+
}
|
272
|
+
std::streamsize sz = sbuf_p->sputn(
|
273
|
+
out_buff.get(),
|
274
|
+
reinterpret_cast<decltype(out_buff.get())>(zstrm_p->next_out) -
|
275
|
+
out_buff.get());
|
276
|
+
if (sz != reinterpret_cast<decltype(out_buff.get())>(zstrm_p->next_out) -
|
277
|
+
out_buff.get()) {
|
278
|
+
// there was an error in the sink stream
|
279
|
+
return -1;
|
280
|
+
}
|
281
|
+
if (ret == Z_STREAM_END || ret == Z_BUF_ERROR || sz == 0) {
|
282
|
+
break;
|
283
|
+
}
|
284
|
+
}
|
285
|
+
return 0;
|
286
|
+
}
|
287
|
+
|
288
|
+
virtual ~ostreambuf() {
|
289
|
+
// flush the zlib stream
|
290
|
+
//
|
291
|
+
// NOTE: Errors here (sync() return value not 0) are ignored, because we
|
292
|
+
// cannot throw in a destructor. This mirrors the behaviour of
|
293
|
+
// std::basic_filebuf::~basic_filebuf(). To see an exception on error,
|
294
|
+
// close the ofstream with an explicit call to close(), and do not rely
|
295
|
+
// on the implicit call in the destructor.
|
296
|
+
//
|
297
|
+
if (!failed) try {
|
298
|
+
sync();
|
299
|
+
} catch (...) {
|
300
|
+
}
|
301
|
+
}
|
302
|
+
std::streambuf::int_type overflow(
|
303
|
+
std::streambuf::int_type c = traits_type::eof()) override {
|
304
|
+
zstrm_p->next_in = reinterpret_cast<decltype(zstrm_p->next_in)>(pbase());
|
305
|
+
zstrm_p->avail_in = uint32_t(pptr() - pbase());
|
306
|
+
while (zstrm_p->avail_in > 0) {
|
307
|
+
int r = deflate_loop(Z_NO_FLUSH);
|
308
|
+
if (r != 0) {
|
309
|
+
setp(nullptr, nullptr);
|
310
|
+
return traits_type::eof();
|
311
|
+
}
|
312
|
+
}
|
313
|
+
setp(in_buff.get(), in_buff.get() + buff_size);
|
314
|
+
return traits_type::eq_int_type(c, traits_type::eof())
|
315
|
+
? traits_type::eof()
|
316
|
+
: sputc(char_type(c));
|
317
|
+
}
|
318
|
+
int sync() override {
|
319
|
+
// first, call overflow to clear in_buff
|
320
|
+
overflow();
|
321
|
+
if (!pptr()) return -1;
|
322
|
+
// then, call deflate asking to finish the zlib stream
|
323
|
+
zstrm_p->next_in = nullptr;
|
324
|
+
zstrm_p->avail_in = 0;
|
325
|
+
if (deflate_loop(Z_FINISH) != 0) return -1;
|
326
|
+
deflateReset(zstrm_p.get());
|
327
|
+
return 0;
|
328
|
+
}
|
329
|
+
|
330
|
+
private:
|
331
|
+
std::streambuf* sbuf_p = nullptr;
|
332
|
+
std::unique_ptr<char[]> in_buff;
|
333
|
+
std::unique_ptr<char[]> out_buff;
|
334
|
+
std::unique_ptr<detail::z_stream_wrapper> zstrm_p;
|
335
|
+
std::size_t buff_size;
|
336
|
+
bool failed = false;
|
337
|
+
|
338
|
+
}; // class ostreambuf
|
339
|
+
|
340
|
+
class istream : public std::istream {
|
341
|
+
public:
|
342
|
+
istream(std::istream& is, std::size_t _buff_size = default_buff_size,
|
343
|
+
bool _auto_detect = true, int _window_bits = 0)
|
344
|
+
: std::istream(new istreambuf(is.rdbuf(), _buff_size, _auto_detect,
|
345
|
+
_window_bits)) {
|
346
|
+
exceptions(std::ios_base::badbit);
|
347
|
+
}
|
348
|
+
explicit istream(std::streambuf* sbuf_p)
|
349
|
+
: std::istream(new istreambuf(sbuf_p)) {
|
350
|
+
exceptions(std::ios_base::badbit);
|
351
|
+
}
|
352
|
+
virtual ~istream() { delete rdbuf(); }
|
353
|
+
}; // class istream
|
354
|
+
|
355
|
+
class ostream : public std::ostream {
|
356
|
+
public:
|
357
|
+
ostream(std::ostream& os, std::size_t _buff_size = default_buff_size,
|
358
|
+
int _level = Z_DEFAULT_COMPRESSION, int _window_bits = 0)
|
359
|
+
: std::ostream(
|
360
|
+
new ostreambuf(os.rdbuf(), _buff_size, _level, _window_bits)) {
|
361
|
+
exceptions(std::ios_base::badbit);
|
362
|
+
}
|
363
|
+
explicit ostream(std::streambuf* sbuf_p)
|
364
|
+
: std::ostream(new ostreambuf(sbuf_p)) {
|
365
|
+
exceptions(std::ios_base::badbit);
|
366
|
+
}
|
367
|
+
virtual ~ostream() { delete rdbuf(); }
|
368
|
+
}; // class ostream
|
369
|
+
|
370
|
+
namespace detail {
|
371
|
+
|
372
|
+
template <typename FStream_Type>
|
373
|
+
struct strict_fstream_holder {
|
374
|
+
strict_fstream_holder(const std::string& filename,
|
375
|
+
std::ios_base::openmode mode = std::ios_base::in)
|
376
|
+
: _fs(filename, mode) {}
|
377
|
+
strict_fstream_holder() = default;
|
378
|
+
FStream_Type _fs{};
|
379
|
+
}; // class strict_fstream_holder
|
380
|
+
|
381
|
+
} // namespace detail
|
382
|
+
|
383
|
+
class ifstream
|
384
|
+
: private detail::strict_fstream_holder<strict_fstream::ifstream>,
|
385
|
+
public std::istream {
|
386
|
+
public:
|
387
|
+
explicit ifstream(const std::string filename,
|
388
|
+
std::ios_base::openmode mode = std::ios_base::in,
|
389
|
+
size_t buff_size = default_buff_size)
|
390
|
+
: detail::strict_fstream_holder<strict_fstream::ifstream>(
|
391
|
+
filename, mode
|
392
|
+
#ifdef _WIN32 // to avoid problems with conversion of \r\n, only windows as
|
393
|
+
// otherwise there are problems on mac
|
394
|
+
| std::ios_base::binary
|
395
|
+
#endif
|
396
|
+
),
|
397
|
+
std::istream(new istreambuf(_fs.rdbuf(), buff_size)) {
|
398
|
+
exceptions(std::ios_base::badbit);
|
399
|
+
}
|
400
|
+
explicit ifstream()
|
401
|
+
: detail::strict_fstream_holder<strict_fstream::ifstream>(),
|
402
|
+
std::istream(new istreambuf(_fs.rdbuf())) {}
|
403
|
+
void close() { _fs.close(); }
|
404
|
+
void open(const std::string filename,
|
405
|
+
std::ios_base::openmode mode = std::ios_base::in) {
|
406
|
+
_fs.open(filename, mode
|
407
|
+
#ifdef _WIN32 // to avoid problems with conversion of \r\n, only windows as
|
408
|
+
// otherwise there are problems on mac
|
409
|
+
| std::ios_base::binary
|
410
|
+
#endif
|
411
|
+
);
|
412
|
+
// make sure the previous buffer is deleted by putting it into a unique_ptr
|
413
|
+
// and set a new one after opening file
|
414
|
+
std::unique_ptr<std::streambuf> oldbuf(rdbuf(new istreambuf(_fs.rdbuf())));
|
415
|
+
// call move assignment operator on istream which does not alter the stream
|
416
|
+
// buffer
|
417
|
+
std::istream::operator=(std::istream(rdbuf()));
|
418
|
+
}
|
419
|
+
bool is_open() const { return _fs.is_open(); }
|
420
|
+
virtual ~ifstream() {
|
421
|
+
if (_fs.is_open()) close();
|
422
|
+
if (rdbuf()) delete rdbuf();
|
423
|
+
}
|
424
|
+
|
425
|
+
/// Return the position within the compressed file (wrapped filestream)
|
426
|
+
std::streampos compressed_tellg() { return _fs.tellg(); }
|
427
|
+
}; // class ifstream
|
428
|
+
|
429
|
+
class ofstream
|
430
|
+
: private detail::strict_fstream_holder<strict_fstream::ofstream>,
|
431
|
+
public std::ostream {
|
432
|
+
public:
|
433
|
+
explicit ofstream(const std::string filename,
|
434
|
+
std::ios_base::openmode mode = std::ios_base::out,
|
435
|
+
int level = Z_DEFAULT_COMPRESSION,
|
436
|
+
size_t buff_size = default_buff_size)
|
437
|
+
: detail::strict_fstream_holder<strict_fstream::ofstream>(
|
438
|
+
filename, mode | std::ios_base::binary),
|
439
|
+
std::ostream(new ostreambuf(_fs.rdbuf(), buff_size, level)) {
|
440
|
+
exceptions(std::ios_base::badbit);
|
441
|
+
}
|
442
|
+
explicit ofstream()
|
443
|
+
: detail::strict_fstream_holder<strict_fstream::ofstream>(),
|
444
|
+
std::ostream(new ostreambuf(_fs.rdbuf())) {}
|
445
|
+
void close() {
|
446
|
+
std::ostream::flush();
|
447
|
+
_fs.close();
|
448
|
+
}
|
449
|
+
void open(const std::string filename,
|
450
|
+
std::ios_base::openmode mode = std::ios_base::out,
|
451
|
+
int level = Z_DEFAULT_COMPRESSION) {
|
452
|
+
flush();
|
453
|
+
_fs.open(filename, mode | std::ios_base::binary);
|
454
|
+
std::ostream::operator=(
|
455
|
+
std::ostream(new ostreambuf(_fs.rdbuf(), default_buff_size, level)));
|
456
|
+
}
|
457
|
+
bool is_open() const { return _fs.is_open(); }
|
458
|
+
ofstream& flush() {
|
459
|
+
std::ostream::flush();
|
460
|
+
_fs.flush();
|
461
|
+
return *this;
|
462
|
+
}
|
463
|
+
virtual ~ofstream() {
|
464
|
+
if (_fs.is_open()) close();
|
465
|
+
if (rdbuf()) delete rdbuf();
|
466
|
+
}
|
467
|
+
|
468
|
+
// Return the position within the compressed file (wrapped filestream)
|
469
|
+
std::streampos compressed_tellp() { return _fs.tellp(); }
|
470
|
+
}; // class ofstream
|
471
|
+
|
472
|
+
} // namespace zstr
|