lpsolver 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +70 -26
- data/ext/lpsolver/Makefile +273 -0
- data/ext/lpsolver/ext.c +353 -0
- data/ext/lpsolver/ext.o +0 -0
- data/ext/lpsolver/extconf.rb +79 -0
- data/ext/lpsolver/native.so +0 -0
- data/ext/lpsolver-highs/AUTHORS +7 -0
- data/ext/lpsolver-highs/BUILD.bazel +243 -0
- data/ext/lpsolver-highs/CITATION.cff +29 -0
- data/ext/lpsolver-highs/CMakeCache.txt +406 -0
- data/ext/lpsolver-highs/CMakeFiles/3.31.4/CMakeCCompiler.cmake +81 -0
- data/ext/lpsolver-highs/CMakeFiles/3.31.4/CMakeCXXCompiler.cmake +101 -0
- data/ext/lpsolver-highs/CMakeFiles/3.31.4/CMakeDetermineCompilerABI_C.bin +0 -0
- data/ext/lpsolver-highs/CMakeFiles/3.31.4/CMakeDetermineCompilerABI_CXX.bin +0 -0
- data/ext/lpsolver-highs/CMakeFiles/3.31.4/CMakeSystem.cmake +15 -0
- data/ext/lpsolver-highs/CMakeFiles/3.31.4/CompilerIdC/CMakeCCompilerId.c +904 -0
- data/ext/lpsolver-highs/CMakeFiles/3.31.4/CompilerIdC/a.out +0 -0
- data/ext/lpsolver-highs/CMakeFiles/3.31.4/CompilerIdCXX/CMakeCXXCompilerId.cpp +919 -0
- data/ext/lpsolver-highs/CMakeFiles/3.31.4/CompilerIdCXX/a.out +0 -0
- data/ext/lpsolver-highs/CMakeFiles/CMakeConfigureLog.yaml +576 -0
- data/ext/lpsolver-highs/CMakeFiles/cmake.check_cache +1 -0
- data/ext/lpsolver-highs/CMakeLists.txt +983 -0
- data/ext/lpsolver-highs/CODE_OF_CONDUCT.md +128 -0
- data/ext/lpsolver-highs/CONTRIBUTING.md +31 -0
- data/ext/lpsolver-highs/FEATURES.md +61 -0
- data/ext/lpsolver-highs/LICENSE.txt +21 -0
- data/ext/lpsolver-highs/MODULE.bazel +38 -0
- data/ext/lpsolver-highs/README.md +281 -0
- data/ext/lpsolver-highs/THIRD_PARTY_NOTICES.md +78 -0
- data/ext/lpsolver-highs/Version.txt +4 -0
- data/ext/lpsolver-highs/WORKSPACE +33 -0
- data/ext/lpsolver-highs/app/CMakeLists.txt +110 -0
- data/ext/lpsolver-highs/app/HighsRuntimeOptions.h +292 -0
- data/ext/lpsolver-highs/app/RunHighs.cpp +147 -0
- data/ext/lpsolver-highs/app/highs_webdemo_shell.html +73 -0
- data/ext/lpsolver-highs/build/bin/highs +0 -0
- data/ext/lpsolver-highs/build/include/highs/HConfig.h +22 -0
- data/ext/lpsolver-highs/build/include/highs/Highs.h +1812 -0
- data/ext/lpsolver-highs/build/include/highs/interfaces/highs_c_api.h +2651 -0
- data/ext/lpsolver-highs/build/include/highs/io/Filereader.h +45 -0
- data/ext/lpsolver-highs/build/include/highs/io/FilereaderLp.h +49 -0
- data/ext/lpsolver-highs/build/include/highs/io/FilereaderMps.h +27 -0
- data/ext/lpsolver-highs/build/include/highs/io/HMPSIO.h +78 -0
- data/ext/lpsolver-highs/build/include/highs/io/HMpsFF.h +245 -0
- data/ext/lpsolver-highs/build/include/highs/io/HighsIO.h +118 -0
- data/ext/lpsolver-highs/build/include/highs/io/LoadOptions.h +24 -0
- data/ext/lpsolver-highs/build/include/highs/io/filereaderlp/builder.hpp +25 -0
- data/ext/lpsolver-highs/build/include/highs/io/filereaderlp/def.hpp +19 -0
- data/ext/lpsolver-highs/build/include/highs/io/filereaderlp/model.hpp +68 -0
- data/ext/lpsolver-highs/build/include/highs/io/filereaderlp/reader.hpp +10 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/IpxSolution.h +32 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/IpxWrapper.h +106 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu.h +161 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu_factorize.h +247 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu_get_factors.h +108 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu_initialize.h +119 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu_obj_factorize.h +34 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu_obj_free.h +19 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu_obj_get_factors.h +34 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu_obj_initialize.h +46 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu_obj_solve_dense.h +29 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu_obj_solve_for_update.h +42 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu_obj_solve_sparse.h +32 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu_obj_update.h +31 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu_object.h +30 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu_solve_dense.h +75 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu_solve_for_update.h +169 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu_solve_sparse.h +112 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/basiclu_update.h +125 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/lu_def.h +39 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/lu_file.h +21 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/lu_internal.h +220 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/basiclu/lu_list.h +173 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/basiclu_kernel.h +20 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/basiclu_wrapper.h +47 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/basis.h +350 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/conjugate_residuals.h +74 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/control.h +167 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/crossover.h +157 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/diagonal_precond.h +45 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/forrest_tomlin.h +102 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/guess_basis.h +21 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/indexed_vector.h +113 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/info.h +27 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/ipm.h +94 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/ipx_c.h +47 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/ipx_config.h +9 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/ipx_info.h +111 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/ipx_internal.h +89 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/ipx_parameters.h +76 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/ipx_status.h +57 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/iterate.h +331 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/kkt_solver.h +70 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/kkt_solver_basis.h +66 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/kkt_solver_diag.h +48 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/linear_operator.h +26 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/lp_solver.h +204 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/lu_factorization.h +79 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/lu_update.h +129 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/maxvolume.h +54 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/model.h +413 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/multistream.h +52 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/normal_matrix.h +44 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/power_method.h +44 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/sparse_matrix.h +195 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/sparse_utils.h +58 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/splitted_normal_matrix.h +63 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/starting_basis.h +39 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/symbolic_invert.h +29 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/timer.h +25 -0
- data/ext/lpsolver-highs/build/include/highs/ipm/ipx/utils.h +37 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HConst.h +430 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HStruct.h +213 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsAnalysis.h +23 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsCallback.h +104 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsCallbackStruct.h +70 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsDebug.h +34 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsIis.h +139 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsInfo.h +421 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsInfoDebug.h +27 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsLp.h +97 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsLpSolverObject.h +47 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsLpUtils.h +330 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsModelUtils.h +129 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsOptions.h +1715 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsRanging.h +43 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsSolution.h +179 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsSolutionDebug.h +87 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsSolve.h +29 -0
- data/ext/lpsolver-highs/build/include/highs/lp_data/HighsStatus.h +29 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsCliqueTable.h +329 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsConflictPool.h +109 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsCutGeneration.h +108 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsCutPool.h +168 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsDebugSol.h +133 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsDomain.h +657 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsDomainChange.h +48 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsDynamicRowMatrix.h +104 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsGFkSolve.h +439 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsImplications.h +194 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsLpAggregator.h +50 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsLpRelaxation.h +361 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsMipAnalysis.h +71 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsMipSolver.h +159 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsMipSolverData.h +313 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsModkSeparator.h +60 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsNodeQueue.h +312 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsObjectiveFunction.h +71 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsPathSeparator.h +39 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsPrimalHeuristics.h +75 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsPseudocost.h +366 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsRedcostFixing.h +42 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsSearch.h +241 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsSeparation.h +41 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsSeparator.h +60 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsTableauSeparator.h +34 -0
- data/ext/lpsolver-highs/build/include/highs/mip/HighsTransformedLp.h +63 -0
- data/ext/lpsolver-highs/build/include/highs/mip/MipTimer.h +544 -0
- data/ext/lpsolver-highs/build/include/highs/mip/feasibilityjump.hh +800 -0
- data/ext/lpsolver-highs/build/include/highs/model/HighsHessian.h +54 -0
- data/ext/lpsolver-highs/build/include/highs/model/HighsHessianUtils.h +47 -0
- data/ext/lpsolver-highs/build/include/highs/model/HighsModel.h +42 -0
- data/ext/lpsolver-highs/build/include/highs/parallel/HighsBinarySemaphore.h +108 -0
- data/ext/lpsolver-highs/build/include/highs/parallel/HighsCacheAlign.h +82 -0
- data/ext/lpsolver-highs/build/include/highs/parallel/HighsCombinable.h +116 -0
- data/ext/lpsolver-highs/build/include/highs/parallel/HighsMutex.h +124 -0
- data/ext/lpsolver-highs/build/include/highs/parallel/HighsParallel.h +128 -0
- data/ext/lpsolver-highs/build/include/highs/parallel/HighsRaceTimer.h +38 -0
- data/ext/lpsolver-highs/build/include/highs/parallel/HighsSchedulerConstants.h +19 -0
- data/ext/lpsolver-highs/build/include/highs/parallel/HighsSpinMutex.h +48 -0
- data/ext/lpsolver-highs/build/include/highs/parallel/HighsSplitDeque.h +606 -0
- data/ext/lpsolver-highs/build/include/highs/parallel/HighsTask.h +170 -0
- data/ext/lpsolver-highs/build/include/highs/parallel/HighsTaskExecutor.h +217 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/CupdlpWrapper.h +108 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/HiPdlpTimer.h +155 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/HiPdlpWrapper.h +26 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/cupdlp/cupdlp_cs.h +40 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/cupdlp/cupdlp_defs.h +447 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/cupdlp/cupdlp_linalg.h +189 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/cupdlp/cupdlp_proj.h +19 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/cupdlp/cupdlp_restart.h +31 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/cupdlp/cupdlp_scaling.h +26 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/cupdlp/cupdlp_solver.h +105 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/cupdlp/cupdlp_step.h +37 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/cupdlp/cupdlp_utils.c +1850 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/hipdlp/defs.hpp +222 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/hipdlp/linalg.hpp +61 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/hipdlp/logger.hpp +80 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/hipdlp/pdhg.hpp +358 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/hipdlp/restart.hpp +96 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/hipdlp/scaling.hpp +74 -0
- data/ext/lpsolver-highs/build/include/highs/pdlp/hipdlp/solver_results.hpp +65 -0
- data/ext/lpsolver-highs/build/include/highs/pdqsort/pdqsort.h +532 -0
- data/ext/lpsolver-highs/build/include/highs/presolve/HPresolve.h +505 -0
- data/ext/lpsolver-highs/build/include/highs/presolve/HPresolveAnalysis.h +52 -0
- data/ext/lpsolver-highs/build/include/highs/presolve/HighsPostsolveStack.h +943 -0
- data/ext/lpsolver-highs/build/include/highs/presolve/HighsSymmetry.h +284 -0
- data/ext/lpsolver-highs/build/include/highs/presolve/ICrash.h +124 -0
- data/ext/lpsolver-highs/build/include/highs/presolve/ICrashUtil.h +62 -0
- data/ext/lpsolver-highs/build/include/highs/presolve/ICrashX.h +23 -0
- data/ext/lpsolver-highs/build/include/highs/presolve/PresolveComponent.h +90 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/a_asm.hpp +77 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/a_quass.hpp +22 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/basis.hpp +159 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/crashsolution.hpp +20 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/dantzigpricing.hpp +80 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/devexpricing.hpp +108 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/eventhandler.hpp +30 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/factor.hpp +408 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/feasibility_bounded.hpp +114 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/feasibility_highs.hpp +301 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/gradient.hpp +46 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/instance.hpp +70 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/matrix.hpp +342 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/perturbation.hpp +15 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/pricing.hpp +22 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/qpconst.hpp +34 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/qpvector.hpp +242 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/quass.hpp +27 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/ratiotest.hpp +26 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/runtime.hpp +45 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/scaling.hpp +15 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/settings.hpp +84 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/snippets.hpp +36 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/statistics.hpp +30 -0
- data/ext/lpsolver-highs/build/include/highs/qpsolver/steepestedgepricing.hpp +173 -0
- data/ext/lpsolver-highs/build/include/highs/simplex/HApp.h +550 -0
- data/ext/lpsolver-highs/build/include/highs/simplex/HEkk.h +419 -0
- data/ext/lpsolver-highs/build/include/highs/simplex/HEkkDual.h +513 -0
- data/ext/lpsolver-highs/build/include/highs/simplex/HEkkDualRHS.h +134 -0
- data/ext/lpsolver-highs/build/include/highs/simplex/HEkkDualRow.h +201 -0
- data/ext/lpsolver-highs/build/include/highs/simplex/HEkkPrimal.h +191 -0
- data/ext/lpsolver-highs/build/include/highs/simplex/HSimplex.h +42 -0
- data/ext/lpsolver-highs/build/include/highs/simplex/HSimplexDebug.h +48 -0
- data/ext/lpsolver-highs/build/include/highs/simplex/HSimplexNla.h +158 -0
- data/ext/lpsolver-highs/build/include/highs/simplex/HSimplexReport.h +21 -0
- data/ext/lpsolver-highs/build/include/highs/simplex/HighsSimplexAnalysis.h +500 -0
- data/ext/lpsolver-highs/build/include/highs/simplex/SimplexConst.h +273 -0
- data/ext/lpsolver-highs/build/include/highs/simplex/SimplexStruct.h +263 -0
- data/ext/lpsolver-highs/build/include/highs/simplex/SimplexTimer.h +414 -0
- data/ext/lpsolver-highs/build/include/highs/test_kkt/DevKkt.h +143 -0
- data/ext/lpsolver-highs/build/include/highs/test_kkt/KktCh2.h +79 -0
- data/ext/lpsolver-highs/build/include/highs/util/FactorTimer.h +199 -0
- data/ext/lpsolver-highs/build/include/highs/util/HFactor.h +587 -0
- data/ext/lpsolver-highs/build/include/highs/util/HFactorConst.h +81 -0
- data/ext/lpsolver-highs/build/include/highs/util/HFactorDebug.h +55 -0
- data/ext/lpsolver-highs/build/include/highs/util/HSet.h +89 -0
- data/ext/lpsolver-highs/build/include/highs/util/HVector.h +22 -0
- data/ext/lpsolver-highs/build/include/highs/util/HVectorBase.h +102 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsCDouble.h +323 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsComponent.h +53 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsDataStack.h +83 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsDisjointSets.h +107 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsHash.h +1274 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsHashTree.h +1461 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsInt.h +36 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsIntegers.h +212 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsLinearSumBounds.h +203 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsMatrixPic.h +37 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsMatrixSlice.h +561 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsMatrixUtils.h +57 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsMemoryAllocation.h +63 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsRandom.h +242 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsRbTree.h +452 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsSort.h +131 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsSparseMatrix.h +151 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsSparseVectorSum.h +95 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsSplay.h +135 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsTimer.h +385 -0
- data/ext/lpsolver-highs/build/include/highs/util/HighsUtils.h +272 -0
- data/ext/lpsolver-highs/build/include/highs/util/stringutil.h +46 -0
- data/ext/lpsolver-highs/build/include/highs/zstr/strict_fstream.hpp +237 -0
- data/ext/lpsolver-highs/build/include/highs/zstr/zstr.hpp +473 -0
- data/ext/lpsolver-highs/build/include/highs_export.h +43 -0
- data/ext/lpsolver-highs/build/lib/cmake/highs/highs-config-version.cmake +65 -0
- data/ext/lpsolver-highs/build/lib/cmake/highs/highs-config.cmake +36 -0
- data/ext/lpsolver-highs/build/lib/cmake/highs/highs-targets-release.cmake +19 -0
- data/ext/lpsolver-highs/build/lib/cmake/highs/highs-targets.cmake +111 -0
- data/ext/lpsolver-highs/build/lib/libhighs.a +0 -0
- data/ext/lpsolver-highs/build/lib/pkgconfig/highs.pc +12 -0
- data/ext/lpsolver-highs/build/share/doc/HIGHS/AUTHORS +7 -0
- data/ext/lpsolver-highs/build/share/doc/HIGHS/CITATION.cff +29 -0
- data/ext/lpsolver-highs/build/share/doc/HIGHS/CODE_OF_CONDUCT.md +128 -0
- data/ext/lpsolver-highs/build/share/doc/HIGHS/CONTRIBUTING.md +31 -0
- data/ext/lpsolver-highs/build/share/doc/HIGHS/FEATURES.md +61 -0
- data/ext/lpsolver-highs/build/share/doc/HIGHS/LICENSE.txt +21 -0
- data/ext/lpsolver-highs/build/share/doc/HIGHS/README.md +281 -0
- data/ext/lpsolver-highs/build_webdemo.sh +46 -0
- data/ext/lpsolver-highs/check/Avgas.cpp +245 -0
- data/ext/lpsolver-highs/check/Avgas.h +44 -0
- data/ext/lpsolver-highs/check/CMakeLists.txt +573 -0
- data/ext/lpsolver-highs/check/HCheckConfig.h.bazel.in +6 -0
- data/ext/lpsolver-highs/check/HCheckConfig.h.in +12 -0
- data/ext/lpsolver-highs/check/HCheckConfig.h.meson.in +6 -0
- data/ext/lpsolver-highs/check/SpecialLps.h +405 -0
- data/ext/lpsolver-highs/check/TestAlienBasis.cpp +720 -0
- data/ext/lpsolver-highs/check/TestBasis.cpp +359 -0
- data/ext/lpsolver-highs/check/TestBasisSolves.cpp +669 -0
- data/ext/lpsolver-highs/check/TestCAPI.c +2513 -0
- data/ext/lpsolver-highs/check/TestCallbacks.cpp +608 -0
- data/ext/lpsolver-highs/check/TestCheckSolution.cpp +740 -0
- data/ext/lpsolver-highs/check/TestCrossover.cpp +111 -0
- data/ext/lpsolver-highs/check/TestDualize.cpp +172 -0
- data/ext/lpsolver-highs/check/TestEkk.cpp +100 -0
- data/ext/lpsolver-highs/check/TestFactor.cpp +389 -0
- data/ext/lpsolver-highs/check/TestFilereader.cpp +568 -0
- data/ext/lpsolver-highs/check/TestFortranAPI.f90 +65 -0
- data/ext/lpsolver-highs/check/TestHSet.cpp +80 -0
- data/ext/lpsolver-highs/check/TestHighsCDouble.cpp +109 -0
- data/ext/lpsolver-highs/check/TestHighsGFkSolve.cpp +102 -0
- data/ext/lpsolver-highs/check/TestHighsHash.cpp +126 -0
- data/ext/lpsolver-highs/check/TestHighsHessian.cpp +329 -0
- data/ext/lpsolver-highs/check/TestHighsIntegers.cpp +42 -0
- data/ext/lpsolver-highs/check/TestHighsModel.cpp +134 -0
- data/ext/lpsolver-highs/check/TestHighsParallel.cpp +277 -0
- data/ext/lpsolver-highs/check/TestHighsRbTree.cpp +109 -0
- data/ext/lpsolver-highs/check/TestHighsSparseMatrix.cpp +126 -0
- data/ext/lpsolver-highs/check/TestHighsVersion.cpp +61 -0
- data/ext/lpsolver-highs/check/TestHipo.cpp +122 -0
- data/ext/lpsolver-highs/check/TestICrash.cpp +46 -0
- data/ext/lpsolver-highs/check/TestIO.cpp +163 -0
- data/ext/lpsolver-highs/check/TestIis.cpp +1063 -0
- data/ext/lpsolver-highs/check/TestInfo.cpp +116 -0
- data/ext/lpsolver-highs/check/TestIpm.cpp +226 -0
- data/ext/lpsolver-highs/check/TestIpx.cpp +96 -0
- data/ext/lpsolver-highs/check/TestLPFileFormat.cpp +22 -0
- data/ext/lpsolver-highs/check/TestLogging.cpp +69 -0
- data/ext/lpsolver-highs/check/TestLpModification.cpp +2497 -0
- data/ext/lpsolver-highs/check/TestLpOrientation.cpp +121 -0
- data/ext/lpsolver-highs/check/TestLpSolvers.cpp +555 -0
- data/ext/lpsolver-highs/check/TestLpValidation.cpp +689 -0
- data/ext/lpsolver-highs/check/TestMain.cpp +6 -0
- data/ext/lpsolver-highs/check/TestMipSolver.cpp +1406 -0
- data/ext/lpsolver-highs/check/TestModelProperties.cpp +143 -0
- data/ext/lpsolver-highs/check/TestMultiObjective.cpp +198 -0
- data/ext/lpsolver-highs/check/TestNames.cpp +187 -0
- data/ext/lpsolver-highs/check/TestOptions.cpp +544 -0
- data/ext/lpsolver-highs/check/TestPdlp.cpp +327 -0
- data/ext/lpsolver-highs/check/TestPdlpHi.cpp +40 -0
- data/ext/lpsolver-highs/check/TestPresolve.cpp +912 -0
- data/ext/lpsolver-highs/check/TestQpSolver.cpp +1345 -0
- data/ext/lpsolver-highs/check/TestRanging.cpp +558 -0
- data/ext/lpsolver-highs/check/TestRays.cpp +1010 -0
- data/ext/lpsolver-highs/check/TestSemiVariables.cpp +329 -0
- data/ext/lpsolver-highs/check/TestSetup.cpp +12 -0
- data/ext/lpsolver-highs/check/TestSort.cpp +247 -0
- data/ext/lpsolver-highs/check/TestSpecialLps.cpp +775 -0
- data/ext/lpsolver-highs/check/TestThrow.cpp +83 -0
- data/ext/lpsolver-highs/check/TestTspSolver.cpp +19 -0
- data/ext/lpsolver-highs/check/TestUserScale.cpp +444 -0
- data/ext/lpsolver-highs/check/cublas_example.cpp +76 -0
- data/ext/lpsolver-highs/check/cublas_gpu_start.cpp +88 -0
- data/ext/lpsolver-highs/check/hipo_test_option_files/hipo_options_0 +1 -0
- data/ext/lpsolver-highs/check/instances/1448.lp +1 -0
- data/ext/lpsolver-highs/check/instances/1449a.lp +1 -0
- data/ext/lpsolver-highs/check/instances/1449b.lp +1 -0
- data/ext/lpsolver-highs/check/instances/1451.lp +8 -0
- data/ext/lpsolver-highs/check/instances/2122.lp +1822 -0
- data/ext/lpsolver-highs/check/instances/2171.mps +717 -0
- data/ext/lpsolver-highs/check/instances/25fv47.mps +6919 -0
- data/ext/lpsolver-highs/check/instances/2821-duplicate.mps +31 -0
- data/ext/lpsolver-highs/check/instances/2821-qmatrix.mps +31 -0
- data/ext/lpsolver-highs/check/instances/2821-quadobj.mps +29 -0
- data/ext/lpsolver-highs/check/instances/2821-summation.mps +30 -0
- data/ext/lpsolver-highs/check/instances/2821.mps +29 -0
- data/ext/lpsolver-highs/check/instances/2894.mps +89 -0
- data/ext/lpsolver-highs/check/instances/80bau3b.mps +23732 -0
- data/ext/lpsolver-highs/check/instances/WithInf.set +3 -0
- data/ext/lpsolver-highs/check/instances/adlittle.mps +335 -0
- data/ext/lpsolver-highs/check/instances/afiro.mps +83 -0
- data/ext/lpsolver-highs/check/instances/avgas.mps +51 -0
- data/ext/lpsolver-highs/check/instances/bell5.mps +384 -0
- data/ext/lpsolver-highs/check/instances/bgetam.mps +2112 -0
- data/ext/lpsolver-highs/check/instances/blending.mps +13 -0
- data/ext/lpsolver-highs/check/instances/box1.mps +1085 -0
- data/ext/lpsolver-highs/check/instances/chip.mps +13 -0
- data/ext/lpsolver-highs/check/instances/comment.mps +23 -0
- data/ext/lpsolver-highs/check/instances/cplex1.mps +9674 -0
- data/ext/lpsolver-highs/check/instances/dD2e.mps +10 -0
- data/ext/lpsolver-highs/check/instances/dcmulti.mps +2310 -0
- data/ext/lpsolver-highs/check/instances/e226.mps +1733 -0
- data/ext/lpsolver-highs/check/instances/egout-ac.mps +473 -0
- data/ext/lpsolver-highs/check/instances/egout.mps +403 -0
- data/ext/lpsolver-highs/check/instances/etamacro.mps +2084 -0
- data/ext/lpsolver-highs/check/instances/ex72a.mps +849 -0
- data/ext/lpsolver-highs/check/instances/fixed-binary.lp +11 -0
- data/ext/lpsolver-highs/check/instances/flugpl.mps +111 -0
- data/ext/lpsolver-highs/check/instances/flugpl_illegal_integer.sol +24 -0
- data/ext/lpsolver-highs/check/instances/flugpl_integer.sol +25 -0
- data/ext/lpsolver-highs/check/instances/forest6.mps +261 -0
- data/ext/lpsolver-highs/check/instances/galenet.mps +34 -0
- data/ext/lpsolver-highs/check/instances/gams10am.mps +478 -0
- data/ext/lpsolver-highs/check/instances/garbage.ems +3 -0
- data/ext/lpsolver-highs/check/instances/garbage.lp +3 -0
- data/ext/lpsolver-highs/check/instances/garbage.mps +3 -0
- data/ext/lpsolver-highs/check/instances/gas11.mps +2924 -0
- data/ext/lpsolver-highs/check/instances/gesa2.mps +5459 -0
- data/ext/lpsolver-highs/check/instances/greenbea.mps +19215 -0
- data/ext/lpsolver-highs/check/instances/gt2.mps +534 -0
- data/ext/lpsolver-highs/check/instances/infeasible-mip0.mps +140 -0
- data/ext/lpsolver-highs/check/instances/infeasible-mip1.mps +371 -0
- data/ext/lpsolver-highs/check/instances/israel.mps +1490 -0
- data/ext/lpsolver-highs/check/instances/issue-2095.mps +836 -0
- data/ext/lpsolver-highs/check/instances/issue-2173.mps +3331 -0
- data/ext/lpsolver-highs/check/instances/issue-2204.mps +143 -0
- data/ext/lpsolver-highs/check/instances/issue-2290.mps +158 -0
- data/ext/lpsolver-highs/check/instances/issue-2388.lp +76 -0
- data/ext/lpsolver-highs/check/instances/issue-2402.mps +435 -0
- data/ext/lpsolver-highs/check/instances/issue-2446.mps +9154 -0
- data/ext/lpsolver-highs/check/instances/issue-2585.lp +16 -0
- data/ext/lpsolver-highs/check/instances/issue-2874-3.mps +97 -0
- data/ext/lpsolver-highs/check/instances/klein1.mps +422 -0
- data/ext/lpsolver-highs/check/instances/lseu.mps +371 -0
- data/ext/lpsolver-highs/check/instances/model.xyz +1 -0
- data/ext/lpsolver-highs/check/instances/nan0.mps +13 -0
- data/ext/lpsolver-highs/check/instances/nan1.mps +13 -0
- data/ext/lpsolver-highs/check/instances/nan2.mps +13 -0
- data/ext/lpsolver-highs/check/instances/no-newline-eof.lp +5 -0
- data/ext/lpsolver-highs/check/instances/p01.mps +909 -0
- data/ext/lpsolver-highs/check/instances/p0548.mps +1992 -0
- data/ext/lpsolver-highs/check/instances/primal1.mps +3909 -0
- data/ext/lpsolver-highs/check/instances/qap04.mps +606 -0
- data/ext/lpsolver-highs/check/instances/qcqp.lp +8 -0
- data/ext/lpsolver-highs/check/instances/qjh.lp +9 -0
- data/ext/lpsolver-highs/check/instances/qjh.mps +18 -0
- data/ext/lpsolver-highs/check/instances/qjh_qmatrix.mps +19 -0
- data/ext/lpsolver-highs/check/instances/qjh_quadobj.mps +18 -0
- data/ext/lpsolver-highs/check/instances/qjh_quadobj_qmatrix.mps +25 -0
- data/ext/lpsolver-highs/check/instances/qjh_uncon.lp +10 -0
- data/ext/lpsolver-highs/check/instances/qjh_uncon.mps +17 -0
- data/ext/lpsolver-highs/check/instances/qpinfeasible.lp +8 -0
- data/ext/lpsolver-highs/check/instances/qptestnw.lp +7 -0
- data/ext/lpsolver-highs/check/instances/qpunbounded.lp +5 -0
- data/ext/lpsolver-highs/check/instances/refinery.mps +1882 -0
- data/ext/lpsolver-highs/check/instances/rgn.mps +559 -0
- data/ext/lpsolver-highs/check/instances/scrs8.mps +2717 -0
- data/ext/lpsolver-highs/check/instances/sctest.mps +66 -0
- data/ext/lpsolver-highs/check/instances/semi-continuous.lp +13 -0
- data/ext/lpsolver-highs/check/instances/semi-continuous.mps +24 -0
- data/ext/lpsolver-highs/check/instances/semi-integer.lp +15 -0
- data/ext/lpsolver-highs/check/instances/semi-integer.mps +22 -0
- data/ext/lpsolver-highs/check/instances/shell.mps +4039 -0
- data/ext/lpsolver-highs/check/instances/silly-names.mps +14 -0
- data/ext/lpsolver-highs/check/instances/small_mip.mps +87 -0
- data/ext/lpsolver-highs/check/instances/smalllp.mps +21 -0
- data/ext/lpsolver-highs/check/instances/sp150x300d.mps +1983 -0
- data/ext/lpsolver-highs/check/instances/stair.mps +2499 -0
- data/ext/lpsolver-highs/check/instances/standata.mps +2317 -0
- data/ext/lpsolver-highs/check/instances/standgub.mps +2428 -0
- data/ext/lpsolver-highs/check/instances/standmps.mps +2695 -0
- data/ext/lpsolver-highs/check/instances/test.mps +53 -0
- data/ext/lpsolver-highs/check/instances/vol1.mps +1895 -0
- data/ext/lpsolver-highs/check/instances/warnings.mps +68 -0
- data/ext/lpsolver-highs/check/instances/woodinfe.mps +216 -0
- data/ext/lpsolver-highs/check/matrix_multiplication.hpp +49 -0
- data/ext/lpsolver-highs/check/meson.build +92 -0
- data/ext/lpsolver-highs/check/pythontest.py +11 -0
- data/ext/lpsolver-highs/check/sample_options_file +8 -0
- data/ext/lpsolver-highs/cmake/CheckAtomic.cmake +74 -0
- data/ext/lpsolver-highs/cmake/FindCUDAConf.cmake +44 -0
- data/ext/lpsolver-highs/cmake/FindHipoDeps.cmake +351 -0
- data/ext/lpsolver-highs/cmake/README.md +243 -0
- data/ext/lpsolver-highs/cmake/cpp-highs.cmake +243 -0
- data/ext/lpsolver-highs/cmake/dotnet.cmake +94 -0
- data/ext/lpsolver-highs/cmake/highs-config.cmake.in +22 -0
- data/ext/lpsolver-highs/cmake/python-highs.cmake +74 -0
- data/ext/lpsolver-highs/cmake/set-version.cmake +26 -0
- data/ext/lpsolver-highs/cmake/sources-python.cmake +461 -0
- data/ext/lpsolver-highs/cmake/sources.cmake +618 -0
- data/ext/lpsolver-highs/docs/HiGHS_CopyrightHeader.pl +78 -0
- data/ext/lpsolver-highs/docs/HiGHS_CopyrightHeaderUpdateAll +32 -0
- data/ext/lpsolver-highs/docs/Project.toml +7 -0
- data/ext/lpsolver-highs/docs/README.md +27 -0
- data/ext/lpsolver-highs/docs/c_api_gen/HConfig.h +1 -0
- data/ext/lpsolver-highs/docs/c_api_gen/build.jl +48 -0
- data/ext/lpsolver-highs/docs/make.jl +115 -0
- data/ext/lpsolver-highs/docs/src/assets/logo.png +0 -0
- data/ext/lpsolver-highs/docs/src/callbacks.md +171 -0
- data/ext/lpsolver-highs/docs/src/executable.md +88 -0
- data/ext/lpsolver-highs/docs/src/guide/advanced.md +66 -0
- data/ext/lpsolver-highs/docs/src/guide/basic.md +116 -0
- data/ext/lpsolver-highs/docs/src/guide/further.md +193 -0
- data/ext/lpsolver-highs/docs/src/guide/gpu.md +58 -0
- data/ext/lpsolver-highs/docs/src/guide/index.md +18 -0
- data/ext/lpsolver-highs/docs/src/guide/kkt.md +219 -0
- data/ext/lpsolver-highs/docs/src/guide/numerics.md +55 -0
- data/ext/lpsolver-highs/docs/src/index.md +86 -0
- data/ext/lpsolver-highs/docs/src/installation.md +130 -0
- data/ext/lpsolver-highs/docs/src/interfaces/c_api.md +6 -0
- data/ext/lpsolver-highs/docs/src/interfaces/cpp/examples.md +1 -0
- data/ext/lpsolver-highs/docs/src/interfaces/cpp/index.md +29 -0
- data/ext/lpsolver-highs/docs/src/interfaces/cpp/library.md +107 -0
- data/ext/lpsolver-highs/docs/src/interfaces/csharp.md +55 -0
- data/ext/lpsolver-highs/docs/src/interfaces/fortran.md +11 -0
- data/ext/lpsolver-highs/docs/src/interfaces/julia/index.md +130 -0
- data/ext/lpsolver-highs/docs/src/interfaces/other.md +41 -0
- data/ext/lpsolver-highs/docs/src/interfaces/python/example-py.md +275 -0
- data/ext/lpsolver-highs/docs/src/interfaces/python/index.md +91 -0
- data/ext/lpsolver-highs/docs/src/interfaces/python/model-py.md +90 -0
- data/ext/lpsolver-highs/docs/src/options/definitions.md +529 -0
- data/ext/lpsolver-highs/docs/src/options/intro.md +46 -0
- data/ext/lpsolver-highs/docs/src/parallel.md +88 -0
- data/ext/lpsolver-highs/docs/src/solvers.md +168 -0
- data/ext/lpsolver-highs/docs/src/structures/classes/HighsHessian.md +9 -0
- data/ext/lpsolver-highs/docs/src/structures/classes/HighsIis.md +16 -0
- data/ext/lpsolver-highs/docs/src/structures/classes/HighsLp.md +19 -0
- data/ext/lpsolver-highs/docs/src/structures/classes/HighsModel.md +6 -0
- data/ext/lpsolver-highs/docs/src/structures/classes/HighsSparseMatrix.md +10 -0
- data/ext/lpsolver-highs/docs/src/structures/classes/index.md +11 -0
- data/ext/lpsolver-highs/docs/src/structures/enums.md +114 -0
- data/ext/lpsolver-highs/docs/src/structures/index.md +12 -0
- data/ext/lpsolver-highs/docs/src/structures/structs/HighsBasis.md +8 -0
- data/ext/lpsolver-highs/docs/src/structures/structs/HighsInfo.md +148 -0
- data/ext/lpsolver-highs/docs/src/structures/structs/HighsLinearObjective.md +11 -0
- data/ext/lpsolver-highs/docs/src/structures/structs/HighsSolution.md +10 -0
- data/ext/lpsolver-highs/docs/src/structures/structs/index.md +10 -0
- data/ext/lpsolver-highs/docs/src/terminology.md +163 -0
- data/ext/lpsolver-highs/examples/CMakeLists.txt +26 -0
- data/ext/lpsolver-highs/examples/Docs.py +104 -0
- data/ext/lpsolver-highs/examples/branch-and-price.py +465 -0
- data/ext/lpsolver-highs/examples/call_highs_from_c.c +685 -0
- data/ext/lpsolver-highs/examples/call_highs_from_c_minimal.c +659 -0
- data/ext/lpsolver-highs/examples/call_highs_from_cpp.cpp +178 -0
- data/ext/lpsolver-highs/examples/call_highs_from_csharp.cs +83 -0
- data/ext/lpsolver-highs/examples/call_highs_from_fortran.f90 +579 -0
- data/ext/lpsolver-highs/examples/call_highs_from_python.py +448 -0
- data/ext/lpsolver-highs/examples/call_highs_from_python_highspy.py +71 -0
- data/ext/lpsolver-highs/examples/call_highs_from_python_mps.py +59 -0
- data/ext/lpsolver-highs/examples/callback_gap.py +71 -0
- data/ext/lpsolver-highs/examples/chip.py +43 -0
- data/ext/lpsolver-highs/examples/chip0.py +29 -0
- data/ext/lpsolver-highs/examples/distillation.py +77 -0
- data/ext/lpsolver-highs/examples/knapsack.py +43 -0
- data/ext/lpsolver-highs/examples/minimal.py +11 -0
- data/ext/lpsolver-highs/examples/multi_objective.py +139 -0
- data/ext/lpsolver-highs/examples/multiple_objective.py +120 -0
- data/ext/lpsolver-highs/examples/network_flow.py +37 -0
- data/ext/lpsolver-highs/examples/nqueens.py +29 -0
- data/ext/lpsolver-highs/examples/plot_highs_log.py +134 -0
- data/ext/lpsolver-highs/extern/CLI11.hpp +11546 -0
- data/ext/lpsolver-highs/extern/LICENCE_1_0.txt +23 -0
- data/ext/lpsolver-highs/extern/amd/License.txt +35 -0
- data/ext/lpsolver-highs/extern/amd/SuiteSparse_config.c +54 -0
- data/ext/lpsolver-highs/extern/amd/SuiteSparse_config.h +56 -0
- data/ext/lpsolver-highs/extern/amd/amd.h +357 -0
- data/ext/lpsolver-highs/extern/amd/amd_1.c +172 -0
- data/ext/lpsolver-highs/extern/amd/amd_2.c +1761 -0
- data/ext/lpsolver-highs/extern/amd/amd_aat.c +179 -0
- data/ext/lpsolver-highs/extern/amd/amd_control.c +65 -0
- data/ext/lpsolver-highs/extern/amd/amd_defaults.c +37 -0
- data/ext/lpsolver-highs/extern/amd/amd_info.c +120 -0
- data/ext/lpsolver-highs/extern/amd/amd_internal.h +137 -0
- data/ext/lpsolver-highs/extern/amd/amd_order.c +195 -0
- data/ext/lpsolver-highs/extern/amd/amd_post_tree.c +105 -0
- data/ext/lpsolver-highs/extern/amd/amd_postorder.c +140 -0
- data/ext/lpsolver-highs/extern/amd/amd_preprocess.c +107 -0
- data/ext/lpsolver-highs/extern/amd/amd_valid.c +93 -0
- data/ext/lpsolver-highs/extern/amd/changes.txt +8 -0
- data/ext/lpsolver-highs/extern/catch.hpp +18861 -0
- data/ext/lpsolver-highs/extern/metis/Changes.txt +31 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/GKlib.h +62 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/error.c +21 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/gk_arch.h +64 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/gk_defs.h +19 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/gk_macros.h +50 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/gk_mkblas.h +51 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/gk_mkmemory.h +80 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/gk_mkpqueue.h +329 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/gk_mkrandom.h +89 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/gk_mksort.h +271 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/gk_ms_inttypes.h +41 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/gk_ms_stat.h +22 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/gk_ms_stdint.h +41 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/gk_proto.h +50 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/gk_struct.h +66 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/gk_types.h +15 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/mcore.c +176 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/memory.c +23 -0
- data/ext/lpsolver-highs/extern/metis/GKlib/random.c +37 -0
- data/ext/lpsolver-highs/extern/metis/LICENSE.txt +18 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/auxapi.c +27 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/balance.c +491 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/bucketsort.c +44 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/coarsen.c +895 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/compress.c +231 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/contig.c +83 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/defs.h +39 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/fm.c +527 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/gklib.c +55 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/gklib_defs.h +33 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/graph.c +268 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/initpart.c +385 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/macros.h +59 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/mcutil.c +162 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/metislib.h +35 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/mmd.c +598 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/ometis.c +661 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/options.c +260 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/proto.h +172 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/refine.c +99 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/separator.c +57 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/sfm.c +581 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/srefine.c +152 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/stdheaders.h +29 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/struct.h +117 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/util.c +59 -0
- data/ext/lpsolver-highs/extern/metis/libmetis/wspace.c +91 -0
- data/ext/lpsolver-highs/extern/metis/metis.h +271 -0
- data/ext/lpsolver-highs/extern/pdqsort/license.txt +16 -0
- data/ext/lpsolver-highs/extern/pdqsort/pdqsort.h +532 -0
- data/ext/lpsolver-highs/extern/rcm/LICENSE +19 -0
- data/ext/lpsolver-highs/extern/rcm/rcm.cpp +873 -0
- data/ext/lpsolver-highs/extern/rcm/rcm.h +22 -0
- data/ext/lpsolver-highs/extern/zstr/LICENSE +21 -0
- data/ext/lpsolver-highs/extern/zstr/strict_fstream.hpp +237 -0
- data/ext/lpsolver-highs/extern/zstr/zstr.hpp +473 -0
- data/ext/lpsolver-highs/flake.lock +61 -0
- data/ext/lpsolver-highs/flake.nix +73 -0
- data/ext/lpsolver-highs/highs/CMakeLists.txt +499 -0
- data/ext/lpsolver-highs/highs/HConfig.h.bazel.in +25 -0
- data/ext/lpsolver-highs/highs/HConfig.h.in +22 -0
- data/ext/lpsolver-highs/highs/HConfig.h.meson.in +17 -0
- data/ext/lpsolver-highs/highs/Highs.h +1812 -0
- data/ext/lpsolver-highs/highs/HighsRun.md +143 -0
- data/ext/lpsolver-highs/highs/highs_bindings.cpp +1826 -0
- data/ext/lpsolver-highs/highs/highspy/__init__.py +93 -0
- data/ext/lpsolver-highs/highs/highspy/__init__.pyi +91 -0
- data/ext/lpsolver-highs/highs/highspy/_core/__init__.pyi +1058 -0
- data/ext/lpsolver-highs/highs/highspy/_core/cb.pyi +118 -0
- data/ext/lpsolver-highs/highs/highspy/_core/simplex_constants.pyi +472 -0
- data/ext/lpsolver-highs/highs/highspy/highs.py +2430 -0
- data/ext/lpsolver-highs/highs/interfaces/highs_c_api.cpp +1812 -0
- data/ext/lpsolver-highs/highs/interfaces/highs_c_api.h +2651 -0
- data/ext/lpsolver-highs/highs/interfaces/highs_csharp_api.cs +1142 -0
- data/ext/lpsolver-highs/highs/interfaces/highs_fortran_api.f90 +873 -0
- data/ext/lpsolver-highs/highs/io/Filereader.cpp +87 -0
- data/ext/lpsolver-highs/highs/io/Filereader.h +45 -0
- data/ext/lpsolver-highs/highs/io/FilereaderLp.cpp +539 -0
- data/ext/lpsolver-highs/highs/io/FilereaderLp.h +49 -0
- data/ext/lpsolver-highs/highs/io/FilereaderMps.cpp +86 -0
- data/ext/lpsolver-highs/highs/io/FilereaderMps.h +27 -0
- data/ext/lpsolver-highs/highs/io/HMPSIO.cpp +1001 -0
- data/ext/lpsolver-highs/highs/io/HMPSIO.h +78 -0
- data/ext/lpsolver-highs/highs/io/HMpsFF.cpp +2113 -0
- data/ext/lpsolver-highs/highs/io/HMpsFF.h +245 -0
- data/ext/lpsolver-highs/highs/io/HighsIO.cpp +371 -0
- data/ext/lpsolver-highs/highs/io/HighsIO.h +118 -0
- data/ext/lpsolver-highs/highs/io/LoadOptions.cpp +60 -0
- data/ext/lpsolver-highs/highs/io/LoadOptions.h +24 -0
- data/ext/lpsolver-highs/highs/io/filereaderlp/LICENSE +19 -0
- data/ext/lpsolver-highs/highs/io/filereaderlp/builder.hpp +25 -0
- data/ext/lpsolver-highs/highs/io/filereaderlp/def.hpp +19 -0
- data/ext/lpsolver-highs/highs/io/filereaderlp/model.hpp +68 -0
- data/ext/lpsolver-highs/highs/io/filereaderlp/reader.cpp +1375 -0
- data/ext/lpsolver-highs/highs/io/filereaderlp/reader.hpp +10 -0
- data/ext/lpsolver-highs/highs/ipm/IpxSolution.h +32 -0
- data/ext/lpsolver-highs/highs/ipm/IpxWrapper.cpp +1526 -0
- data/ext/lpsolver-highs/highs/ipm/IpxWrapper.h +106 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu.h +161 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_factorize.c +132 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_factorize.h +247 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_get_factors.c +148 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_get_factors.h +108 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_initialize.c +24 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_initialize.h +119 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_obj_factorize.h +34 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_obj_free.h +19 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_obj_get_factors.h +34 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_obj_initialize.h +46 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_obj_solve_dense.h +29 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_obj_solve_for_update.h +42 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_obj_solve_sparse.h +32 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_obj_update.h +31 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_object.c +325 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_object.h +30 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_solve_dense.c +46 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_solve_dense.h +75 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_solve_for_update.c +79 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_solve_for_update.h +169 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_solve_sparse.c +63 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_solve_sparse.h +112 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_update.c +44 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/basiclu_update.h +125 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_build_factors.c +441 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_condest.c +124 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_def.h +39 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_dfs.c +141 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_factorize_bump.c +56 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_file.c +184 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_file.h +21 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_garbage_perm.c +53 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_initialize.c +56 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_internal.c +352 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_internal.h +220 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_list.h +173 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_markowitz.c +188 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_matrix_norm.c +51 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_pivot.c +1247 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_residual_test.c +155 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_setup_bump.c +198 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_singletons.c +511 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_solve_dense.c +129 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_solve_for_update.c +360 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_solve_sparse.c +284 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_solve_symbolic.c +48 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_solve_triangular.c +140 -0
- data/ext/lpsolver-highs/highs/ipm/basiclu/lu_update.c +908 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/auxiliary/Auxiliary.cpp +301 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/auxiliary/Auxiliary.h +104 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/auxiliary/IntConfig.h +27 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/auxiliary/KrylovMethods.cpp +193 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/auxiliary/KrylovMethods.h +30 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/auxiliary/Log.cpp +60 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/auxiliary/Log.h +62 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/auxiliary/OrderingPrint.h +10 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/auxiliary/VectorOperations.cpp +117 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/auxiliary/VectorOperations.h +59 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/auxiliary/mycblas.h +85 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/Analyse.cpp +1367 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/Analyse.h +122 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/CallAndTimeBlas.cpp +114 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/CallAndTimeBlas.h +46 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/CliqueStack.cpp +82 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/CliqueStack.h +83 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/DataCollector.cpp +326 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/DataCollector.h +86 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/DenseFact.h +48 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/DenseFactHybrid.cpp +279 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/DenseFactKernel.cpp +284 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/DgemmParallel.cpp +38 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/DgemmParallel.h +32 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/FactorHiGHS.cpp +57 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/FactorHiGHS.h +112 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/FactorHiGHSSettings.h +63 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/Factorise.cpp +405 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/Factorise.h +85 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/FormatHandler.cpp +46 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/FormatHandler.h +95 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/HybridHybridFormatHandler.cpp +238 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/HybridHybridFormatHandler.h +31 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/HybridSolveHandler.cpp +272 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/HybridSolveHandler.h +26 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/KrylovMethodsIpm.cpp +83 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/KrylovMethodsIpm.h +45 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/Numeric.cpp +54 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/Numeric.h +46 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/ReturnValues.h +19 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/SolveHandler.cpp +10 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/SolveHandler.h +48 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/Swaps.cpp +70 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/Swaps.h +19 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/Symbolic.cpp +101 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/Symbolic.h +220 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/factorhighs/Timing.h +114 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/Control.cpp +38 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/Control.h +41 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/FactorHiGHSSolver.cpp +887 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/FactorHiGHSSolver.h +92 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/Info.h +58 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/IpmData.cpp +8 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/IpmData.h +37 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/Iterate.cpp +640 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/Iterate.h +172 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/LinearSolver.h +81 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/LogHighs.cpp +71 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/LogHighs.h +33 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/Model.cpp +403 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/Model.h +136 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/Options.h +35 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/Parameters.h +63 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/PreProcess.cpp +646 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/PreProcess.h +94 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/Refine.cpp +214 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/Solver.cpp +1346 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/Solver.h +338 -0
- data/ext/lpsolver-highs/highs/ipm/hipo/ipm/Status.h +88 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/basiclu_kernel.cc +71 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/basiclu_kernel.h +20 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/basiclu_wrapper.cc +299 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/basiclu_wrapper.h +47 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/basis.cc +966 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/basis.h +350 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/conjugate_residuals.cc +217 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/conjugate_residuals.h +74 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/control.cc +151 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/control.h +167 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/crossover.cc +479 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/crossover.h +157 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/diagonal_precond.cc +70 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/diagonal_precond.h +45 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/forrest_tomlin.cc +360 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/forrest_tomlin.h +102 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/guess_basis.cc +233 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/guess_basis.h +21 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/indexed_vector.cc +30 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/indexed_vector.h +113 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/info.cc +124 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/info.h +27 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/ipm.cc +897 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/ipm.h +94 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/ipx_c.cc +83 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/ipx_c.h +47 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/ipx_config.h +9 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/ipx_info.h +111 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/ipx_internal.h +89 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/ipx_parameters.h +76 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/ipx_status.h +57 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/iterate.cc +683 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/iterate.h +331 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/kkt_solver.cc +23 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/kkt_solver.h +70 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/kkt_solver_basis.cc +387 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/kkt_solver_basis.h +66 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/kkt_solver_diag.cc +120 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/kkt_solver_diag.h +48 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/linear_operator.cc +10 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/linear_operator.h +26 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/lp_solver.cc +686 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/lp_solver.h +204 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/lu_factorization.cc +131 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/lu_factorization.h +79 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/lu_update.cc +62 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/lu_update.h +129 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/maxvolume.cc +337 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/maxvolume.h +54 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/model.cc +1528 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/model.h +413 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/multistream.h +52 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/normal_matrix.cc +126 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/normal_matrix.h +44 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/power_method.h +44 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/sparse_matrix.cc +382 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/sparse_matrix.h +195 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/sparse_utils.cc +92 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/sparse_utils.h +58 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/splitted_normal_matrix.cc +117 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/splitted_normal_matrix.h +63 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/starting_basis.cc +182 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/starting_basis.h +39 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/symbolic_invert.cc +183 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/symbolic_invert.h +29 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/timer.cc +16 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/timer.h +25 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/utils.cc +95 -0
- data/ext/lpsolver-highs/highs/ipm/ipx/utils.h +37 -0
- data/ext/lpsolver-highs/highs/lp_data/HConst.h +430 -0
- data/ext/lpsolver-highs/highs/lp_data/HStruct.h +213 -0
- data/ext/lpsolver-highs/highs/lp_data/Highs.cpp +4949 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsAnalysis.h +23 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsCallback.cpp +323 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsCallback.h +104 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsCallbackStruct.h +70 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsDebug.cpp +54 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsDebug.h +34 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsDeprecated.cpp +181 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsIis.cpp +1290 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsIis.h +139 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsInfo.cpp +426 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsInfo.h +421 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsInfoDebug.cpp +175 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsInfoDebug.h +27 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsInterface.cpp +4344 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsLp.cpp +564 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsLp.h +97 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsLpSolverObject.h +47 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsLpUtils.cpp +3794 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsLpUtils.h +330 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsModelUtils.cpp +1650 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsModelUtils.h +129 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsOptions.cpp +1176 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsOptions.h +1715 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsRanging.cpp +733 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsRanging.h +43 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsSolution.cpp +2194 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsSolution.h +179 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsSolutionDebug.cpp +490 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsSolutionDebug.h +87 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsSolve.cpp +747 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsSolve.h +29 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsStatus.cpp +48 -0
- data/ext/lpsolver-highs/highs/lp_data/HighsStatus.h +29 -0
- data/ext/lpsolver-highs/highs/lp_data/Iis.md +113 -0
- data/ext/lpsolver-highs/highs/meson.build +433 -0
- data/ext/lpsolver-highs/highs/mip/HighsCliqueTable.cpp +2236 -0
- data/ext/lpsolver-highs/highs/mip/HighsCliqueTable.h +329 -0
- data/ext/lpsolver-highs/highs/mip/HighsConflictPool.cpp +201 -0
- data/ext/lpsolver-highs/highs/mip/HighsConflictPool.h +109 -0
- data/ext/lpsolver-highs/highs/mip/HighsCutGeneration.cpp +1491 -0
- data/ext/lpsolver-highs/highs/mip/HighsCutGeneration.h +108 -0
- data/ext/lpsolver-highs/highs/mip/HighsCutPool.cpp +526 -0
- data/ext/lpsolver-highs/highs/mip/HighsCutPool.h +168 -0
- data/ext/lpsolver-highs/highs/mip/HighsDebugSol.cpp +313 -0
- data/ext/lpsolver-highs/highs/mip/HighsDebugSol.h +133 -0
- data/ext/lpsolver-highs/highs/mip/HighsDomain.cpp +3861 -0
- data/ext/lpsolver-highs/highs/mip/HighsDomain.h +657 -0
- data/ext/lpsolver-highs/highs/mip/HighsDomainChange.h +48 -0
- data/ext/lpsolver-highs/highs/mip/HighsDynamicRowMatrix.cpp +199 -0
- data/ext/lpsolver-highs/highs/mip/HighsDynamicRowMatrix.h +104 -0
- data/ext/lpsolver-highs/highs/mip/HighsFeasibilityJump.cpp +139 -0
- data/ext/lpsolver-highs/highs/mip/HighsGFkSolve.cpp +106 -0
- data/ext/lpsolver-highs/highs/mip/HighsGFkSolve.h +439 -0
- data/ext/lpsolver-highs/highs/mip/HighsImplications.cpp +915 -0
- data/ext/lpsolver-highs/highs/mip/HighsImplications.h +194 -0
- data/ext/lpsolver-highs/highs/mip/HighsLpAggregator.cpp +56 -0
- data/ext/lpsolver-highs/highs/mip/HighsLpAggregator.h +50 -0
- data/ext/lpsolver-highs/highs/mip/HighsLpRelaxation.cpp +1609 -0
- data/ext/lpsolver-highs/highs/mip/HighsLpRelaxation.h +361 -0
- data/ext/lpsolver-highs/highs/mip/HighsMipAnalysis.cpp +313 -0
- data/ext/lpsolver-highs/highs/mip/HighsMipAnalysis.h +71 -0
- data/ext/lpsolver-highs/highs/mip/HighsMipSolver.cpp +1002 -0
- data/ext/lpsolver-highs/highs/mip/HighsMipSolver.h +159 -0
- data/ext/lpsolver-highs/highs/mip/HighsMipSolverData.cpp +2936 -0
- data/ext/lpsolver-highs/highs/mip/HighsMipSolverData.h +313 -0
- data/ext/lpsolver-highs/highs/mip/HighsModkSeparator.cpp +267 -0
- data/ext/lpsolver-highs/highs/mip/HighsModkSeparator.h +60 -0
- data/ext/lpsolver-highs/highs/mip/HighsNodeQueue.cpp +443 -0
- data/ext/lpsolver-highs/highs/mip/HighsNodeQueue.h +312 -0
- data/ext/lpsolver-highs/highs/mip/HighsObjectiveFunction.cpp +124 -0
- data/ext/lpsolver-highs/highs/mip/HighsObjectiveFunction.h +71 -0
- data/ext/lpsolver-highs/highs/mip/HighsPathSeparator.cpp +549 -0
- data/ext/lpsolver-highs/highs/mip/HighsPathSeparator.h +39 -0
- data/ext/lpsolver-highs/highs/mip/HighsPrimalHeuristics.cpp +1673 -0
- data/ext/lpsolver-highs/highs/mip/HighsPrimalHeuristics.h +75 -0
- data/ext/lpsolver-highs/highs/mip/HighsPseudocost.cpp +129 -0
- data/ext/lpsolver-highs/highs/mip/HighsPseudocost.h +366 -0
- data/ext/lpsolver-highs/highs/mip/HighsRedcostFixing.cpp +316 -0
- data/ext/lpsolver-highs/highs/mip/HighsRedcostFixing.h +42 -0
- data/ext/lpsolver-highs/highs/mip/HighsSearch.cpp +1881 -0
- data/ext/lpsolver-highs/highs/mip/HighsSearch.h +241 -0
- data/ext/lpsolver-highs/highs/mip/HighsSeparation.cpp +186 -0
- data/ext/lpsolver-highs/highs/mip/HighsSeparation.h +41 -0
- data/ext/lpsolver-highs/highs/mip/HighsSeparator.cpp +39 -0
- data/ext/lpsolver-highs/highs/mip/HighsSeparator.h +60 -0
- data/ext/lpsolver-highs/highs/mip/HighsTableauSeparator.cpp +244 -0
- data/ext/lpsolver-highs/highs/mip/HighsTableauSeparator.h +34 -0
- data/ext/lpsolver-highs/highs/mip/HighsTransformedLp.cpp +563 -0
- data/ext/lpsolver-highs/highs/mip/HighsTransformedLp.h +63 -0
- data/ext/lpsolver-highs/highs/mip/MipTimer.h +544 -0
- data/ext/lpsolver-highs/highs/mip/feasibilityjump.hh +800 -0
- data/ext/lpsolver-highs/highs/model/HighsHessian.cpp +263 -0
- data/ext/lpsolver-highs/highs/model/HighsHessian.h +54 -0
- data/ext/lpsolver-highs/highs/model/HighsHessianUtils.cpp +584 -0
- data/ext/lpsolver-highs/highs/model/HighsHessianUtils.h +47 -0
- data/ext/lpsolver-highs/highs/model/HighsModel.cpp +46 -0
- data/ext/lpsolver-highs/highs/model/HighsModel.h +42 -0
- data/ext/lpsolver-highs/highs/parallel/HighsBinarySemaphore.h +108 -0
- data/ext/lpsolver-highs/highs/parallel/HighsCacheAlign.h +82 -0
- data/ext/lpsolver-highs/highs/parallel/HighsCombinable.h +116 -0
- data/ext/lpsolver-highs/highs/parallel/HighsMutex.h +124 -0
- data/ext/lpsolver-highs/highs/parallel/HighsParallel.h +128 -0
- data/ext/lpsolver-highs/highs/parallel/HighsRaceTimer.h +38 -0
- data/ext/lpsolver-highs/highs/parallel/HighsSchedulerConstants.h +19 -0
- data/ext/lpsolver-highs/highs/parallel/HighsSpinMutex.h +48 -0
- data/ext/lpsolver-highs/highs/parallel/HighsSplitDeque.h +606 -0
- data/ext/lpsolver-highs/highs/parallel/HighsTask.h +170 -0
- data/ext/lpsolver-highs/highs/parallel/HighsTaskExecutor.cpp +43 -0
- data/ext/lpsolver-highs/highs/parallel/HighsTaskExecutor.h +217 -0
- data/ext/lpsolver-highs/highs/pdlp/CupdlpWrapper.cpp +848 -0
- data/ext/lpsolver-highs/highs/pdlp/CupdlpWrapper.h +108 -0
- data/ext/lpsolver-highs/highs/pdlp/HiPdlpTimer.h +155 -0
- data/ext/lpsolver-highs/highs/pdlp/HiPdlpWrapper.cpp +141 -0
- data/ext/lpsolver-highs/highs/pdlp/HiPdlpWrapper.h +26 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/Diff +12 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/Meld +7 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/Merge +2 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/README.md +95 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cuda/CMakeLists.txt +58 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cuda/cupdlp_cuda_kernels.cu +338 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cuda/cupdlp_cuda_kernels.cuh +319 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cuda/cupdlp_cudalinalg.cu +386 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cuda/cupdlp_cudalinalg.cuh +149 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cuda/test_cublas.c +154 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cuda/test_cuda_linalg.c +79 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp.h +16 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_cs.c +214 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_cs.h +40 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_defs.h +447 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_linalg.c +802 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_linalg.h +189 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_proj.c +148 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_proj.h +19 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_restart.c +124 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_restart.h +31 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_scaling.c +425 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_scaling.h +26 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_solver.c +1498 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_solver.h +105 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_step.c +478 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_step.h +37 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_utils.c +1850 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/cupdlp_utils.h +212 -0
- data/ext/lpsolver-highs/highs/pdlp/cupdlp/glbopts.h +342 -0
- data/ext/lpsolver-highs/highs/pdlp/hipdlp/defs.hpp +222 -0
- data/ext/lpsolver-highs/highs/pdlp/hipdlp/linalg.cc +231 -0
- data/ext/lpsolver-highs/highs/pdlp/hipdlp/linalg.hpp +61 -0
- data/ext/lpsolver-highs/highs/pdlp/hipdlp/logger.cc +225 -0
- data/ext/lpsolver-highs/highs/pdlp/hipdlp/logger.hpp +80 -0
- data/ext/lpsolver-highs/highs/pdlp/hipdlp/pdhg.cc +2798 -0
- data/ext/lpsolver-highs/highs/pdlp/hipdlp/pdhg.cu +497 -0
- data/ext/lpsolver-highs/highs/pdlp/hipdlp/pdhg.hpp +358 -0
- data/ext/lpsolver-highs/highs/pdlp/hipdlp/pdhg_kernels.hpp +77 -0
- data/ext/lpsolver-highs/highs/pdlp/hipdlp/pdlp_gpu_debug.hpp +62 -0
- data/ext/lpsolver-highs/highs/pdlp/hipdlp/restart.cc +132 -0
- data/ext/lpsolver-highs/highs/pdlp/hipdlp/restart.hpp +96 -0
- data/ext/lpsolver-highs/highs/pdlp/hipdlp/scaling.cc +307 -0
- data/ext/lpsolver-highs/highs/pdlp/hipdlp/scaling.hpp +74 -0
- data/ext/lpsolver-highs/highs/pdlp/hipdlp/solver_results.hpp +65 -0
- data/ext/lpsolver-highs/highs/presolve/HPresolve.cpp +8511 -0
- data/ext/lpsolver-highs/highs/presolve/HPresolve.h +505 -0
- data/ext/lpsolver-highs/highs/presolve/HPresolveAnalysis.cpp +239 -0
- data/ext/lpsolver-highs/highs/presolve/HPresolveAnalysis.h +52 -0
- data/ext/lpsolver-highs/highs/presolve/HighsPostsolveStack.cpp +1368 -0
- data/ext/lpsolver-highs/highs/presolve/HighsPostsolveStack.h +943 -0
- data/ext/lpsolver-highs/highs/presolve/HighsSymmetry.cpp +1921 -0
- data/ext/lpsolver-highs/highs/presolve/HighsSymmetry.h +284 -0
- data/ext/lpsolver-highs/highs/presolve/ICrash.cpp +474 -0
- data/ext/lpsolver-highs/highs/presolve/ICrash.h +124 -0
- data/ext/lpsolver-highs/highs/presolve/ICrashUtil.cpp +267 -0
- data/ext/lpsolver-highs/highs/presolve/ICrashUtil.h +62 -0
- data/ext/lpsolver-highs/highs/presolve/ICrashX.cpp +173 -0
- data/ext/lpsolver-highs/highs/presolve/ICrashX.h +23 -0
- data/ext/lpsolver-highs/highs/presolve/PresolveComponent.cpp +45 -0
- data/ext/lpsolver-highs/highs/presolve/PresolveComponent.h +90 -0
- data/ext/lpsolver-highs/highs/qpsolver/README.md +185 -0
- data/ext/lpsolver-highs/highs/qpsolver/a_asm.cpp +139 -0
- data/ext/lpsolver-highs/highs/qpsolver/a_asm.hpp +77 -0
- data/ext/lpsolver-highs/highs/qpsolver/a_quass.cpp +194 -0
- data/ext/lpsolver-highs/highs/qpsolver/a_quass.hpp +22 -0
- data/ext/lpsolver-highs/highs/qpsolver/basis.cpp +443 -0
- data/ext/lpsolver-highs/highs/qpsolver/basis.hpp +159 -0
- data/ext/lpsolver-highs/highs/qpsolver/crashsolution.hpp +20 -0
- data/ext/lpsolver-highs/highs/qpsolver/dantzigpricing.hpp +80 -0
- data/ext/lpsolver-highs/highs/qpsolver/devexharrispricing.hpp +98 -0
- data/ext/lpsolver-highs/highs/qpsolver/devexpricing.hpp +108 -0
- data/ext/lpsolver-highs/highs/qpsolver/eventhandler.hpp +30 -0
- data/ext/lpsolver-highs/highs/qpsolver/factor.hpp +408 -0
- data/ext/lpsolver-highs/highs/qpsolver/feasibility_bounded.hpp +114 -0
- data/ext/lpsolver-highs/highs/qpsolver/feasibility_highs.hpp +301 -0
- data/ext/lpsolver-highs/highs/qpsolver/gradient.hpp +46 -0
- data/ext/lpsolver-highs/highs/qpsolver/instance.hpp +70 -0
- data/ext/lpsolver-highs/highs/qpsolver/matrix.hpp +342 -0
- data/ext/lpsolver-highs/highs/qpsolver/perturbation.cpp +41 -0
- data/ext/lpsolver-highs/highs/qpsolver/perturbation.hpp +15 -0
- data/ext/lpsolver-highs/highs/qpsolver/pricing.hpp +22 -0
- data/ext/lpsolver-highs/highs/qpsolver/qpconst.hpp +34 -0
- data/ext/lpsolver-highs/highs/qpsolver/qpvector.hpp +242 -0
- data/ext/lpsolver-highs/highs/qpsolver/quass.cpp +551 -0
- data/ext/lpsolver-highs/highs/qpsolver/quass.hpp +27 -0
- data/ext/lpsolver-highs/highs/qpsolver/ratiotest.cpp +146 -0
- data/ext/lpsolver-highs/highs/qpsolver/ratiotest.hpp +26 -0
- data/ext/lpsolver-highs/highs/qpsolver/reducedcosts.hpp +46 -0
- data/ext/lpsolver-highs/highs/qpsolver/reducedgradient.hpp +95 -0
- data/ext/lpsolver-highs/highs/qpsolver/runtime.hpp +45 -0
- data/ext/lpsolver-highs/highs/qpsolver/scaling.cpp +123 -0
- data/ext/lpsolver-highs/highs/qpsolver/scaling.hpp +15 -0
- data/ext/lpsolver-highs/highs/qpsolver/settings.hpp +84 -0
- data/ext/lpsolver-highs/highs/qpsolver/snippets.hpp +36 -0
- data/ext/lpsolver-highs/highs/qpsolver/statistics.hpp +30 -0
- data/ext/lpsolver-highs/highs/qpsolver/steepestedgepricing.hpp +173 -0
- data/ext/lpsolver-highs/highs/simplex/HApp.h +550 -0
- data/ext/lpsolver-highs/highs/simplex/HEkk.cpp +4404 -0
- data/ext/lpsolver-highs/highs/simplex/HEkk.h +419 -0
- data/ext/lpsolver-highs/highs/simplex/HEkkControl.cpp +146 -0
- data/ext/lpsolver-highs/highs/simplex/HEkkDebug.cpp +1722 -0
- data/ext/lpsolver-highs/highs/simplex/HEkkDual.cpp +3003 -0
- data/ext/lpsolver-highs/highs/simplex/HEkkDual.h +513 -0
- data/ext/lpsolver-highs/highs/simplex/HEkkDualMulti.cpp +1020 -0
- data/ext/lpsolver-highs/highs/simplex/HEkkDualRHS.cpp +535 -0
- data/ext/lpsolver-highs/highs/simplex/HEkkDualRHS.h +134 -0
- data/ext/lpsolver-highs/highs/simplex/HEkkDualRow.cpp +697 -0
- data/ext/lpsolver-highs/highs/simplex/HEkkDualRow.h +201 -0
- data/ext/lpsolver-highs/highs/simplex/HEkkInterface.cpp +26 -0
- data/ext/lpsolver-highs/highs/simplex/HEkkPrimal.cpp +2984 -0
- data/ext/lpsolver-highs/highs/simplex/HEkkPrimal.h +191 -0
- data/ext/lpsolver-highs/highs/simplex/HSimplex.cpp +330 -0
- data/ext/lpsolver-highs/highs/simplex/HSimplex.h +42 -0
- data/ext/lpsolver-highs/highs/simplex/HSimplexDebug.cpp +145 -0
- data/ext/lpsolver-highs/highs/simplex/HSimplexDebug.h +48 -0
- data/ext/lpsolver-highs/highs/simplex/HSimplexNla.cpp +517 -0
- data/ext/lpsolver-highs/highs/simplex/HSimplexNla.h +158 -0
- data/ext/lpsolver-highs/highs/simplex/HSimplexNlaDebug.cpp +373 -0
- data/ext/lpsolver-highs/highs/simplex/HSimplexNlaFreeze.cpp +28 -0
- data/ext/lpsolver-highs/highs/simplex/HSimplexNlaProductForm.cpp +113 -0
- data/ext/lpsolver-highs/highs/simplex/HSimplexReport.cpp +77 -0
- data/ext/lpsolver-highs/highs/simplex/HSimplexReport.h +21 -0
- data/ext/lpsolver-highs/highs/simplex/HighsSimplexAnalysis.cpp +1495 -0
- data/ext/lpsolver-highs/highs/simplex/HighsSimplexAnalysis.h +500 -0
- data/ext/lpsolver-highs/highs/simplex/SimplexConst.h +273 -0
- data/ext/lpsolver-highs/highs/simplex/SimplexStruct.h +263 -0
- data/ext/lpsolver-highs/highs/simplex/SimplexTimer.h +414 -0
- data/ext/lpsolver-highs/highs/test_kkt/DevKkt.cpp +469 -0
- data/ext/lpsolver-highs/highs/test_kkt/DevKkt.h +143 -0
- data/ext/lpsolver-highs/highs/test_kkt/KktCh2.cpp +305 -0
- data/ext/lpsolver-highs/highs/test_kkt/KktCh2.h +79 -0
- data/ext/lpsolver-highs/highs/util/FactorTimer.h +199 -0
- data/ext/lpsolver-highs/highs/util/HFactor.cpp +2597 -0
- data/ext/lpsolver-highs/highs/util/HFactor.h +587 -0
- data/ext/lpsolver-highs/highs/util/HFactorConst.h +81 -0
- data/ext/lpsolver-highs/highs/util/HFactorDebug.cpp +231 -0
- data/ext/lpsolver-highs/highs/util/HFactorDebug.h +55 -0
- data/ext/lpsolver-highs/highs/util/HFactorExtend.cpp +229 -0
- data/ext/lpsolver-highs/highs/util/HFactorRefactor.cpp +304 -0
- data/ext/lpsolver-highs/highs/util/HFactorUtils.cpp +122 -0
- data/ext/lpsolver-highs/highs/util/HSet.cpp +197 -0
- data/ext/lpsolver-highs/highs/util/HSet.h +89 -0
- data/ext/lpsolver-highs/highs/util/HVector.h +22 -0
- data/ext/lpsolver-highs/highs/util/HVectorBase.cpp +271 -0
- data/ext/lpsolver-highs/highs/util/HVectorBase.h +102 -0
- data/ext/lpsolver-highs/highs/util/HighsCDouble.h +323 -0
- data/ext/lpsolver-highs/highs/util/HighsComponent.h +53 -0
- data/ext/lpsolver-highs/highs/util/HighsDataStack.h +83 -0
- data/ext/lpsolver-highs/highs/util/HighsDisjointSets.h +107 -0
- data/ext/lpsolver-highs/highs/util/HighsHash.cpp +10 -0
- data/ext/lpsolver-highs/highs/util/HighsHash.h +1274 -0
- data/ext/lpsolver-highs/highs/util/HighsHashTree.h +1461 -0
- data/ext/lpsolver-highs/highs/util/HighsInt.h +36 -0
- data/ext/lpsolver-highs/highs/util/HighsIntegers.h +212 -0
- data/ext/lpsolver-highs/highs/util/HighsLinearSumBounds.cpp +267 -0
- data/ext/lpsolver-highs/highs/util/HighsLinearSumBounds.h +203 -0
- data/ext/lpsolver-highs/highs/util/HighsMatrixPic.cpp +146 -0
- data/ext/lpsolver-highs/highs/util/HighsMatrixPic.h +37 -0
- data/ext/lpsolver-highs/highs/util/HighsMatrixSlice.h +561 -0
- data/ext/lpsolver-highs/highs/util/HighsMatrixUtils.cpp +407 -0
- data/ext/lpsolver-highs/highs/util/HighsMatrixUtils.h +57 -0
- data/ext/lpsolver-highs/highs/util/HighsMemoryAllocation.h +63 -0
- data/ext/lpsolver-highs/highs/util/HighsRandom.h +242 -0
- data/ext/lpsolver-highs/highs/util/HighsRbTree.h +452 -0
- data/ext/lpsolver-highs/highs/util/HighsSort.cpp +364 -0
- data/ext/lpsolver-highs/highs/util/HighsSort.h +131 -0
- data/ext/lpsolver-highs/highs/util/HighsSparseMatrix.cpp +1746 -0
- data/ext/lpsolver-highs/highs/util/HighsSparseMatrix.h +151 -0
- data/ext/lpsolver-highs/highs/util/HighsSparseVectorSum.h +95 -0
- data/ext/lpsolver-highs/highs/util/HighsSplay.h +135 -0
- data/ext/lpsolver-highs/highs/util/HighsTimer.h +385 -0
- data/ext/lpsolver-highs/highs/util/HighsUtils.cpp +1259 -0
- data/ext/lpsolver-highs/highs/util/HighsUtils.h +272 -0
- data/ext/lpsolver-highs/highs/util/stringutil.cpp +131 -0
- data/ext/lpsolver-highs/highs/util/stringutil.h +46 -0
- data/ext/lpsolver-highs/highs.pc.in +12 -0
- data/ext/lpsolver-highs/meson.build +198 -0
- data/ext/lpsolver-highs/meson_options.txt +31 -0
- data/ext/lpsolver-highs/nuget/HiGHS_Logo.png +0 -0
- data/ext/lpsolver-highs/nuget/Highs.csproj +25 -0
- data/ext/lpsolver-highs/nuget/Highs.csproj.in +36 -0
- data/ext/lpsolver-highs/nuget/HowToAlternative.md +77 -0
- data/ext/lpsolver-highs/nuget/README.md +38 -0
- data/ext/lpsolver-highs/nuget/arm-toolchain.cmake +15 -0
- data/ext/lpsolver-highs/nuget/build_linux-arm.sh +13 -0
- data/ext/lpsolver-highs/nuget/build_linux.sh +10 -0
- data/ext/lpsolver-highs/nuget/build_windows.ps1 +27 -0
- data/ext/lpsolver-highs/nuget/generatePackage.ps1 +28 -0
- data/ext/lpsolver-highs/pyproject.toml +221 -0
- data/ext/lpsolver-highs/subprojects/pybind11.wrap +13 -0
- data/ext/lpsolver-highs/tests/test_highspy.py +2310 -0
- data/ext/lpsolver-highs/version.rc.in +50 -0
- data/lib/lpsolver/highs +0 -0
- data/lib/lpsolver/model.rb +28 -4
- data/lib/lpsolver/native.so +0 -0
- data/lib/lpsolver/native_model.rb +261 -0
- data/lib/lpsolver/solution.rb +72 -7
- data/lib/lpsolver/version.rb +1 -1
- data/lpsolver.gemspec +4 -1
- metadata +1176 -4
|
@@ -0,0 +1,2310 @@
|
|
|
1
|
+
import tempfile
|
|
2
|
+
import unittest
|
|
3
|
+
import highspy
|
|
4
|
+
from highspy.highs import highs_linear_expression, qsum
|
|
5
|
+
import numpy as np
|
|
6
|
+
from sys import platform
|
|
7
|
+
import signal
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class TestHighsPy(unittest.TestCase):
|
|
11
|
+
def assertEqualExpr(self, expr, idxs, vals, constant=None, bounds=None):
|
|
12
|
+
self.assertEqual(list(map(int, expr.idxs)), list(map(int, idxs)), "variable index")
|
|
13
|
+
self.assertEqual(expr.vals, vals, "variable values")
|
|
14
|
+
self.assertEqual(expr.constant, constant, "constant")
|
|
15
|
+
self.assertEqual(expr.bounds, (bounds[0], bounds[1]) if bounds is not None else None, "bounds")
|
|
16
|
+
|
|
17
|
+
def get_basic_model(self):
|
|
18
|
+
"""
|
|
19
|
+
min y
|
|
20
|
+
s.t.
|
|
21
|
+
-x + y >= 2
|
|
22
|
+
x + y >= 0
|
|
23
|
+
"""
|
|
24
|
+
inf = highspy.kHighsInf
|
|
25
|
+
h = highspy.Highs()
|
|
26
|
+
h.setOptionValue("output_flag", False)
|
|
27
|
+
h.addVars(2, np.array([-inf, -inf]), np.array([inf, inf]))
|
|
28
|
+
h.changeColsCost(2, np.array([0, 1]), np.array([0, 1], dtype=np.double))
|
|
29
|
+
num_cons = 2
|
|
30
|
+
lower = np.array([2, 0], dtype=np.double)
|
|
31
|
+
upper = np.array([inf, inf], dtype=np.double)
|
|
32
|
+
num_new_nz = 4
|
|
33
|
+
starts = np.array([0, 2])
|
|
34
|
+
indices = np.array([0, 1, 0, 1])
|
|
35
|
+
values = np.array([-1, 1, 1, 1], dtype=np.double)
|
|
36
|
+
h.addRows(num_cons, lower, upper, num_new_nz, starts, indices, values)
|
|
37
|
+
return h
|
|
38
|
+
|
|
39
|
+
def get_example_model(self):
|
|
40
|
+
"""
|
|
41
|
+
minimize f = x0 + x1
|
|
42
|
+
subject to x1 <= 7
|
|
43
|
+
5 <= x0 + 2x1 <= 15
|
|
44
|
+
6 <= 3x0 + 2x1
|
|
45
|
+
0 <= x0 <= 4; 1 <= x1
|
|
46
|
+
"""
|
|
47
|
+
inf = highspy.kHighsInf
|
|
48
|
+
h = highspy.Highs()
|
|
49
|
+
# Define a HighsLp instance
|
|
50
|
+
lp = highspy.HighsLp()
|
|
51
|
+
lp.num_col_ = 2
|
|
52
|
+
lp.num_row_ = 3
|
|
53
|
+
lp.col_cost_ = np.array([1, 1], dtype=np.double)
|
|
54
|
+
lp.col_lower_ = np.array([0, 1], dtype=np.double)
|
|
55
|
+
lp.col_upper_ = np.array([4, inf], dtype=np.double)
|
|
56
|
+
lp.row_lower_ = np.array([-inf, 5, 6], dtype=np.double)
|
|
57
|
+
lp.row_upper_ = np.array([7, 15, inf], dtype=np.double)
|
|
58
|
+
lp.a_matrix_.start_ = np.array([0, 2, 5])
|
|
59
|
+
lp.a_matrix_.index_ = np.array([1, 2, 0, 1, 2])
|
|
60
|
+
lp.a_matrix_.value_ = np.array([1, 3, 1, 2, 2], dtype=np.double)
|
|
61
|
+
h.passModel(lp)
|
|
62
|
+
return h
|
|
63
|
+
|
|
64
|
+
def test_example_model_builder(self):
|
|
65
|
+
"""
|
|
66
|
+
minimize f = x0 + x1
|
|
67
|
+
subject to x1 <= 7
|
|
68
|
+
5 <= x0 + 2x1 <= 15
|
|
69
|
+
6 <= 3x0 + 2x1
|
|
70
|
+
0 <= x0 <= 4; 1 <= x1
|
|
71
|
+
"""
|
|
72
|
+
h = highspy.Highs()
|
|
73
|
+
|
|
74
|
+
x0 = h.addVariable(lb=0, ub=4, obj=1)
|
|
75
|
+
x1 = h.addVariable(lb=1, ub=7, obj=1)
|
|
76
|
+
|
|
77
|
+
h.addConstr(5 <= x0 + 2 * x1 <= 15)
|
|
78
|
+
h.addConstr(6 <= 3 * x0 + 2 * x1)
|
|
79
|
+
|
|
80
|
+
lp = h.getLp()
|
|
81
|
+
|
|
82
|
+
self.assertEqual(lp.num_col_, 2)
|
|
83
|
+
self.assertEqual(lp.num_row_, 2)
|
|
84
|
+
self.assertAlmostEqual(lp.col_cost_[0], 1)
|
|
85
|
+
self.assertAlmostEqual(lp.col_lower_[0], 0)
|
|
86
|
+
self.assertAlmostEqual(lp.col_upper_[0], 4)
|
|
87
|
+
self.assertAlmostEqual(lp.row_lower_[0], 5)
|
|
88
|
+
self.assertAlmostEqual(lp.row_upper_[0], 15)
|
|
89
|
+
self.assertAlmostEqual(lp.row_lower_[1], 6)
|
|
90
|
+
self.assertAlmostEqual(lp.row_upper_[1], highspy.kHighsInf)
|
|
91
|
+
|
|
92
|
+
def get_infeasible_model(self):
|
|
93
|
+
inf = highspy.kHighsInf
|
|
94
|
+
lp = highspy.HighsLp()
|
|
95
|
+
lp.num_col_ = 2
|
|
96
|
+
lp.num_row_ = 2
|
|
97
|
+
lp.col_cost_ = np.array([10, 15], dtype=np.double)
|
|
98
|
+
lp.col_lower_ = np.array([0, 0], dtype=np.double)
|
|
99
|
+
lp.col_upper_ = np.array([inf, inf], dtype=np.double)
|
|
100
|
+
lp.row_lower_ = np.array([3, 1], dtype=np.double)
|
|
101
|
+
lp.row_upper_ = np.array([3, 1], dtype=np.double)
|
|
102
|
+
lp.a_matrix_.start_ = np.array([0, 2, 4])
|
|
103
|
+
lp.a_matrix_.index_ = np.array([0, 1, 0, 1])
|
|
104
|
+
lp.a_matrix_.value_ = np.array([2, 1, 1, 3], dtype=np.double)
|
|
105
|
+
lp.offset_ = 0
|
|
106
|
+
h = highspy.Highs()
|
|
107
|
+
h.setOptionValue("output_flag", False)
|
|
108
|
+
status = h.passModel(lp)
|
|
109
|
+
self.assertEqual(status, highspy.HighsStatus.kOk)
|
|
110
|
+
h.setOptionValue("presolve", "off")
|
|
111
|
+
return h
|
|
112
|
+
|
|
113
|
+
def test_version(self):
|
|
114
|
+
h = self.get_basic_model()
|
|
115
|
+
self.assertEqual(h.version(), "1.14.0")
|
|
116
|
+
self.assertEqual(h.versionMajor(), 1)
|
|
117
|
+
self.assertEqual(h.versionMinor(), 14)
|
|
118
|
+
self.assertEqual(h.versionPatch(), 0)
|
|
119
|
+
|
|
120
|
+
def test_basics(self):
|
|
121
|
+
h = self.get_basic_model()
|
|
122
|
+
h.passColName(0, "Col0")
|
|
123
|
+
h.passColName(1, "Col1")
|
|
124
|
+
h.passRowName(0, "Row0")
|
|
125
|
+
h.passRowName(1, "Row1")
|
|
126
|
+
# h.setOptionValue('output_flag', True)
|
|
127
|
+
h.writeModel("")
|
|
128
|
+
h.setOptionValue("output_flag", False)
|
|
129
|
+
self.assertEqual(h.setOptionValue("presolve", "off"), highspy.HighsStatus.kOk)
|
|
130
|
+
# h.setOptionValue('output_flag', True)
|
|
131
|
+
h.run()
|
|
132
|
+
|
|
133
|
+
# Info can be obtained from the class instance, specific call
|
|
134
|
+
# and, in the case of objective_function_value,
|
|
135
|
+
# h.getObjectiveValue()
|
|
136
|
+
info = h.getInfo()
|
|
137
|
+
objective_function_value0 = info.objective_function_value
|
|
138
|
+
self.assertAlmostEqual(objective_function_value0, 1)
|
|
139
|
+
[status, objective_function_value1] = h.getInfoValue("objective_function_value")
|
|
140
|
+
self.assertAlmostEqual(objective_function_value0, objective_function_value1)
|
|
141
|
+
self.assertAlmostEqual(h.getObjectiveValue(), objective_function_value0)
|
|
142
|
+
|
|
143
|
+
simplex_iteration_count0 = info.simplex_iteration_count
|
|
144
|
+
self.assertAlmostEqual(simplex_iteration_count0, 2)
|
|
145
|
+
[status, simplex_iteration_count1] = h.getInfoValue("simplex_iteration_count")
|
|
146
|
+
self.assertAlmostEqual(simplex_iteration_count0, simplex_iteration_count1)
|
|
147
|
+
|
|
148
|
+
sol = h.getSolution()
|
|
149
|
+
self.assertAlmostEqual(sol.col_value[0], -1)
|
|
150
|
+
self.assertAlmostEqual(sol.col_value[1], 1)
|
|
151
|
+
|
|
152
|
+
# h.setOptionValue('output_flag', False)
|
|
153
|
+
"""
|
|
154
|
+
min y
|
|
155
|
+
s.t.
|
|
156
|
+
-x + y >= 3
|
|
157
|
+
x + y >= 0
|
|
158
|
+
"""
|
|
159
|
+
inf = highspy.kHighsInf
|
|
160
|
+
h.changeRowBounds(0, 3, inf)
|
|
161
|
+
h.run()
|
|
162
|
+
sol = h.getSolution()
|
|
163
|
+
self.assertAlmostEqual(sol.col_value[0], -1.5)
|
|
164
|
+
self.assertAlmostEqual(sol.col_value[1], 1.5)
|
|
165
|
+
|
|
166
|
+
# now make y integer
|
|
167
|
+
h.changeColsIntegrality(1, np.array([1]), np.array([highspy.HighsVarType.kInteger]))
|
|
168
|
+
h.run()
|
|
169
|
+
sol = h.getSolution()
|
|
170
|
+
self.assertAlmostEqual(sol.col_value[0], -1.5)
|
|
171
|
+
self.assertAlmostEqual(sol.col_value[1], 2)
|
|
172
|
+
|
|
173
|
+
"""
|
|
174
|
+
now delete the first constraint and add a new one
|
|
175
|
+
|
|
176
|
+
min y
|
|
177
|
+
s.t.
|
|
178
|
+
x + y >= 0
|
|
179
|
+
-x + y >= 0
|
|
180
|
+
"""
|
|
181
|
+
h.deleteRows(1, np.array([0]))
|
|
182
|
+
h.addRows(1, np.array([0], dtype=np.double), np.array([inf]), 2, np.array([0]), np.array([0, 1]), np.array([-1, 1], dtype=np.double))
|
|
183
|
+
h.run()
|
|
184
|
+
sol = h.getSolution()
|
|
185
|
+
self.assertAlmostEqual(sol.col_value[0], 0)
|
|
186
|
+
self.assertAlmostEqual(sol.col_value[1], 0)
|
|
187
|
+
|
|
188
|
+
# change the upper bound of x to -5
|
|
189
|
+
h.changeColsBounds(1, np.array([0]), np.array([-inf], dtype=np.double), np.array([-5], dtype=np.double))
|
|
190
|
+
h.run()
|
|
191
|
+
sol = h.getSolution()
|
|
192
|
+
self.assertAlmostEqual(sol.col_value[0], -5)
|
|
193
|
+
self.assertAlmostEqual(sol.col_value[1], 5)
|
|
194
|
+
|
|
195
|
+
# now maximize
|
|
196
|
+
h.changeColCost(1, -1)
|
|
197
|
+
h.changeRowBounds(0, -inf, 0)
|
|
198
|
+
h.changeRowBounds(1, -inf, 0)
|
|
199
|
+
h.run()
|
|
200
|
+
sol = h.getSolution()
|
|
201
|
+
self.assertAlmostEqual(sol.col_value[0], -5)
|
|
202
|
+
self.assertAlmostEqual(sol.col_value[1], -5)
|
|
203
|
+
|
|
204
|
+
h.changeColCost(1, 1)
|
|
205
|
+
[status, sense] = h.getObjectiveSense()
|
|
206
|
+
self.assertEqual(sense, highspy.ObjSense.kMinimize)
|
|
207
|
+
h.changeObjectiveSense(highspy.ObjSense.kMaximize)
|
|
208
|
+
[status, sense] = h.getObjectiveSense()
|
|
209
|
+
self.assertEqual(sense, highspy.ObjSense.kMaximize)
|
|
210
|
+
h.run()
|
|
211
|
+
sol = h.getSolution()
|
|
212
|
+
self.assertAlmostEqual(sol.col_value[0], -5)
|
|
213
|
+
self.assertAlmostEqual(sol.col_value[1], -5)
|
|
214
|
+
|
|
215
|
+
self.assertAlmostEqual(h.getObjectiveValue(), -5)
|
|
216
|
+
|
|
217
|
+
h.changeObjectiveOffset(1)
|
|
218
|
+
[status, offset] = h.getObjectiveOffset()
|
|
219
|
+
self.assertAlmostEqual(offset, 1)
|
|
220
|
+
h.run()
|
|
221
|
+
self.assertAlmostEqual(h.getObjectiveValue(), -4)
|
|
222
|
+
|
|
223
|
+
info = h.getInfo()
|
|
224
|
+
mip_node_count0 = info.mip_node_count
|
|
225
|
+
self.assertAlmostEqual(mip_node_count0, 0)
|
|
226
|
+
[status, mip_node_count1] = h.getInfoValue("mip_node_count")
|
|
227
|
+
self.assertEqual(status, highspy.HighsStatus.kOk)
|
|
228
|
+
self.assertAlmostEqual(mip_node_count0, mip_node_count1)
|
|
229
|
+
|
|
230
|
+
def test_example(self):
|
|
231
|
+
h = self.get_example_model()
|
|
232
|
+
lp = h.getLp()
|
|
233
|
+
#
|
|
234
|
+
# Extract column 0
|
|
235
|
+
iCol = 0
|
|
236
|
+
[status, cost, lower, upper, get_num_nz] = h.getCol(iCol)
|
|
237
|
+
self.assertEqual(cost, lp.col_cost_[iCol])
|
|
238
|
+
self.assertEqual(lower, lp.col_lower_[iCol])
|
|
239
|
+
self.assertEqual(upper, lp.col_upper_[iCol])
|
|
240
|
+
index = np.empty(get_num_nz)
|
|
241
|
+
value = np.empty(get_num_nz, dtype=np.double)
|
|
242
|
+
[status, index, value] = h.getColEntries(iCol)
|
|
243
|
+
for iEl in range(get_num_nz):
|
|
244
|
+
self.assertEqual(index[iEl], lp.a_matrix_.index_[iEl])
|
|
245
|
+
self.assertEqual(value[iEl], lp.a_matrix_.value_[iEl])
|
|
246
|
+
#
|
|
247
|
+
# Extract columns 0 and 1
|
|
248
|
+
indices = np.array([0, 1])
|
|
249
|
+
[status, get_num_col, cost, lower, upper, get_num_nz] = h.getCols(2, indices)
|
|
250
|
+
for get_col in range(get_num_col):
|
|
251
|
+
iCol = indices[get_col]
|
|
252
|
+
self.assertEqual(cost[get_col], lp.col_cost_[iCol])
|
|
253
|
+
self.assertEqual(lower[get_col], lp.col_lower_[iCol])
|
|
254
|
+
self.assertEqual(upper[get_col], lp.col_upper_[iCol])
|
|
255
|
+
start = np.empty(get_num_col)
|
|
256
|
+
index = np.empty(get_num_nz)
|
|
257
|
+
value = np.empty(get_num_nz, dtype=np.double)
|
|
258
|
+
[status, start, index, value] = h.getColsEntries(2, indices)
|
|
259
|
+
for iCol in range(lp.num_col_):
|
|
260
|
+
self.assertEqual(start[iCol], lp.a_matrix_.start_[iCol])
|
|
261
|
+
for iEl in range(get_num_nz):
|
|
262
|
+
self.assertEqual(index[iEl], lp.a_matrix_.index_[iEl])
|
|
263
|
+
self.assertEqual(value[iEl], lp.a_matrix_.value_[iEl])
|
|
264
|
+
#
|
|
265
|
+
# Extract row 1
|
|
266
|
+
iRow = 1
|
|
267
|
+
[status, lower, upper, get_num_nz] = h.getRow(iRow)
|
|
268
|
+
self.assertEqual(lower, lp.row_lower_[iRow])
|
|
269
|
+
self.assertEqual(upper, lp.row_upper_[iRow])
|
|
270
|
+
index = np.empty(get_num_nz)
|
|
271
|
+
value = np.empty(get_num_nz, dtype=np.double)
|
|
272
|
+
[status, index, value] = h.getRowEntries(iRow)
|
|
273
|
+
#
|
|
274
|
+
# Extract rows 0 and 2
|
|
275
|
+
indices = np.array([0, 2])
|
|
276
|
+
[status, get_num_row, lower, upper, get_num_nz] = h.getRows(2, indices)
|
|
277
|
+
for get_row in range(get_num_row):
|
|
278
|
+
iRow = indices[get_row]
|
|
279
|
+
self.assertEqual(lower[get_row], lp.row_lower_[iRow])
|
|
280
|
+
self.assertEqual(upper[get_row], lp.row_upper_[iRow])
|
|
281
|
+
start = np.empty(get_num_row)
|
|
282
|
+
index = np.empty(get_num_nz)
|
|
283
|
+
value = np.empty(get_num_nz, dtype=np.double)
|
|
284
|
+
[status, start, index, value] = h.getRowsEntries(2, indices)
|
|
285
|
+
|
|
286
|
+
def test_options(self):
|
|
287
|
+
h = highspy.Highs()
|
|
288
|
+
|
|
289
|
+
# test vanilla get option value method
|
|
290
|
+
|
|
291
|
+
[status, output_flag] = h.getOptionValue("output_flag")
|
|
292
|
+
[status, solver] = h.getOptionValue("solver")
|
|
293
|
+
[status, primal_feasibility_tolerance] = h.getOptionValue("primal_feasibility_tolerance")
|
|
294
|
+
[status, simplex_update_limit] = h.getOptionValue("simplex_update_limit")
|
|
295
|
+
self.assertEqual(output_flag, True)
|
|
296
|
+
self.assertEqual(solver, "choose")
|
|
297
|
+
self.assertEqual(primal_feasibility_tolerance, 1e-7)
|
|
298
|
+
self.assertEqual(simplex_update_limit, 5000)
|
|
299
|
+
# Illegal name
|
|
300
|
+
option_value = h.getOptionValue("simplex_limit")
|
|
301
|
+
self.assertEqual(option_value[0], highspy.HighsStatus.kError)
|
|
302
|
+
|
|
303
|
+
# test bool option
|
|
304
|
+
[status, type] = h.getOptionType("output_flag")
|
|
305
|
+
self.assertEqual(type, highspy.HighsOptionType.kBool)
|
|
306
|
+
|
|
307
|
+
h.setOptionValue("output_flag", True)
|
|
308
|
+
[status, value] = h.getOptionValue("output_flag")
|
|
309
|
+
self.assertTrue(value)
|
|
310
|
+
h.setOptionValue("output_flag", False)
|
|
311
|
+
[status, value] = h.getOptionValue("output_flag")
|
|
312
|
+
self.assertFalse(value)
|
|
313
|
+
|
|
314
|
+
# test string option
|
|
315
|
+
[status, type] = h.getOptionType("presolve")
|
|
316
|
+
self.assertEqual(type, highspy.HighsOptionType.kString)
|
|
317
|
+
h.setOptionValue("presolve", "off")
|
|
318
|
+
[status, value] = h.getOptionValue("presolve")
|
|
319
|
+
self.assertEqual(value, "off")
|
|
320
|
+
h.setOptionValue("presolve", "on")
|
|
321
|
+
[status, value] = h.getOptionValue("presolve")
|
|
322
|
+
self.assertEqual(value, "on")
|
|
323
|
+
|
|
324
|
+
# test int option
|
|
325
|
+
[status, type] = h.getOptionType("threads")
|
|
326
|
+
self.assertEqual(type, highspy.HighsOptionType.kInt)
|
|
327
|
+
h.setOptionValue("threads", 1)
|
|
328
|
+
[status, value] = h.getOptionValue("threads")
|
|
329
|
+
self.assertEqual(value, 1)
|
|
330
|
+
h.setOptionValue("threads", 2)
|
|
331
|
+
[status, value] = h.getOptionValue("threads")
|
|
332
|
+
self.assertEqual(value, 2)
|
|
333
|
+
|
|
334
|
+
# test double option
|
|
335
|
+
[status, type] = h.getOptionType("time_limit")
|
|
336
|
+
self.assertEqual(type, highspy.HighsOptionType.kDouble)
|
|
337
|
+
h.setOptionValue("time_limit", 1.7)
|
|
338
|
+
[status, value] = h.getOptionValue("time_limit")
|
|
339
|
+
self.assertAlmostEqual(value, 1.7)
|
|
340
|
+
h.setOptionValue("time_limit", 2.7)
|
|
341
|
+
[status, value] = h.getOptionValue("time_limit")
|
|
342
|
+
self.assertAlmostEqual(value, 2.7)
|
|
343
|
+
|
|
344
|
+
def test_clear(self):
|
|
345
|
+
h = self.get_basic_model()
|
|
346
|
+
self.assertEqual(h.getNumCol(), 2)
|
|
347
|
+
self.assertEqual(h.getNumRow(), 2)
|
|
348
|
+
self.assertEqual(h.getNumNz(), 4)
|
|
349
|
+
|
|
350
|
+
[status, orig_feas_tol] = h.getOptionValue("primal_feasibility_tolerance")
|
|
351
|
+
new_feas_tol = orig_feas_tol + 1
|
|
352
|
+
h.setOptionValue("primal_feasibility_tolerance", new_feas_tol)
|
|
353
|
+
[status, value] = h.getOptionValue("primal_feasibility_tolerance")
|
|
354
|
+
self.assertAlmostEqual(value, new_feas_tol)
|
|
355
|
+
h.clear()
|
|
356
|
+
self.assertEqual(h.getNumCol(), 0)
|
|
357
|
+
self.assertEqual(h.getNumRow(), 0)
|
|
358
|
+
self.assertEqual(h.getNumNz(), 0)
|
|
359
|
+
[status, value] = h.getOptionValue("primal_feasibility_tolerance")
|
|
360
|
+
self.assertAlmostEqual(value, orig_feas_tol)
|
|
361
|
+
|
|
362
|
+
h = self.get_basic_model()
|
|
363
|
+
h.setOptionValue("primal_feasibility_tolerance", new_feas_tol)
|
|
364
|
+
[status, value] = h.getOptionValue("primal_feasibility_tolerance")
|
|
365
|
+
self.assertAlmostEqual(value, new_feas_tol)
|
|
366
|
+
h.clearModel()
|
|
367
|
+
self.assertEqual(h.getNumCol(), 0)
|
|
368
|
+
self.assertEqual(h.getNumRow(), 0)
|
|
369
|
+
self.assertEqual(h.getNumNz(), 0)
|
|
370
|
+
[status, value] = h.getOptionValue("primal_feasibility_tolerance")
|
|
371
|
+
self.assertAlmostEqual(value, new_feas_tol)
|
|
372
|
+
|
|
373
|
+
h = self.get_basic_model()
|
|
374
|
+
h.run()
|
|
375
|
+
sol = h.getSolution()
|
|
376
|
+
self.assertAlmostEqual(sol.col_value[0], -1)
|
|
377
|
+
self.assertAlmostEqual(sol.col_value[1], 1)
|
|
378
|
+
h.clearSolver()
|
|
379
|
+
self.assertEqual(h.getNumCol(), 2)
|
|
380
|
+
self.assertEqual(h.getNumRow(), 2)
|
|
381
|
+
self.assertEqual(h.getNumNz(), 4)
|
|
382
|
+
sol = h.getSolution()
|
|
383
|
+
self.assertFalse(sol.value_valid)
|
|
384
|
+
self.assertFalse(sol.dual_valid)
|
|
385
|
+
|
|
386
|
+
h = self.get_basic_model()
|
|
387
|
+
[status, orig_feas_tol] = h.getOptionValue("primal_feasibility_tolerance")
|
|
388
|
+
new_feas_tol = orig_feas_tol + 1
|
|
389
|
+
h.setOptionValue("primal_feasibility_tolerance", new_feas_tol)
|
|
390
|
+
[status, value] = h.getOptionValue("primal_feasibility_tolerance")
|
|
391
|
+
self.assertAlmostEqual(value, new_feas_tol)
|
|
392
|
+
h.resetOptions()
|
|
393
|
+
[status, value] = h.getOptionValue("primal_feasibility_tolerance")
|
|
394
|
+
self.assertAlmostEqual(value, orig_feas_tol)
|
|
395
|
+
|
|
396
|
+
def test_ranging(self):
|
|
397
|
+
inf = highspy.kHighsInf
|
|
398
|
+
h = self.get_basic_model()
|
|
399
|
+
# Cost ranging
|
|
400
|
+
# c0 2 -1 1 0
|
|
401
|
+
# c1 0 0 inf inf
|
|
402
|
+
#
|
|
403
|
+
## Bound ranging
|
|
404
|
+
## Columns
|
|
405
|
+
# c0 1 -inf inf 1
|
|
406
|
+
# c1 1 1 inf 1
|
|
407
|
+
## Rows
|
|
408
|
+
# r0 -inf -inf inf inf
|
|
409
|
+
# r1 -inf -inf inf inf
|
|
410
|
+
h.run()
|
|
411
|
+
[status, ranging] = h.getRanging()
|
|
412
|
+
self.assertEqual(ranging.col_cost_dn.objective_[0], 2)
|
|
413
|
+
self.assertEqual(ranging.col_cost_dn.value_[0], -1)
|
|
414
|
+
self.assertEqual(ranging.col_cost_up.value_[0], 1)
|
|
415
|
+
self.assertEqual(ranging.col_cost_up.objective_[0], 0)
|
|
416
|
+
self.assertEqual(ranging.col_cost_dn.objective_[1], 0)
|
|
417
|
+
self.assertEqual(ranging.col_cost_dn.value_[1], 0)
|
|
418
|
+
self.assertEqual(ranging.col_cost_up.value_[1], inf)
|
|
419
|
+
self.assertEqual(ranging.col_cost_up.objective_[1], inf)
|
|
420
|
+
#
|
|
421
|
+
self.assertEqual(ranging.col_bound_dn.objective_[0], 1)
|
|
422
|
+
self.assertEqual(ranging.col_bound_dn.value_[0], -inf)
|
|
423
|
+
self.assertEqual(ranging.col_bound_up.value_[0], inf)
|
|
424
|
+
self.assertEqual(ranging.col_bound_up.objective_[0], 1)
|
|
425
|
+
self.assertEqual(ranging.col_bound_dn.objective_[1], 1)
|
|
426
|
+
self.assertEqual(ranging.col_bound_dn.value_[1], 1)
|
|
427
|
+
self.assertEqual(ranging.col_bound_up.value_[1], inf)
|
|
428
|
+
self.assertEqual(ranging.col_bound_up.objective_[1], 1)
|
|
429
|
+
#
|
|
430
|
+
self.assertEqual(ranging.row_bound_dn.objective_[0], -inf)
|
|
431
|
+
self.assertEqual(ranging.row_bound_dn.value_[0], -inf)
|
|
432
|
+
self.assertEqual(ranging.row_bound_up.value_[0], inf)
|
|
433
|
+
self.assertEqual(ranging.row_bound_up.objective_[0], inf)
|
|
434
|
+
self.assertEqual(ranging.row_bound_dn.objective_[1], -inf)
|
|
435
|
+
self.assertEqual(ranging.row_bound_dn.value_[1], -inf)
|
|
436
|
+
self.assertEqual(ranging.row_bound_up.value_[1], inf)
|
|
437
|
+
self.assertEqual(ranging.row_bound_up.objective_[1], inf)
|
|
438
|
+
|
|
439
|
+
# this catches error in our highs_bindings (pybind11) when passed arrays are not contiguous
|
|
440
|
+
def test_numpy_slice(self):
|
|
441
|
+
h = highspy.Highs()
|
|
442
|
+
|
|
443
|
+
N = 10
|
|
444
|
+
zero, ones = np.zeros(N), np.ones(N)
|
|
445
|
+
h.addCols(N, zero, zero, ones, 0, [], [], [])
|
|
446
|
+
|
|
447
|
+
x = np.arange(N, dtype=np.int32) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
448
|
+
tmp = x[1::2] # [1, 3, 5, 7, 9]
|
|
449
|
+
|
|
450
|
+
h.addRow(1, 1, len(tmp), tmp, ones)
|
|
451
|
+
|
|
452
|
+
# needs to be rowwise for test to work correctly
|
|
453
|
+
self.assertEqual(h.getLp().a_matrix_.format_, highspy.MatrixFormat.kRowwise)
|
|
454
|
+
self.assertEqual(h.getLp().a_matrix_.index_, list(tmp))
|
|
455
|
+
|
|
456
|
+
def test_constraint_removal(self):
|
|
457
|
+
h = highspy.Highs()
|
|
458
|
+
x = h.addVariable(lb=-highspy.kHighsInf)
|
|
459
|
+
y = h.addVariable(lb=-highspy.kHighsInf)
|
|
460
|
+
c1 = h.addConstr(-x + y >= 2)
|
|
461
|
+
c2 = h.addConstr(x + y >= 0)
|
|
462
|
+
self.assertEqual(h.numConstrs, 2)
|
|
463
|
+
h.removeConstr(c1)
|
|
464
|
+
self.assertEqual(h.numConstrs, 1)
|
|
465
|
+
|
|
466
|
+
def test_infeasible_model(self):
|
|
467
|
+
h = highspy.Highs()
|
|
468
|
+
h.setOptionValue("output_flag", False)
|
|
469
|
+
h.setOptionValue("presolve", "off")
|
|
470
|
+
|
|
471
|
+
x = h.addVariable()
|
|
472
|
+
y = h.addVariable()
|
|
473
|
+
|
|
474
|
+
c1 = h.addConstr(x + y == 3)
|
|
475
|
+
c2 = h.addConstr(x + y == 1)
|
|
476
|
+
|
|
477
|
+
status = h.minimize(10 * x + 15 * y)
|
|
478
|
+
self.assertEqual(status, highspy.HighsStatus.kOk)
|
|
479
|
+
|
|
480
|
+
status = h.getModelStatus()
|
|
481
|
+
self.assertEqual(status, highspy.HighsModelStatus.kInfeasible)
|
|
482
|
+
|
|
483
|
+
# change the model to be feasible
|
|
484
|
+
h.chgCoeff(c1, y, 3)
|
|
485
|
+
|
|
486
|
+
status = h.run()
|
|
487
|
+
self.assertEqual(status, highspy.HighsStatus.kOk)
|
|
488
|
+
|
|
489
|
+
status = h.getModelStatus()
|
|
490
|
+
self.assertEqual(status, highspy.HighsModelStatus.kOptimal)
|
|
491
|
+
|
|
492
|
+
def test_simple_basics_builder(self):
|
|
493
|
+
h = highspy.Highs()
|
|
494
|
+
h.silent()
|
|
495
|
+
|
|
496
|
+
x, y = h.addVariables(2, lb=-highspy.kHighsInf)
|
|
497
|
+
c = h.addConstrs(-x + y >= 2, x + y >= 0)
|
|
498
|
+
h.minimize(y)
|
|
499
|
+
self.assertAlmostEqual(list(h.val([x, y])), [-1, 1])
|
|
500
|
+
self.assertAlmostEqual(list(h.variableValue([x, y])), [-1, 1])
|
|
501
|
+
self.assertAlmostEqual(list(h.variableValues([x, y])), [-1, 1])
|
|
502
|
+
self.assertAlmostEqual(list(h.allVariableValues()), [-1, 1])
|
|
503
|
+
|
|
504
|
+
# -x + y >= 3
|
|
505
|
+
h.changeRowBounds(0, 3, highspy.kHighsInf)
|
|
506
|
+
h.run()
|
|
507
|
+
self.assertAlmostEqual(list(h.val([x, y])), [-1.5, 1.5])
|
|
508
|
+
|
|
509
|
+
# make y integer
|
|
510
|
+
h.setInteger(y)
|
|
511
|
+
h.run()
|
|
512
|
+
self.assertAlmostEqual(list(h.val([x, y])), [-1, 2])
|
|
513
|
+
|
|
514
|
+
# delete the first constraint and add a new one
|
|
515
|
+
h.removeConstr(c[0], c)
|
|
516
|
+
self.assertEqual(list(map(int, c)), [-1, 0])
|
|
517
|
+
|
|
518
|
+
h.addConstr(-x + y >= 0)
|
|
519
|
+
h.run()
|
|
520
|
+
self.assertAlmostEqual(list(h.val([x, y])), [0, 0])
|
|
521
|
+
|
|
522
|
+
def test_basics_builder(self):
|
|
523
|
+
h = highspy.Highs()
|
|
524
|
+
h.setOptionValue("output_flag", False)
|
|
525
|
+
|
|
526
|
+
x = h.addVariable(lb=-highspy.kHighsInf)
|
|
527
|
+
y = h.addVariable(lb=-highspy.kHighsInf)
|
|
528
|
+
|
|
529
|
+
c1 = h.addConstr(-x + y >= 2)
|
|
530
|
+
c2 = h.addConstr(x + y >= 0)
|
|
531
|
+
|
|
532
|
+
h.minimize(y)
|
|
533
|
+
|
|
534
|
+
self.assertAlmostEqual(h.val(x), -1)
|
|
535
|
+
self.assertAlmostEqual(h.val(y), 1)
|
|
536
|
+
|
|
537
|
+
"""
|
|
538
|
+
min y
|
|
539
|
+
s.t.
|
|
540
|
+
-x + y >= 3
|
|
541
|
+
x + y >= 0
|
|
542
|
+
"""
|
|
543
|
+
h.changeRowBounds(0, 3, highspy.kHighsInf)
|
|
544
|
+
h.run()
|
|
545
|
+
|
|
546
|
+
self.assertAlmostEqual(h.val(x), -1.5)
|
|
547
|
+
self.assertAlmostEqual(h.val(y), 1.5)
|
|
548
|
+
|
|
549
|
+
sol = h.getSolution()
|
|
550
|
+
self.assertAlmostEqual(h.variableDual(x), sol.col_dual[0])
|
|
551
|
+
|
|
552
|
+
self.assertAlmostEqual(h.variableDuals(x), sol.col_dual[0])
|
|
553
|
+
self.assertAlmostEqual(list(h.variableDuals([x, y])), [sol.col_dual[0], sol.col_dual[1]])
|
|
554
|
+
self.assertAlmostEqual(h.variableDuals({"x": x, "y": y}), {"x": sol.col_dual[0], "y": sol.col_dual[1]})
|
|
555
|
+
self.assertAlmostEqual(list(h.variableDuals(np.asarray([x, y]))), [sol.col_dual[0], sol.col_dual[1]])
|
|
556
|
+
|
|
557
|
+
self.assertAlmostEqual(h.allVariableDuals(), sol.col_dual)
|
|
558
|
+
|
|
559
|
+
c1, c2 = h.getConstrs()
|
|
560
|
+
self.assertAlmostEqual(h.constrValue(c1), sol.row_value[0])
|
|
561
|
+
|
|
562
|
+
self.assertAlmostEqual(h.constrValues(c1), sol.row_value[0])
|
|
563
|
+
self.assertAlmostEqual(list(h.constrValues([c1, c2])), sol.row_value)
|
|
564
|
+
self.assertAlmostEqual(list(h.constrValues([c2, c1])), sol.row_value[::-1]) # order matters
|
|
565
|
+
self.assertAlmostEqual(h.constrValues({"c1": c1, "c2": c2}), {"c1": sol.row_value[0], "c2": sol.row_value[1]})
|
|
566
|
+
self.assertAlmostEqual(list(h.constrValues(np.asarray([c1, c2]))), sol.row_value)
|
|
567
|
+
|
|
568
|
+
self.assertAlmostEqual(h.allConstrValues(), sol.row_value)
|
|
569
|
+
|
|
570
|
+
self.assertAlmostEqual(h.constrDual(c1), sol.row_dual[0])
|
|
571
|
+
|
|
572
|
+
self.assertAlmostEqual(h.constrDuals(c1), sol.row_dual[0])
|
|
573
|
+
self.assertAlmostEqual(list(h.constrDuals([c1, c2])), sol.row_dual)
|
|
574
|
+
self.assertAlmostEqual(list(h.constrDuals([c2, c1])), sol.row_dual[::-1]) # order matters
|
|
575
|
+
self.assertAlmostEqual(h.constrDuals({"c1": c1, "c2": c2}), {"c1": sol.row_dual[0], "c2": sol.row_dual[1]})
|
|
576
|
+
self.assertAlmostEqual(list(h.constrDuals(np.asarray([c1, c2]))), sol.row_dual)
|
|
577
|
+
|
|
578
|
+
self.assertAlmostEqual(h.allConstrDuals(), sol.row_dual)
|
|
579
|
+
|
|
580
|
+
# now make y integer
|
|
581
|
+
h.changeColsIntegrality(1, np.array([1]), np.array([highspy.HighsVarType.kInteger]))
|
|
582
|
+
h.run()
|
|
583
|
+
sol = h.getSolution()
|
|
584
|
+
self.assertAlmostEqual(sol.col_value[0], -1)
|
|
585
|
+
self.assertAlmostEqual(sol.col_value[1], 2)
|
|
586
|
+
|
|
587
|
+
"""
|
|
588
|
+
now delete the first constraint and add a new one
|
|
589
|
+
|
|
590
|
+
min y
|
|
591
|
+
s.t.
|
|
592
|
+
x + y >= 0
|
|
593
|
+
-x + y >= 0
|
|
594
|
+
"""
|
|
595
|
+
h.removeConstr(c1)
|
|
596
|
+
|
|
597
|
+
c1 = h.addConstr(-x + y >= 0)
|
|
598
|
+
|
|
599
|
+
h.run()
|
|
600
|
+
|
|
601
|
+
self.assertAlmostEqual(h.val(x), 0)
|
|
602
|
+
self.assertAlmostEqual(h.val(y), 0)
|
|
603
|
+
|
|
604
|
+
# change the upper bound of x to -5
|
|
605
|
+
h.changeColsBounds(1, np.array([0]), np.array([-highspy.kHighsInf], dtype=np.double), np.array([-5], dtype=np.double))
|
|
606
|
+
h.run()
|
|
607
|
+
self.assertAlmostEqual(h.val(x), -5)
|
|
608
|
+
self.assertAlmostEqual(h.val(y), 5)
|
|
609
|
+
|
|
610
|
+
# now maximize
|
|
611
|
+
h.changeRowBounds(1, -highspy.kHighsInf, 0)
|
|
612
|
+
h.changeRowBounds(0, -highspy.kHighsInf, 0)
|
|
613
|
+
h.minimize(-y)
|
|
614
|
+
|
|
615
|
+
self.assertAlmostEqual(h.val(x), -5)
|
|
616
|
+
self.assertAlmostEqual(h.val(y), -5)
|
|
617
|
+
|
|
618
|
+
self.assertEqual(h.getObjectiveSense()[1], highspy.ObjSense.kMinimize)
|
|
619
|
+
h.maximize(y)
|
|
620
|
+
self.assertEqual(h.getObjectiveSense()[1], highspy.ObjSense.kMaximize)
|
|
621
|
+
|
|
622
|
+
self.assertAlmostEqual(h.val(x), -5)
|
|
623
|
+
self.assertAlmostEqual(h.val(y), -5)
|
|
624
|
+
|
|
625
|
+
self.assertAlmostEqual(h.getObjectiveValue(), -5)
|
|
626
|
+
|
|
627
|
+
h.maximize(y + 1)
|
|
628
|
+
self.assertAlmostEqual(h.getObjectiveOffset()[1], 1)
|
|
629
|
+
self.assertAlmostEqual(h.getObjectiveValue(), -4)
|
|
630
|
+
|
|
631
|
+
def test_addVariable(self):
|
|
632
|
+
h = highspy.Highs()
|
|
633
|
+
h.addVariable()
|
|
634
|
+
self.assertEqual(h.numVariables, 1)
|
|
635
|
+
|
|
636
|
+
# exception
|
|
637
|
+
self.assertRaises(Exception, lambda: h.addVariable(lb=h.inf))
|
|
638
|
+
self.assertRaises(Exception, lambda: h.addVariables(2, lb=h.inf))
|
|
639
|
+
|
|
640
|
+
def test_addConstr(self):
|
|
641
|
+
h = highspy.Highs()
|
|
642
|
+
x = h.addVariable()
|
|
643
|
+
y = h.addVariable()
|
|
644
|
+
|
|
645
|
+
c1 = h.addConstr(2 * x + 3 * y <= 10, name="c1")
|
|
646
|
+
self.assertEqual(h.numVariables, 2)
|
|
647
|
+
self.assertEqual(h.numConstrs, 1)
|
|
648
|
+
self.assertEqual(h.getNumNz(), 2)
|
|
649
|
+
self.assertEqual(c1.name, "c1")
|
|
650
|
+
c1.name = "c2"
|
|
651
|
+
self.assertEqual(c1.name, "c2")
|
|
652
|
+
|
|
653
|
+
lp = h.getLp()
|
|
654
|
+
self.assertAlmostEqual(lp.row_lower_[0], -highspy.kHighsInf)
|
|
655
|
+
self.assertAlmostEqual(lp.row_upper_[0], 10)
|
|
656
|
+
|
|
657
|
+
self.assertEqual(lp.a_matrix_.index_[0], 0)
|
|
658
|
+
self.assertEqual(lp.a_matrix_.index_[1], 1)
|
|
659
|
+
|
|
660
|
+
self.assertAlmostEqual(lp.a_matrix_.value_[0], 2)
|
|
661
|
+
self.assertAlmostEqual(lp.a_matrix_.value_[1], 3)
|
|
662
|
+
|
|
663
|
+
def test_removeConstr(self):
|
|
664
|
+
h = highspy.Highs()
|
|
665
|
+
x = h.addVariable()
|
|
666
|
+
y = h.addVariable()
|
|
667
|
+
c = h.addConstr(2 * x + 3 * y <= 10)
|
|
668
|
+
self.assertEqual(h.numConstrs, 1)
|
|
669
|
+
|
|
670
|
+
h.removeConstr(c)
|
|
671
|
+
self.assertEqual(h.numVariables, 2)
|
|
672
|
+
self.assertEqual(h.numConstrs, 0)
|
|
673
|
+
self.assertRaises(Exception, lambda: c.name("c"))
|
|
674
|
+
|
|
675
|
+
def test_val(self):
|
|
676
|
+
h = highspy.Highs()
|
|
677
|
+
h.setOptionValue("output_flag", False)
|
|
678
|
+
|
|
679
|
+
x = [h.addVariable(), h.addVariable()]
|
|
680
|
+
h.addConstr(2 * x[0] + 3 * x[1] <= 10)
|
|
681
|
+
h.maximize(x[0])
|
|
682
|
+
|
|
683
|
+
self.assertAlmostEqual(h.val(x[0]), 5)
|
|
684
|
+
|
|
685
|
+
vals = h.vals(x)
|
|
686
|
+
self.assertAlmostEqual(vals[0], 5)
|
|
687
|
+
self.assertAlmostEqual(vals[1], 0)
|
|
688
|
+
|
|
689
|
+
# test linear expr
|
|
690
|
+
self.assertAlmostEqual(h.val(2 * x[0] + 3 * x[1]), 10)
|
|
691
|
+
self.assertAlmostEqual(h.val(1 * x[0] + 3 * x[1]), 5)
|
|
692
|
+
|
|
693
|
+
self.assertAlmostEqual(h.val(1 * x[0] + 3 * x[1] <= 4), False)
|
|
694
|
+
self.assertAlmostEqual(h.val(1 * x[0] + 3 * x[1] == 5), True)
|
|
695
|
+
self.assertAlmostEqual(h.val(1 * x[0] + 3 * x[1] >= 6), False)
|
|
696
|
+
|
|
697
|
+
def test_var_name(self):
|
|
698
|
+
h = highspy.Highs()
|
|
699
|
+
|
|
700
|
+
# name set, but not in the model
|
|
701
|
+
x = h.addVariable(name="x")
|
|
702
|
+
self.assertEqual(x.name, "x")
|
|
703
|
+
|
|
704
|
+
# change name before adding to the model
|
|
705
|
+
x.name = "y"
|
|
706
|
+
self.assertEqual(x.name, "y")
|
|
707
|
+
|
|
708
|
+
# add to the model
|
|
709
|
+
self.assertEqual(h.numVariables, 1)
|
|
710
|
+
self.assertEqual(h.getLp().col_names_[0], "y")
|
|
711
|
+
|
|
712
|
+
# change name after adding to the model
|
|
713
|
+
x.name = "z"
|
|
714
|
+
self.assertEqual(h.getLp().col_names_[0], "z")
|
|
715
|
+
|
|
716
|
+
# change name via the model
|
|
717
|
+
h.passColName(0, "a")
|
|
718
|
+
self.assertEqual(h.getLp().col_names_[0], "a")
|
|
719
|
+
self.assertEqual(x.name, "a")
|
|
720
|
+
self.assertEqual(h.variableName(x), "a")
|
|
721
|
+
self.assertRaises(Exception, lambda: h.variableName(1))
|
|
722
|
+
self.assertEqual(h.variableNames([x]), ["a"])
|
|
723
|
+
self.assertEqual(h.variableNames({"key": x}), {"key": "a"})
|
|
724
|
+
self.assertEqual(h.allVariableNames(), ["a"])
|
|
725
|
+
|
|
726
|
+
y = h.addVariable()
|
|
727
|
+
h.deleteVariable(y)
|
|
728
|
+
self.assertRaises(Exception, lambda: y.name)
|
|
729
|
+
|
|
730
|
+
def test_binary(self):
|
|
731
|
+
h = highspy.Highs()
|
|
732
|
+
h.setOptionValue("output_flag", False)
|
|
733
|
+
|
|
734
|
+
x = [h.addBinary(), h.addBinary()]
|
|
735
|
+
h.addConstr(2 * x[0] + 3 * x[1] <= 10)
|
|
736
|
+
h.maximize(x[0])
|
|
737
|
+
|
|
738
|
+
lp = h.getLp()
|
|
739
|
+
self.assertAlmostEqual(lp.col_lower_[0], 0)
|
|
740
|
+
self.assertAlmostEqual(lp.col_upper_[0], 1)
|
|
741
|
+
self.assertEqual(lp.integrality_[0], highspy.HighsVarType.kInteger)
|
|
742
|
+
|
|
743
|
+
self.assertAlmostEqual(h.val(x[0]), 1)
|
|
744
|
+
|
|
745
|
+
vals = h.vals(x)
|
|
746
|
+
self.assertAlmostEqual(vals[0], 1)
|
|
747
|
+
self.assertAlmostEqual(vals[1], 0)
|
|
748
|
+
|
|
749
|
+
def test_integer(self):
|
|
750
|
+
h = highspy.Highs()
|
|
751
|
+
h.setOptionValue("output_flag", False)
|
|
752
|
+
|
|
753
|
+
x = [h.addIntegral(), h.addVariable()]
|
|
754
|
+
h.addConstr(2 * x[0] + 3 * x[1] <= 10.6)
|
|
755
|
+
h.maximize(x[0] + x[1])
|
|
756
|
+
|
|
757
|
+
lp = h.getLp()
|
|
758
|
+
self.assertEqual(lp.integrality_[0], highspy.HighsVarType.kInteger)
|
|
759
|
+
self.assertEqual(lp.integrality_[1], highspy.HighsVarType.kContinuous)
|
|
760
|
+
|
|
761
|
+
self.assertAlmostEqual(h.val(x[0]), 5)
|
|
762
|
+
|
|
763
|
+
vals = h.vals(x)
|
|
764
|
+
self.assertAlmostEqual(vals[0], 5)
|
|
765
|
+
self.assertAlmostEqual(vals[1], 0.2)
|
|
766
|
+
|
|
767
|
+
y = h.addIntegrals(2)
|
|
768
|
+
self.assertEqual(h.getLp().integrality_[2], highspy.HighsVarType.kInteger)
|
|
769
|
+
self.assertEqual(h.getLp().integrality_[3], highspy.HighsVarType.kInteger)
|
|
770
|
+
|
|
771
|
+
h.setContinuous(y[0])
|
|
772
|
+
self.assertEqual(h.getLp().integrality_[2], highspy.HighsVarType.kContinuous)
|
|
773
|
+
self.assertEqual(h.getLp().integrality_[3], highspy.HighsVarType.kInteger)
|
|
774
|
+
|
|
775
|
+
h.setInteger(y)
|
|
776
|
+
self.assertEqual(h.getLp().integrality_[2], highspy.HighsVarType.kInteger)
|
|
777
|
+
self.assertEqual(h.getLp().integrality_[3], highspy.HighsVarType.kInteger)
|
|
778
|
+
|
|
779
|
+
h.setContinuous(y)
|
|
780
|
+
self.assertEqual(h.getLp().integrality_[2], highspy.HighsVarType.kContinuous)
|
|
781
|
+
self.assertEqual(h.getLp().integrality_[3], highspy.HighsVarType.kContinuous)
|
|
782
|
+
|
|
783
|
+
def test_objective(self):
|
|
784
|
+
h = highspy.Highs()
|
|
785
|
+
h.setOptionValue("output_flag", False)
|
|
786
|
+
|
|
787
|
+
x = [h.addVariable(), h.addVariable()]
|
|
788
|
+
h.addConstr(2 * x[0] + 3 * x[1] <= 10)
|
|
789
|
+
|
|
790
|
+
self.assertRaises(Exception, h.maximize, x[0] + x[1] <= 3)
|
|
791
|
+
self.assertRaises(Exception, h.minimize, x[0] + x[1] <= 3)
|
|
792
|
+
|
|
793
|
+
def test_constraint_builder(self):
|
|
794
|
+
h = highspy.Highs()
|
|
795
|
+
(x, y) = [h.addVariable(), h.addVariable()]
|
|
796
|
+
|
|
797
|
+
# -inf <= 2x + 3y <= inf
|
|
798
|
+
c1 = 2 * x + 3 * y
|
|
799
|
+
self.assertEqualExpr(c1, [x, y], [2, 3])
|
|
800
|
+
|
|
801
|
+
# -inf <= 2x + 3y <= 2x
|
|
802
|
+
c1 = 2 * x + 3 * y <= 2 * x
|
|
803
|
+
self.assertEqualExpr(c1, [x, y, x], [2, 3, -2], None, [-highspy.kHighsInf, 0])
|
|
804
|
+
|
|
805
|
+
# -inf <= 2x + 3y <= 2x
|
|
806
|
+
c1 = 2 * x >= 2 * x + 3 * y
|
|
807
|
+
self.assertEqualExpr(c1, [x, y, x], [2, 3, -2], None, [-highspy.kHighsInf, 0])
|
|
808
|
+
|
|
809
|
+
# failure add constraint without inequality
|
|
810
|
+
self.assertRaises(Exception, lambda: h.addConstr(x + 3 * y))
|
|
811
|
+
self.assertRaises(Exception, lambda: h.addConstrs(x == 1, x + 3 * y))
|
|
812
|
+
self.assertRaises(Exception, lambda: h.addConstrs({"a": x == 1, "b": x + 3 * y}))
|
|
813
|
+
|
|
814
|
+
# ensure model is rolled back on error
|
|
815
|
+
self.assertEqual(h.numConstrs, 0)
|
|
816
|
+
self.assertRaises(Exception, lambda: h.addConstrs([x == 1] * 100 + [x + 3 * y]))
|
|
817
|
+
self.assertEqual(h.numConstrs, 0)
|
|
818
|
+
|
|
819
|
+
# failure - bounds already set
|
|
820
|
+
self.assertRaises(Exception, lambda: 1 <= (4 <= 2 * x + 3 * y))
|
|
821
|
+
self.assertRaises(Exception, lambda: 2 >= (4 >= 2 * x + 3 * y))
|
|
822
|
+
self.assertRaises(Exception, lambda: (2 * x + 3 * y <= 2) <= 4)
|
|
823
|
+
self.assertRaises(Exception, lambda: (1 <= 2 * x + 3 * y) <= 5)
|
|
824
|
+
self.assertRaises(Exception, lambda: 1 <= (2 * x + 3 * y <= 5))
|
|
825
|
+
self.assertRaises(Exception, lambda: 1 <= (5 >= 2 * x + 3 * y))
|
|
826
|
+
self.assertRaises(Exception, lambda: (5 >= 2 * x + 3 * y) >= 1)
|
|
827
|
+
self.assertRaises(Exception, lambda: 5 >= (2 * x + 3 * y >= 1))
|
|
828
|
+
|
|
829
|
+
c1 = 2 * x + 3 * y <= (2 <= 4) # 2x + 3y <= float(True)
|
|
830
|
+
self.assertEqualExpr(c1, [x, y], [2, 3], None, [-highspy.kHighsInf, 1])
|
|
831
|
+
|
|
832
|
+
# failure, non-linear terms
|
|
833
|
+
self.assertRaises(Exception, lambda: 2 * x * 3 * y)
|
|
834
|
+
|
|
835
|
+
# failure, order matters when having variables on both sides of inequality
|
|
836
|
+
self.assertRaises(Exception, lambda: (4 * x <= 2 * x + 3 * y) <= 5)
|
|
837
|
+
self.assertRaises(Exception, lambda: 4 * x <= (2 * x + 3 * y <= 5))
|
|
838
|
+
self.assertRaises(Exception, lambda: (4 * x <= 2 * x + 3 * y) <= 5 * x)
|
|
839
|
+
|
|
840
|
+
c1 = 5 * x <= 2 * x + 3 * y <= 5 * x
|
|
841
|
+
self.assertEqualExpr(c1, [x, y, x], [2, 3, -5], None, [0, 0])
|
|
842
|
+
|
|
843
|
+
# test various combinations with different inequalities
|
|
844
|
+
self.assertRaises(Exception, lambda: (2 * x + 3 * y == 3 * y) == 3)
|
|
845
|
+
self.assertRaises(Exception, lambda: 2 * x + 3 * y == (3 * y == 3))
|
|
846
|
+
self.assertRaises(Exception, lambda: 2 * x + 3 * y == (3 * y <= 3))
|
|
847
|
+
self.assertRaises(Exception, lambda: 2 * x + 3 * y == (3 * y >= 3))
|
|
848
|
+
|
|
849
|
+
c1 = 2 * x + 3 * y == x
|
|
850
|
+
self.assertEqualExpr(c1, [x, y, x], [2, 3, -1], None, [0, 0])
|
|
851
|
+
|
|
852
|
+
c1 = 2 * x + 3 * y == 5
|
|
853
|
+
self.assertEqualExpr(c1, [x, y], [2, 3], None, [5, 5])
|
|
854
|
+
|
|
855
|
+
c1 = 5 == 2 * x + 3 * y
|
|
856
|
+
self.assertEqualExpr(c1, [x, y], [2, 3], None, [5, 5])
|
|
857
|
+
|
|
858
|
+
# 2*x + 3*y == 4.5
|
|
859
|
+
c1 = 2 * x + 3 * y + 0.5 == 5
|
|
860
|
+
self.assertEqualExpr(c1, [x, y], [2, 3], None, [4.5, 4.5])
|
|
861
|
+
h.addConstr(c1)
|
|
862
|
+
self.assertAlmostEqual((h.getLp().row_lower_[0], h.getLp().row_upper_[0]), (4.5, 4.5))
|
|
863
|
+
|
|
864
|
+
def test_add_multiple_variables(self):
|
|
865
|
+
# test basic functionality
|
|
866
|
+
h = highspy.Highs()
|
|
867
|
+
x = h.addVariables(2)
|
|
868
|
+
self.assertEqual(h.numVariables, 2)
|
|
869
|
+
|
|
870
|
+
# test multiple dimensions
|
|
871
|
+
h = highspy.Highs()
|
|
872
|
+
x = h.addVariables(2, 3, 4, out_array=False)
|
|
873
|
+
self.assertEqual(h.numVariables, 2 * 3 * 4)
|
|
874
|
+
self.assertEqual(isinstance(x, dict), True)
|
|
875
|
+
|
|
876
|
+
# test multiple dimensions array
|
|
877
|
+
h = highspy.Highs()
|
|
878
|
+
x = h.addVariables(2, 3, 4)
|
|
879
|
+
self.assertEqual(h.numVariables, 2 * 3 * 4)
|
|
880
|
+
self.assertEqual(x.shape, (2, 3, 4))
|
|
881
|
+
|
|
882
|
+
# test binary variables with objective and names
|
|
883
|
+
h = highspy.Highs()
|
|
884
|
+
x = h.addBinaries(20, obj=range(20), name_prefix="t_")
|
|
885
|
+
self.assertEqual(h.numVariables, 20)
|
|
886
|
+
self.assertEqual(h.getLp().col_names_[0], "t_0")
|
|
887
|
+
self.assertEqual(h.getLp().col_names_[19], "t_19")
|
|
888
|
+
self.assertEqual(h.getLp().col_cost_[0], 0)
|
|
889
|
+
self.assertEqual(h.getLp().col_cost_[19], 19)
|
|
890
|
+
|
|
891
|
+
# test prefix item with indices, not variable offset
|
|
892
|
+
h = highspy.Highs()
|
|
893
|
+
x = h.addVariables("a", "b", "c", name_prefix="t_") # ('a','b','c')
|
|
894
|
+
self.assertEqual(h.numVariables, 1)
|
|
895
|
+
self.assertEqual(x["a", "b", "c"].name, "t_('a','b','c')")
|
|
896
|
+
|
|
897
|
+
# Testing different ways of adding variables
|
|
898
|
+
# Some are unlikely to be used, but this is expected behaviour
|
|
899
|
+
N = 0
|
|
900
|
+
h = highspy.Highs()
|
|
901
|
+
x1 = h.addVariables(("a", "b", "c"), obj={"b": 20, "c": 10, "a": 50})
|
|
902
|
+
N += 3
|
|
903
|
+
self.assertEqual(h.numVariables, N)
|
|
904
|
+
lp = h.getLp()
|
|
905
|
+
self.assertEqual(lp.col_cost_[0], 50)
|
|
906
|
+
self.assertEqual(lp.col_cost_[1], 20)
|
|
907
|
+
self.assertEqual(lp.col_cost_[2], 10)
|
|
908
|
+
|
|
909
|
+
x2 = h.addVariables(["a", "b", "c", "d"]) # 'a', 'b', 'c', 'd'
|
|
910
|
+
N += 4
|
|
911
|
+
self.assertEqual(h.numVariables, N)
|
|
912
|
+
|
|
913
|
+
x3 = h.addVariables("abc") # 'a', 'b', 'c'
|
|
914
|
+
N += 3
|
|
915
|
+
self.assertEqual(h.numVariables, N)
|
|
916
|
+
|
|
917
|
+
x4 = h.addVariables(("ab", "b", "c", "d")) # 'ab', 'b', 'c', 'd'
|
|
918
|
+
N += 4
|
|
919
|
+
self.assertEqual(h.numVariables, N)
|
|
920
|
+
|
|
921
|
+
x5 = h.addVariables("ab", "b", "c", "d") # ('a', 'b', 'c', 'd'), ('b', 'b', 'c', 'd')
|
|
922
|
+
N += 2
|
|
923
|
+
self.assertEqual(h.numVariables, N)
|
|
924
|
+
self.assertTrue(("a", "b", "c", "d") in x5.keys())
|
|
925
|
+
self.assertTrue(("b", "b", "c", "d") in x5.keys())
|
|
926
|
+
|
|
927
|
+
x6 = h.addVariables(5, "a", 2, "b", "c") # range(5), 'a', range(2), 'b', 'c'
|
|
928
|
+
N += 5 * 2
|
|
929
|
+
self.assertEqual(h.numVariables, N)
|
|
930
|
+
|
|
931
|
+
x7 = h.addVariables([5, "a", 2, "b", "c"]) # 5, 'a', 2, 'b', 'c'
|
|
932
|
+
N += 5
|
|
933
|
+
self.assertEqual(h.numVariables, N)
|
|
934
|
+
|
|
935
|
+
x8 = h.addVariables([(20, 1), (1, 2), (2, 6)], ub=[3, 2, 1], name_prefix="t") # (20, 1), (1,2), (2,6)
|
|
936
|
+
N += 3
|
|
937
|
+
self.assertEqual(h.numVariables, N)
|
|
938
|
+
|
|
939
|
+
x9 = h.addBinaries((20, 1), (1, 2), (2, 6)) # product((20, 1), (1,2), (2,6))) = (20, 1, 2), ..., (1, 2, 6)
|
|
940
|
+
N += 8
|
|
941
|
+
self.assertEqual(h.numVariables, N)
|
|
942
|
+
|
|
943
|
+
def test_add_single_constraints(self):
|
|
944
|
+
h = highspy.Highs()
|
|
945
|
+
(x, y) = h.addVariables(2)
|
|
946
|
+
added_constraints = h.addConstrs([2 * x + 3 * y <= 5])
|
|
947
|
+
self.assertEqual(len(added_constraints), 1)
|
|
948
|
+
self.assertEqual(h.numConstrs, 1)
|
|
949
|
+
|
|
950
|
+
def test_add_multiple_constraints(self):
|
|
951
|
+
# test manual constraints
|
|
952
|
+
h = highspy.Highs()
|
|
953
|
+
(x, y, z) = h.addVariables(3)
|
|
954
|
+
added_constraints = h.addConstrs([x + y <= 5, 2 * x + 3 * y >= 10, x - z == 2])
|
|
955
|
+
self.assertEqual(len(added_constraints), 3)
|
|
956
|
+
self.assertEqual(h.numConstrs, 3)
|
|
957
|
+
|
|
958
|
+
# test list comprehension constraints
|
|
959
|
+
h = highspy.Highs()
|
|
960
|
+
x = h.addVariables(5)
|
|
961
|
+
h.addConstr(sum(x) == 1)
|
|
962
|
+
self.assertEqual(h.numConstrs, 1)
|
|
963
|
+
|
|
964
|
+
h.addConstrs(x[i] + x[j] <= 1 for i in range(5) for j in range(5))
|
|
965
|
+
self.assertEqual(h.numConstrs, 26)
|
|
966
|
+
|
|
967
|
+
# test names and sequence types (list, tuple, nothing)
|
|
968
|
+
h = highspy.Highs()
|
|
969
|
+
(x1, x2, x3) = h.addVariables(3)
|
|
970
|
+
|
|
971
|
+
h.addConstrs((x2 - x1 >= 2), name_prefix="a")
|
|
972
|
+
self.assertEqual(h.numConstrs, 1)
|
|
973
|
+
h.addConstrs((x2 - x1 >= 2))
|
|
974
|
+
self.assertEqual(h.numConstrs, 2)
|
|
975
|
+
|
|
976
|
+
h.addConstrs(x2 - x1 >= 2, name_prefix="b")
|
|
977
|
+
self.assertEqual(h.numConstrs, 3)
|
|
978
|
+
h.addConstrs(x2 - x1 >= 2)
|
|
979
|
+
self.assertEqual(h.numConstrs, 4)
|
|
980
|
+
|
|
981
|
+
h.addConstrs([x2 - x1 >= 2], name_prefix="c")
|
|
982
|
+
self.assertEqual(h.numConstrs, 5)
|
|
983
|
+
h.addConstrs([x2 - x1 >= 2])
|
|
984
|
+
self.assertEqual(h.numConstrs, 6)
|
|
985
|
+
|
|
986
|
+
# r/w basis tests below works on unix but not windows?
|
|
987
|
+
def test_write_basis_before_running(self):
|
|
988
|
+
if platform == "linux" or platform == "darwin":
|
|
989
|
+
h = self.get_basic_model()
|
|
990
|
+
with tempfile.NamedTemporaryFile() as f:
|
|
991
|
+
h.writeBasis(f.name)
|
|
992
|
+
contents = f.read()
|
|
993
|
+
self.assertEqual(contents, b"HiGHS_basis_file v2\nNone\n")
|
|
994
|
+
|
|
995
|
+
def test_write_basis_after_running(self):
|
|
996
|
+
if platform == "linux" or platform == "darwin":
|
|
997
|
+
h = self.get_basic_model()
|
|
998
|
+
h.run()
|
|
999
|
+
with tempfile.NamedTemporaryFile() as f:
|
|
1000
|
+
h.writeBasis(f.name)
|
|
1001
|
+
contents = f.read()
|
|
1002
|
+
self.assertEqual(contents, b"HiGHS_basis_file v2\nValid\n# Columns 2\nc0 1\nc1 1\n# Rows 2\nr0 0\nr1 0\n")
|
|
1003
|
+
|
|
1004
|
+
def test_read_basis(self):
|
|
1005
|
+
if platform == "linux" or platform == "darwin":
|
|
1006
|
+
# Read basis from one run model into an unrun model
|
|
1007
|
+
expected_status_before = highspy.HighsBasisStatus.kNonbasic
|
|
1008
|
+
expected_status_after = highspy.HighsBasisStatus.kBasic
|
|
1009
|
+
|
|
1010
|
+
h1 = self.get_basic_model()
|
|
1011
|
+
self.assertEqual(h1.getBasis().col_status[0], expected_status_before)
|
|
1012
|
+
h1.run()
|
|
1013
|
+
self.assertEqual(h1.getBasis().col_status[0], expected_status_after)
|
|
1014
|
+
|
|
1015
|
+
h2 = self.get_basic_model()
|
|
1016
|
+
self.assertEqual(h2.getBasis().col_status[0], expected_status_before)
|
|
1017
|
+
|
|
1018
|
+
with tempfile.NamedTemporaryFile() as f:
|
|
1019
|
+
h1.writeBasis(f.name)
|
|
1020
|
+
h2.readBasis(f.name)
|
|
1021
|
+
self.assertEqual(h2.getBasis().col_status[0], expected_status_after)
|
|
1022
|
+
|
|
1023
|
+
def test_solve(self):
|
|
1024
|
+
"""Test the solve method to ensure it runs the solver."""
|
|
1025
|
+
h = highspy.Highs()
|
|
1026
|
+
h.silent()
|
|
1027
|
+
x = h.addBinary(obj=1)
|
|
1028
|
+
h.setMaximize()
|
|
1029
|
+
h.solve()
|
|
1030
|
+
self.assertEqual(h.getSolution().col_value[0], 1)
|
|
1031
|
+
self.assertEqual(h.getObjectiveSense()[1], highspy.highs.ObjSense.kMaximize)
|
|
1032
|
+
|
|
1033
|
+
h.setMinimize()
|
|
1034
|
+
h.optimize()
|
|
1035
|
+
self.assertEqual(h.getSolution().col_value[0], 0)
|
|
1036
|
+
self.assertEqual(h.getObjectiveSense()[1], highspy.highs.ObjSense.kMinimize)
|
|
1037
|
+
|
|
1038
|
+
def test_minimize(self):
|
|
1039
|
+
"""Test the minimize method with and without an objective."""
|
|
1040
|
+
h = highspy.Highs()
|
|
1041
|
+
h.silent()
|
|
1042
|
+
x, y, z = h.addBinaries(3, obj=-1)
|
|
1043
|
+
h.minimize()
|
|
1044
|
+
self.assertEqual(list(h.val([x, y, z])), [1, 1, 1])
|
|
1045
|
+
|
|
1046
|
+
h.minimize(-x)
|
|
1047
|
+
self.assertEqual(h.val(x), 1)
|
|
1048
|
+
|
|
1049
|
+
h.minimize(x)
|
|
1050
|
+
self.assertEqual(h.val(x), 0)
|
|
1051
|
+
|
|
1052
|
+
h.minimize(x - y)
|
|
1053
|
+
self.assertEqual(h.val(x), 0)
|
|
1054
|
+
self.assertEqual(h.val(y), 1)
|
|
1055
|
+
|
|
1056
|
+
self.assertRaises(Exception, h.minimize, x - y <= 5)
|
|
1057
|
+
self.assertRaises(Exception, h.minimize, 0 <= x - y <= 5)
|
|
1058
|
+
self.assertRaises(Exception, h.minimize, 4 <= x - y)
|
|
1059
|
+
self.assertRaises(Exception, h.minimize, 4)
|
|
1060
|
+
|
|
1061
|
+
def test_maximize(self):
|
|
1062
|
+
"""Test the maximize method with and without an objective."""
|
|
1063
|
+
h = highspy.Highs()
|
|
1064
|
+
h.silent()
|
|
1065
|
+
x, y, z = h.addBinaries(3, obj=1)
|
|
1066
|
+
h.maximize()
|
|
1067
|
+
self.assertEqual(list(h.val([x, y, z])), [1, 1, 1])
|
|
1068
|
+
|
|
1069
|
+
h.maximize(x)
|
|
1070
|
+
self.assertEqual(h.val(x), 1)
|
|
1071
|
+
|
|
1072
|
+
h.maximize(-x)
|
|
1073
|
+
self.assertEqual(h.val(x), 0)
|
|
1074
|
+
|
|
1075
|
+
h.maximize(y - x)
|
|
1076
|
+
self.assertEqual(h.val(x), 0)
|
|
1077
|
+
self.assertEqual(h.val(y), 1)
|
|
1078
|
+
|
|
1079
|
+
self.assertRaises(Exception, h.maximize, x - y <= 5)
|
|
1080
|
+
self.assertRaises(Exception, h.maximize, 0 <= x - y <= 5)
|
|
1081
|
+
self.assertRaises(Exception, h.maximize, 4 <= x - y)
|
|
1082
|
+
self.assertRaises(Exception, h.maximize, 4)
|
|
1083
|
+
|
|
1084
|
+
def test_get_expr(self):
|
|
1085
|
+
h = self.get_basic_model()
|
|
1086
|
+
|
|
1087
|
+
expr = h.getExpr(0) # -x + y >= 2
|
|
1088
|
+
self.assertEqualExpr(expr, [0, 1], [-1, 1], None, [2, highspy.kHighsInf])
|
|
1089
|
+
|
|
1090
|
+
expr = h.getExpr(1) # x + y >= 0
|
|
1091
|
+
self.assertEqualExpr(expr, [0, 1], [1, 1], None, [0, highspy.kHighsInf])
|
|
1092
|
+
|
|
1093
|
+
c = h.getConstrs()
|
|
1094
|
+
self.assertEqualExpr(c[0].expr(), [0, 1], [-1, 1], None, [2, highspy.kHighsInf])
|
|
1095
|
+
self.assertEqualExpr(c[1].expr(), [0, 1], [1, 1], None, [0, highspy.kHighsInf])
|
|
1096
|
+
|
|
1097
|
+
self.assertRaises(Exception, lambda: h.getExpr(2))
|
|
1098
|
+
|
|
1099
|
+
def test_add_variables(self):
|
|
1100
|
+
"""Test adding multiple variables to the model."""
|
|
1101
|
+
h = highspy.Highs()
|
|
1102
|
+
|
|
1103
|
+
var = h.addVariables()
|
|
1104
|
+
self.assertEqual(var, None)
|
|
1105
|
+
|
|
1106
|
+
keys = ["a", "b", "c"]
|
|
1107
|
+
v = h.addVariables(keys)
|
|
1108
|
+
self.assertTrue(isinstance(v, dict))
|
|
1109
|
+
self.assertEqual(int(v["a"]), 0)
|
|
1110
|
+
|
|
1111
|
+
h.addConstr(v["a"] + v["b"] + v["c"] == 1)
|
|
1112
|
+
h.maximize(v["a"])
|
|
1113
|
+
self.assertEqual(h.val(v), {"a": 1.0, "b": 0, "c": 0})
|
|
1114
|
+
self.assertEqual(list(map(int, h.getVariables())), [0, 1, 2])
|
|
1115
|
+
|
|
1116
|
+
# provided len(parameters) != len(indices)
|
|
1117
|
+
self.assertRaises(Exception, lambda: h.addVariables(5, type=[highspy.HighsVarType.kContinuous, highspy.HighsVarType.kInteger]))
|
|
1118
|
+
self.assertRaises(Exception, lambda: h.addVariables(5, name=["a", "b"]))
|
|
1119
|
+
|
|
1120
|
+
# some parameters not valid
|
|
1121
|
+
self.assertRaises(Exception, lambda: h.addVariables(5, type=[highspy.HighsVarType.kContinuous, None]))
|
|
1122
|
+
self.assertRaises(Exception, lambda: h.addVariables(5, name=["a", None]))
|
|
1123
|
+
self.assertRaises(Exception, lambda: h.addVariables(5, out_array=["a"]))
|
|
1124
|
+
self.assertRaises(Exception, lambda: h.addVariables(5, name_prefix=["a"]))
|
|
1125
|
+
|
|
1126
|
+
# correct usage
|
|
1127
|
+
y = h.addVariables(5, type=[highspy.HighsVarType.kContinuous] * 5)
|
|
1128
|
+
self.assertEqual(list(map(int, y)), [3, 4, 5, 6, 7])
|
|
1129
|
+
|
|
1130
|
+
y2 = h.addVariables(
|
|
1131
|
+
["a", "b", "c"], type={"a": highspy.HighsVarType.kContinuous, "b": highspy.HighsVarType.kInteger, "c": highspy.HighsVarType.kContinuous}
|
|
1132
|
+
)
|
|
1133
|
+
self.assertEqual({k: int(v) for k, v in y2.items()}, {"a": 8, "b": 9, "c": 10})
|
|
1134
|
+
|
|
1135
|
+
y3 = h.addVariables(2, name=["a", "b"])
|
|
1136
|
+
self.assertEqual(list(map(int, y3)), [11, 12])
|
|
1137
|
+
|
|
1138
|
+
def test_delete_variable(self):
|
|
1139
|
+
h = highspy.Highs()
|
|
1140
|
+
|
|
1141
|
+
keys = ["a", "b", "c"]
|
|
1142
|
+
D = h.addVariables(keys)
|
|
1143
|
+
X = h.addVariables(5)
|
|
1144
|
+
|
|
1145
|
+
self.assertEqual({k: int(v) for k, v in D.items()}, {"a": 0, "b": 1, "c": 2})
|
|
1146
|
+
self.assertEqual(list(map(int, X)), [3, 4, 5, 6, 7])
|
|
1147
|
+
|
|
1148
|
+
# delete variable and update collections
|
|
1149
|
+
h.deleteVariable(D["b"], D, X)
|
|
1150
|
+
|
|
1151
|
+
self.assertEqual(h.numVariables, 7)
|
|
1152
|
+
self.assertEqual({k: int(v) for k, v in D.items()}, {"a": 0, "b": -1, "c": 1})
|
|
1153
|
+
self.assertEqual(list(map(int, X)), [2, 3, 4, 5, 6])
|
|
1154
|
+
|
|
1155
|
+
# delete variable and update collections
|
|
1156
|
+
h.deleteVariable(X[3], D, X)
|
|
1157
|
+
|
|
1158
|
+
self.assertEqual(h.numVariables, 6)
|
|
1159
|
+
self.assertEqual({k: int(v) for k, v in D.items()}, {"a": 0, "b": -1, "c": 1})
|
|
1160
|
+
self.assertEqual(list(map(int, X)), [2, 3, 4, -1, 5])
|
|
1161
|
+
|
|
1162
|
+
# delete variable and update collections
|
|
1163
|
+
h.deleteVariable(X[2], D, *X)
|
|
1164
|
+
|
|
1165
|
+
self.assertEqual(h.numVariables, 5)
|
|
1166
|
+
self.assertEqual({k: int(v) for k, v in D.items()}, {"a": 0, "b": -1, "c": 1})
|
|
1167
|
+
self.assertEqual(list(map(int, X)), [2, 3, -1, -1, 4])
|
|
1168
|
+
|
|
1169
|
+
def test_remove_constraint(self):
|
|
1170
|
+
h = highspy.Highs()
|
|
1171
|
+
|
|
1172
|
+
keys = ["a", "b", "c"]
|
|
1173
|
+
D = h.addVariables(keys)
|
|
1174
|
+
X = h.addVariables(5)
|
|
1175
|
+
|
|
1176
|
+
c1 = h.addConstr(D["a"] + D["b"] + D["c"] == 1)
|
|
1177
|
+
cX = h.addConstrs((x >= 1 for x in X))
|
|
1178
|
+
c2 = h.addConstr(qsum(X) == 1)
|
|
1179
|
+
c3 = h.addConstr(qsum(D.values()) == 1)
|
|
1180
|
+
hash_test = {c1: "c1", c2: "c2", c3: "c3"}
|
|
1181
|
+
|
|
1182
|
+
self.assertEqual(h.numConstrs, 8)
|
|
1183
|
+
self.assertEqual([int(c1)] + list(map(int, cX)) + [int(c2), int(c3)], [0, 1, 2, 3, 4, 5, 6, 7])
|
|
1184
|
+
|
|
1185
|
+
# delete constr and update collections
|
|
1186
|
+
h.removeConstr(cX[2], c1, cX, c2, c3)
|
|
1187
|
+
|
|
1188
|
+
self.assertEqual(h.numConstrs, 7)
|
|
1189
|
+
self.assertEqual([int(c1)] + list(map(int, cX)) + [int(c2), int(c3)], [0, 1, 2, -1, 3, 4, 5, 6])
|
|
1190
|
+
|
|
1191
|
+
# delete variable and update collections
|
|
1192
|
+
h.removeConstr(c1, c1, cX)
|
|
1193
|
+
|
|
1194
|
+
self.assertEqual(h.numConstrs, 6)
|
|
1195
|
+
self.assertEqual([int(c1)] + list(map(int, cX)) + [int(c2), int(c3)], [-1, 0, 1, -1, 2, 3, 5, 6])
|
|
1196
|
+
|
|
1197
|
+
# add dictionary of constraints with highs_var keys
|
|
1198
|
+
cM = h.addConstrs({x: x >= 1 for x in X})
|
|
1199
|
+
self.assertEqual(h.numConstrs, 11)
|
|
1200
|
+
self.assertEqual([int(c1)] + list(map(int, cX)) + [int(c2), int(c3)], [-1, 0, 1, -1, 2, 3, 5, 6])
|
|
1201
|
+
self.assertEqual({int(k): int(c) for k, c in cM.items()}, {3: 6, 4: 7, 5: 8, 6: 9, 7: 10})
|
|
1202
|
+
|
|
1203
|
+
# add dictionary of constraints with string keys
|
|
1204
|
+
cD = h.addConstrs({k: x >= 1 for k, x in D.items()})
|
|
1205
|
+
self.assertEqual(h.numConstrs, 14)
|
|
1206
|
+
self.assertEqual([int(c1)] + list(map(int, cX)) + [int(c2), int(c3)], [-1, 0, 1, -1, 2, 3, 5, 6])
|
|
1207
|
+
self.assertEqual({int(k): int(c) for k, c in cM.items()}, {3: 6, 4: 7, 5: 8, 6: 9, 7: 10})
|
|
1208
|
+
self.assertEqual({k: int(c) for k, c in cD.items()}, {"a": 11, "b": 12, "c": 13})
|
|
1209
|
+
|
|
1210
|
+
# delete constraint from dictionary
|
|
1211
|
+
h.removeConstr(cM[X[2]], c1, cX, c2, c3, cM, cD)
|
|
1212
|
+
self.assertEqual(h.numConstrs, 13)
|
|
1213
|
+
self.assertEqual([int(c1)] + list(map(int, cX)) + [int(c2), int(c3)], [-1, 0, 1, -1, 2, 3, 5, 6]) # unchanged
|
|
1214
|
+
self.assertEqual({int(k): int(c) for k, c in cM.items()}, {3: 6, 4: 7, 5: -1, 6: 8, 7: 9})
|
|
1215
|
+
self.assertEqual({k: int(c) for k, c in cD.items()}, {"a": 10, "b": 11, "c": 12})
|
|
1216
|
+
|
|
1217
|
+
# delete constraint from dictionary
|
|
1218
|
+
h.removeConstr(cD["b"], c1, cX, c2, c3, cM, cD)
|
|
1219
|
+
self.assertEqual(h.numConstrs, 12)
|
|
1220
|
+
self.assertEqual([int(c1)] + list(map(int, cX)) + [int(c2), int(c3)], [-1, 0, 1, -1, 2, 3, 5, 6]) # unchanged
|
|
1221
|
+
self.assertEqual({int(k): int(c) for k, c in cM.items()}, {3: 6, 4: 7, 5: -1, 6: 8, 7: 9}) # unchanged
|
|
1222
|
+
self.assertEqual({k: int(c) for k, c in cD.items()}, {"a": 10, "b": -1, "c": 11})
|
|
1223
|
+
|
|
1224
|
+
# delete non-existent constraint
|
|
1225
|
+
self.assertRaises(Exception, lambda: h.removeConstr(cD["b"], c1, cX, c2, c3, cM, cD))
|
|
1226
|
+
|
|
1227
|
+
def test_qsum(self):
|
|
1228
|
+
"""Test summation."""
|
|
1229
|
+
h = highspy.Highs()
|
|
1230
|
+
X = h.addVariables(10)
|
|
1231
|
+
|
|
1232
|
+
# qsum
|
|
1233
|
+
expr = qsum(X)
|
|
1234
|
+
self.assertEqualExpr(expr, X, [1] * 10)
|
|
1235
|
+
|
|
1236
|
+
expr = qsum((2 * x for x in X))
|
|
1237
|
+
self.assertEqualExpr(expr, X, [2] * 10)
|
|
1238
|
+
|
|
1239
|
+
expr = qsum((qsum(X) for k in range(11))).simplify()
|
|
1240
|
+
self.assertEqualExpr(expr, X, [11] * 10)
|
|
1241
|
+
|
|
1242
|
+
# sum
|
|
1243
|
+
expr = sum(X)
|
|
1244
|
+
self.assertEqualExpr(expr, X, [1] * 10, 0)
|
|
1245
|
+
|
|
1246
|
+
expr = sum((2 * x for x in X))
|
|
1247
|
+
self.assertEqualExpr(expr, X, [2] * 10, 0)
|
|
1248
|
+
|
|
1249
|
+
# init sum with empty expression
|
|
1250
|
+
expr = sum((2 * x for x in X), highs_linear_expression())
|
|
1251
|
+
self.assertEqualExpr(expr, X, [2] * 10)
|
|
1252
|
+
|
|
1253
|
+
# manual sum
|
|
1254
|
+
expr = h.expr()
|
|
1255
|
+
for x in X:
|
|
1256
|
+
expr += x
|
|
1257
|
+
self.assertEqualExpr(expr, X, [1] * 10)
|
|
1258
|
+
|
|
1259
|
+
def test_user_interrupts(self):
|
|
1260
|
+
N = 8
|
|
1261
|
+
h = highspy.Highs()
|
|
1262
|
+
h.silent()
|
|
1263
|
+
|
|
1264
|
+
x = h.addBinaries(N, N)
|
|
1265
|
+
y = np.fliplr(x)
|
|
1266
|
+
|
|
1267
|
+
h.addConstrs(x.sum(axis = 0) == 1) # each col has exactly one queen
|
|
1268
|
+
h.addConstrs(x.sum(axis = 1) == 1) # each row has exactly one queen
|
|
1269
|
+
|
|
1270
|
+
h.addConstrs(x.diagonal(k).sum() <= 1 for k in range(-N + 1, N)) # each diagonal has at most one queen
|
|
1271
|
+
h.addConstrs(y.diagonal(k).sum() <= 1 for k in range(-N + 1, N)) # each 'reverse' diagonal has at most one queen
|
|
1272
|
+
|
|
1273
|
+
h.HandleUserInterrupt = True
|
|
1274
|
+
t = h.startSolve()
|
|
1275
|
+
self.assertRaises(Exception, lambda: h.startSolve())
|
|
1276
|
+
h.cancelSolve()
|
|
1277
|
+
h.wait()
|
|
1278
|
+
|
|
1279
|
+
h = self.get_basic_model()
|
|
1280
|
+
h.HandleKeyboardInterrupt = True
|
|
1281
|
+
self.assertEqual(h.HandleKeyboardInterrupt, True)
|
|
1282
|
+
self.assertEqual(h.HandleUserInterrupt, True)
|
|
1283
|
+
|
|
1284
|
+
h.solve()
|
|
1285
|
+
h.minimize()
|
|
1286
|
+
h.maximize()
|
|
1287
|
+
h.minimize()
|
|
1288
|
+
|
|
1289
|
+
h.joinSolve(h.startSolve())
|
|
1290
|
+
h.joinSolve(h.startSolve(), 0)
|
|
1291
|
+
|
|
1292
|
+
# replace wait function with Ctrl+C signal
|
|
1293
|
+
highspy.highs.Highs.wait = lambda self, t: signal.raise_signal(signal.SIGINT)
|
|
1294
|
+
h.HandleKeyboardInterrupt = False
|
|
1295
|
+
|
|
1296
|
+
self.assertEqual(h.HandleKeyboardInterrupt, False)
|
|
1297
|
+
self.assertEqual(h.HandleUserInterrupt, False)
|
|
1298
|
+
|
|
1299
|
+
h.joinSolve(h.startSolve(), 0)
|
|
1300
|
+
h.startSolve()
|
|
1301
|
+
h.joinSolve(None, 0)
|
|
1302
|
+
|
|
1303
|
+
with self.assertRaises(SystemExit):
|
|
1304
|
+
h.startSolve()
|
|
1305
|
+
h.joinSolve(None, 5)
|
|
1306
|
+
unittest.main(exit=False)
|
|
1307
|
+
|
|
1308
|
+
def test_callbacks(self):
|
|
1309
|
+
N = 8
|
|
1310
|
+
h = highspy.Highs()
|
|
1311
|
+
h.silent(False)
|
|
1312
|
+
|
|
1313
|
+
x = h.addBinaries(N, N)
|
|
1314
|
+
y = np.fliplr(x)
|
|
1315
|
+
|
|
1316
|
+
h.addConstrs(h.qsum(x[i, :]) == 1 for i in range(N)) # each row has exactly one queen
|
|
1317
|
+
h.addConstrs(h.qsum(x[:, j]) == 1 for j in range(N)) # each col has exactly one queen
|
|
1318
|
+
|
|
1319
|
+
h.addConstrs(h.qsum(x.diagonal(k)) <= 1 for k in range(-N + 1, N)) # each diagonal has at most one queen
|
|
1320
|
+
h.addConstrs(h.qsum(y.diagonal(k)) <= 1 for k in range(-N + 1, N)) # each 'reverse' diagonal has at most one queen
|
|
1321
|
+
|
|
1322
|
+
do_nothing = lambda e: None
|
|
1323
|
+
|
|
1324
|
+
check_callback = []
|
|
1325
|
+
chk_callback = lambda e: check_callback.append(e)
|
|
1326
|
+
|
|
1327
|
+
check_solution = []
|
|
1328
|
+
chk_solution = lambda e: check_solution.append(e.val(x))
|
|
1329
|
+
|
|
1330
|
+
# check callback is added and called
|
|
1331
|
+
h.cbLogging += chk_callback
|
|
1332
|
+
h.cbMipSolution += chk_solution
|
|
1333
|
+
self.assertEqual(len(h.cbLogging.callbacks), 1)
|
|
1334
|
+
self.assertEqual(len(h.cbMipSolution.callbacks), 1)
|
|
1335
|
+
h.solve()
|
|
1336
|
+
self.assertNotEqual(len(check_callback), 0)
|
|
1337
|
+
self.assertNotEqual(len(check_solution), 0)
|
|
1338
|
+
check_callback.clear()
|
|
1339
|
+
check_solution.clear()
|
|
1340
|
+
|
|
1341
|
+
# check callback is removed and not called
|
|
1342
|
+
h.cbLogging -= chk_callback
|
|
1343
|
+
h.cbMipSolution -= chk_solution
|
|
1344
|
+
self.assertEqual(len(h.cbLogging.callbacks), 0)
|
|
1345
|
+
self.assertEqual(len(h.cbMipSolution.callbacks), 0)
|
|
1346
|
+
h.solve()
|
|
1347
|
+
self.assertEqual(len(check_callback), 0)
|
|
1348
|
+
self.assertEqual(len(check_solution), 0)
|
|
1349
|
+
|
|
1350
|
+
h.disableCallbacks()
|
|
1351
|
+
self.assertRaises(Exception, lambda: h.cbLogging.subscribe(do_nothing))
|
|
1352
|
+
h.enableCallbacks()
|
|
1353
|
+
|
|
1354
|
+
h.cbLogging += chk_callback
|
|
1355
|
+
h.cbSimplexInterrupt += do_nothing
|
|
1356
|
+
h.cbIpmInterrupt += do_nothing
|
|
1357
|
+
h.cbMipSolution += do_nothing
|
|
1358
|
+
h.cbMipImprovingSolution += do_nothing
|
|
1359
|
+
h.cbMipLogging += do_nothing
|
|
1360
|
+
h.cbMipInterrupt += do_nothing
|
|
1361
|
+
h.cbMipGetCutPool += do_nothing
|
|
1362
|
+
h.cbMipDefineLazyConstraints += do_nothing
|
|
1363
|
+
|
|
1364
|
+
self.assertEqual(len(h.cbLogging.callbacks), 1)
|
|
1365
|
+
|
|
1366
|
+
# check callback is disabled and not called
|
|
1367
|
+
h.disableCallbacks()
|
|
1368
|
+
self.assertEqual(len(h.cbLogging.callbacks), 1)
|
|
1369
|
+
h.solve()
|
|
1370
|
+
self.assertEqual(len(check_callback), 0)
|
|
1371
|
+
check_callback.clear()
|
|
1372
|
+
|
|
1373
|
+
# check callback is enabled and called
|
|
1374
|
+
h.enableCallbacks()
|
|
1375
|
+
self.assertEqual(len(h.cbLogging.callbacks), 1)
|
|
1376
|
+
h.solve()
|
|
1377
|
+
self.assertNotEqual(len(check_callback), 0)
|
|
1378
|
+
check_callback.clear()
|
|
1379
|
+
|
|
1380
|
+
h.cbLogging -= chk_callback
|
|
1381
|
+
h.cbSimplexInterrupt -= do_nothing
|
|
1382
|
+
h.cbIpmInterrupt -= do_nothing
|
|
1383
|
+
h.cbMipSolution -= do_nothing
|
|
1384
|
+
h.cbMipImprovingSolution -= do_nothing
|
|
1385
|
+
h.cbMipLogging -= do_nothing
|
|
1386
|
+
h.cbMipInterrupt -= do_nothing
|
|
1387
|
+
h.cbMipGetCutPool -= do_nothing
|
|
1388
|
+
h.cbMipDefineLazyConstraints -= do_nothing
|
|
1389
|
+
|
|
1390
|
+
self.assertEqual(len(h.cbLogging.callbacks), 0)
|
|
1391
|
+
h.cbLogging.subscribe(do_nothing)
|
|
1392
|
+
self.assertEqual(len(h.cbLogging.callbacks), 1)
|
|
1393
|
+
h.cbLogging.unsubscribe(do_nothing)
|
|
1394
|
+
self.assertEqual(len(h.cbLogging.callbacks), 0)
|
|
1395
|
+
h.cbLogging.unsubscribe(do_nothing) # does not throw error if not exists
|
|
1396
|
+
self.assertEqual(len(h.cbLogging.callbacks), 0)
|
|
1397
|
+
|
|
1398
|
+
h.cbLogging.subscribe(do_nothing, "test")
|
|
1399
|
+
self.assertEqual(len(h.cbLogging.callbacks), 1)
|
|
1400
|
+
h.cbLogging.unsubscribe_by_data("test")
|
|
1401
|
+
self.assertEqual(len(h.cbLogging.callbacks), 0)
|
|
1402
|
+
|
|
1403
|
+
h.cbLogging += do_nothing
|
|
1404
|
+
h.cbLogging += do_nothing
|
|
1405
|
+
h.cbLogging += do_nothing
|
|
1406
|
+
self.assertEqual(len(h.cbLogging.callbacks), 3)
|
|
1407
|
+
h.cbLogging.clear()
|
|
1408
|
+
self.assertEqual(len(h.cbLogging.callbacks), 0)
|
|
1409
|
+
|
|
1410
|
+
self.assertRaises(Exception, lambda: h.__setattr__("cbLogging", None))
|
|
1411
|
+
self.assertRaises(Exception, lambda: h.__setattr__("cbSimplexInterrupt", None))
|
|
1412
|
+
self.assertRaises(Exception, lambda: h.__setattr__("cbIpmInterrupt", None))
|
|
1413
|
+
self.assertRaises(Exception, lambda: h.__setattr__("cbMipSolution", None))
|
|
1414
|
+
self.assertRaises(Exception, lambda: h.__setattr__("cbMipImprovingSolution", None))
|
|
1415
|
+
self.assertRaises(Exception, lambda: h.__setattr__("cbMipLogging", None))
|
|
1416
|
+
self.assertRaises(Exception, lambda: h.__setattr__("cbMipInterrupt", None))
|
|
1417
|
+
self.assertRaises(Exception, lambda: h.__setattr__("cbMipGetCutPool", None))
|
|
1418
|
+
self.assertRaises(Exception, lambda: h.__setattr__("cbMipDefineLazyConstraints", None))
|
|
1419
|
+
|
|
1420
|
+
|
|
1421
|
+
def test_usercallbacks(self):
|
|
1422
|
+
N = 8
|
|
1423
|
+
h = highspy.Highs()
|
|
1424
|
+
h.silent()
|
|
1425
|
+
|
|
1426
|
+
x = h.addBinaries(N, N)
|
|
1427
|
+
y = np.fliplr(x)
|
|
1428
|
+
|
|
1429
|
+
h.addConstrs(h.qsum(x[i, :]) == 1 for i in range(N)) # each row has exactly one queen
|
|
1430
|
+
h.addConstrs(h.qsum(x[:, j]) == 1 for j in range(N)) # each col has exactly one queen
|
|
1431
|
+
|
|
1432
|
+
h.addConstrs(h.qsum(x.diagonal(k)) <= 1 for k in range(-N + 1, N)) # each diagonal has at most one queen
|
|
1433
|
+
h.addConstrs(h.qsum(y.diagonal(k)) <= 1 for k in range(-N + 1, N)) # each 'reverse' diagonal has at most one queen
|
|
1434
|
+
|
|
1435
|
+
# minimize index where queen is placed
|
|
1436
|
+
h.minimize((x.astype(int) * x).sum())
|
|
1437
|
+
sol = h.val(x)
|
|
1438
|
+
self.assertEqual(sol.shape, (N, N))
|
|
1439
|
+
|
|
1440
|
+
# verify callback called
|
|
1441
|
+
check_called = [False]
|
|
1442
|
+
|
|
1443
|
+
def check_called_func(e):
|
|
1444
|
+
check_called[0] = True
|
|
1445
|
+
|
|
1446
|
+
h.cbMipUserSolution += check_called_func
|
|
1447
|
+
|
|
1448
|
+
# verify initialization
|
|
1449
|
+
h.cbMipUserSolution += lambda e: self.assertEqual(e.data_in.user_has_solution, False)
|
|
1450
|
+
|
|
1451
|
+
def partial_solution(e):
|
|
1452
|
+
# different sizes
|
|
1453
|
+
self.assertEqual(e.data_in.setSolution(range(N*N), sol[::2]), highspy.HighsStatus.kError)
|
|
1454
|
+
|
|
1455
|
+
# get every 2nd element from 2d numpy sol array
|
|
1456
|
+
self.assertEqual(e.data_in.setSolution(x[:, ::2], sol[:, ::2]), highspy.HighsStatus.kOk)
|
|
1457
|
+
self.assertEqual(list(e.data_in.user_solution[0:4]), [sol[0,0],highspy.kHighsUndefined,sol[0,2],highspy.kHighsUndefined])
|
|
1458
|
+
self.assertEqual(e.data_in.repairSolution(), highspy.HighsStatus.kOk)
|
|
1459
|
+
self.assertEqual(list(e.data_in.user_solution[0:8]), list(sol[0,0:8]))
|
|
1460
|
+
|
|
1461
|
+
def try_change_ptr(e):
|
|
1462
|
+
e.data_in.user_solution = [0] * (N*N)
|
|
1463
|
+
|
|
1464
|
+
self.assertRaises(Exception, lambda: try_change_ptr(e))
|
|
1465
|
+
|
|
1466
|
+
# modify directly
|
|
1467
|
+
e.data_in.user_solution[:] = highspy.kHighsUndefined
|
|
1468
|
+
self.assertEqual(e.data_in.user_solution[8], highspy.kHighsUndefined)
|
|
1469
|
+
e.data_in.user_has_solution = False
|
|
1470
|
+
|
|
1471
|
+
# set subset partial without index
|
|
1472
|
+
# note: we're setting a sub-optimal feasible solution here
|
|
1473
|
+
self.assertEqual(e.data_in.setSolution([0., 0., 0., 0., 0., 0., highspy.kHighsUndefined, 0.]), highspy.HighsStatus.kOk)
|
|
1474
|
+
self.assertEqual(e.data_in.repairSolution(), highspy.HighsStatus.kOk)
|
|
1475
|
+
self.assertEqual(list(e.data_in.user_solution[0:8]), [0., 0., 0., 0., 0., 0., 1., 0.])
|
|
1476
|
+
self.assertEqual(e.data_in.user_has_solution, True)
|
|
1477
|
+
|
|
1478
|
+
# set partial solution with fractional value
|
|
1479
|
+
self.assertEqual(e.data_in.setSolution([0., 0.5]), highspy.HighsStatus.kOk)
|
|
1480
|
+
self.assertEqual(e.data_in.repairSolution(), highspy.HighsStatus.kError)
|
|
1481
|
+
|
|
1482
|
+
# verify partial solution
|
|
1483
|
+
h.cbMipUserSolution += partial_solution
|
|
1484
|
+
|
|
1485
|
+
# verify full solution
|
|
1486
|
+
h.cbMipUserSolution += lambda e: self.assertEqual(e.data_in.setSolution([0] * (N * N + 1)), highspy.HighsStatus.kError)
|
|
1487
|
+
h.cbMipUserSolution += lambda e: self.assertEqual(e.data_in.setSolution(sol), highspy.HighsStatus.kOk)
|
|
1488
|
+
|
|
1489
|
+
h.clearSolver()
|
|
1490
|
+
h.solve()
|
|
1491
|
+
self.assertEqual(check_called[0], True)
|
|
1492
|
+
|
|
1493
|
+
|
|
1494
|
+
class TestHighsLinearExpressionPy(unittest.TestCase):
|
|
1495
|
+
def setUp(self):
|
|
1496
|
+
self.h = highspy.Highs()
|
|
1497
|
+
self.h.silent()
|
|
1498
|
+
|
|
1499
|
+
self.x = self.h.addVariables(10)
|
|
1500
|
+
|
|
1501
|
+
def assertEqualExpr(self, expr, idxs, vals, constant=None, bounds=None):
|
|
1502
|
+
self.assertEqual(list(map(int, expr.idxs)), list(map(int, idxs)), "variable index")
|
|
1503
|
+
self.assertEqual(expr.vals, vals, "variable values")
|
|
1504
|
+
self.assertEqual(expr.constant, constant, "constant")
|
|
1505
|
+
self.assertEqual(expr.bounds, (bounds[0], bounds[1]) if bounds is not None else None, "bounds")
|
|
1506
|
+
|
|
1507
|
+
def test_init_empty(self):
|
|
1508
|
+
# Test initialization with no arguments
|
|
1509
|
+
expr = highspy.highs.highs_linear_expression()
|
|
1510
|
+
self.assertEqualExpr(expr, [], [])
|
|
1511
|
+
|
|
1512
|
+
expr = self.h.expr()
|
|
1513
|
+
self.assertEqualExpr(expr, [], [])
|
|
1514
|
+
self.assertRaises(Exception, lambda: self.h.expr([]))
|
|
1515
|
+
self.assertRaises(Exception, lambda: self.h.expr(self.h))
|
|
1516
|
+
|
|
1517
|
+
def test_init_var(self):
|
|
1518
|
+
# Test initialization with a highs_var
|
|
1519
|
+
expr = highspy.highs.highs_linear_expression(self.x[0])
|
|
1520
|
+
self.assertEqualExpr(expr, [self.x[0]], [1.0])
|
|
1521
|
+
|
|
1522
|
+
expr = 1.0 * self.x[0]
|
|
1523
|
+
self.assertEqualExpr(expr, [self.x[0]], [1.0])
|
|
1524
|
+
|
|
1525
|
+
expr = self.h.expr(self.x[0])
|
|
1526
|
+
self.assertEqualExpr(expr, [self.x[0]], [1.0])
|
|
1527
|
+
|
|
1528
|
+
def test_init_const(self):
|
|
1529
|
+
# Test initialization with a constant
|
|
1530
|
+
expr = highspy.highs.highs_linear_expression(5)
|
|
1531
|
+
self.assertEqualExpr(expr, [], [], 5)
|
|
1532
|
+
|
|
1533
|
+
expr = self.h.expr(5)
|
|
1534
|
+
self.assertEqualExpr(expr, [], [], 5)
|
|
1535
|
+
|
|
1536
|
+
def test_mutable(self):
|
|
1537
|
+
x, y, z = self.x[0:3]
|
|
1538
|
+
|
|
1539
|
+
expr = x + 2 * y
|
|
1540
|
+
expr2 = expr # reference to expr
|
|
1541
|
+
expr3 = expr.copy() # copy of expr
|
|
1542
|
+
self.assertEqualExpr(expr, [x, y], [1, 2])
|
|
1543
|
+
self.assertEqualExpr(expr2, [x, y], [1, 2])
|
|
1544
|
+
self.assertEqualExpr(expr3, [x, y], [1, 2])
|
|
1545
|
+
|
|
1546
|
+
expr += z
|
|
1547
|
+
self.assertEqualExpr(expr, [x, y, z], [1, 2, 1])
|
|
1548
|
+
self.assertEqualExpr(expr2, [x, y, z], [1, 2, 1])
|
|
1549
|
+
self.assertEqualExpr(expr3, [x, y], [1, 2])
|
|
1550
|
+
|
|
1551
|
+
expr *= 2
|
|
1552
|
+
self.assertEqualExpr(expr, [x, y, z], [2, 4, 2])
|
|
1553
|
+
self.assertEqualExpr(expr2, [x, y, z], [2, 4, 2])
|
|
1554
|
+
self.assertEqualExpr(expr3, [x, y], [1, 2])
|
|
1555
|
+
|
|
1556
|
+
# test simplify
|
|
1557
|
+
expr += x + y + z
|
|
1558
|
+
expr += x + y + z
|
|
1559
|
+
expr += x + y + z
|
|
1560
|
+
self.assertEqualExpr(expr, [x, y, z] + [x, y, z] * 3, [2, 4, 2] + [1, 1, 1] * 3)
|
|
1561
|
+
|
|
1562
|
+
expr4 = expr.simplify()
|
|
1563
|
+
self.assertEqualExpr(expr, [x, y, z] + [x, y, z] * 3, [2, 4, 2] + [1, 1, 1] * 3)
|
|
1564
|
+
self.assertEqualExpr(expr4, [x, y, z], [5, 7, 5])
|
|
1565
|
+
|
|
1566
|
+
# test edge cases
|
|
1567
|
+
e1 = x + z <= 3
|
|
1568
|
+
e2 = 2 * y
|
|
1569
|
+
|
|
1570
|
+
# addition
|
|
1571
|
+
self.assertRaises(Exception, lambda: e1 + (e2 + 3)) # cannot add if one has bounds and the other has constant
|
|
1572
|
+
self.assertRaises(Exception, lambda: e1 + 5) # cannot add constant to expr with bounds
|
|
1573
|
+
self.assertRaises(Exception, lambda: e1 + []) # unknown type
|
|
1574
|
+
|
|
1575
|
+
expr = e1 + (1 <= (e2 + 4) <= 2)
|
|
1576
|
+
self.assertEqualExpr(expr, [x, z, y], [1, 1, 2], None, [-self.h.inf, 1])
|
|
1577
|
+
|
|
1578
|
+
expr = e2.copy()
|
|
1579
|
+
expr += e1
|
|
1580
|
+
self.assertEqualExpr(expr, [y, x, z], [2, 1, 1], None, [-self.h.inf, 3])
|
|
1581
|
+
|
|
1582
|
+
# subtract
|
|
1583
|
+
self.assertRaises(Exception, lambda: e1 - (e2 + 3)) # cannot add if one has bounds and the other has constant
|
|
1584
|
+
self.assertRaises(Exception, lambda: e1 - 5) # cannot add constant to expr with bounds
|
|
1585
|
+
self.assertRaises(Exception, lambda: e1 - []) # unknown type
|
|
1586
|
+
|
|
1587
|
+
expr = e1 - (1 <= (e2 + 4) <= 2) # (-inf <= x + z <= 3) + (2 <= -2y <= 3)
|
|
1588
|
+
self.assertEqualExpr(expr, [x, z, y], [1, 1, -2], None, [-self.h.inf, 6])
|
|
1589
|
+
|
|
1590
|
+
expr = e2.copy()
|
|
1591
|
+
expr -= e1
|
|
1592
|
+
self.assertEqualExpr(expr, [y, x, z], [2, -1, -1], None, [-3, self.h.inf])
|
|
1593
|
+
|
|
1594
|
+
def test_immutable(self):
|
|
1595
|
+
x, y, z = self.x[0:3]
|
|
1596
|
+
|
|
1597
|
+
expr = (1 * x - 2 * y).simplify()
|
|
1598
|
+
self.assertEqualExpr(expr, [x, y], [1, -2])
|
|
1599
|
+
|
|
1600
|
+
expr2 = expr + z
|
|
1601
|
+
self.assertEqualExpr(expr, [x, y], [1, -2])
|
|
1602
|
+
self.assertEqualExpr(expr2, [x, y, z], [1, -2, 1])
|
|
1603
|
+
|
|
1604
|
+
expr2 = expr + 5
|
|
1605
|
+
self.assertEqualExpr(expr, [x, y], [1, -2])
|
|
1606
|
+
self.assertEqualExpr(expr2, [x, y], [1, -2], 5)
|
|
1607
|
+
|
|
1608
|
+
expr2 = expr <= 3
|
|
1609
|
+
self.assertEqualExpr(expr, [x, y], [1, -2])
|
|
1610
|
+
self.assertEqualExpr(expr2, [x, y], [1, -2], None, [-self.h.inf, 3])
|
|
1611
|
+
|
|
1612
|
+
expr2 = 0 <= expr <= 3
|
|
1613
|
+
self.assertEqualExpr(expr, [x, y], [1, -2])
|
|
1614
|
+
self.assertEqualExpr(expr2, [x, y], [1, -2], None, [0, 3])
|
|
1615
|
+
|
|
1616
|
+
expr2 = 0 <= expr <= 3
|
|
1617
|
+
expr2 += z
|
|
1618
|
+
self.assertEqualExpr(expr, [x, y], [1, -2])
|
|
1619
|
+
self.assertEqualExpr(expr2, [x, y, z], [1, -2, 1], None, [0, 3])
|
|
1620
|
+
|
|
1621
|
+
def test_negation(self):
|
|
1622
|
+
# Test negation of a highs_var
|
|
1623
|
+
expr = -self.x[0]
|
|
1624
|
+
self.assertEqualExpr(expr, [self.x[0]], [-1])
|
|
1625
|
+
|
|
1626
|
+
# Test negation of a highs_linear_expression
|
|
1627
|
+
x, y = self.x[0:2]
|
|
1628
|
+
expr = x - 2 * y
|
|
1629
|
+
self.assertEqualExpr(expr, [x, y], [1, -2])
|
|
1630
|
+
negr = -expr
|
|
1631
|
+
self.assertEqualExpr(negr, [x, y], [-1, 2])
|
|
1632
|
+
|
|
1633
|
+
# Test negation of a highs_linear_expression
|
|
1634
|
+
expr = -self.h.qsum(self.x)
|
|
1635
|
+
self.assertEqualExpr(expr, list(map(int, self.x)), [-1] * len(self.x))
|
|
1636
|
+
|
|
1637
|
+
def test_equality(self):
|
|
1638
|
+
x, y = self.x[0:2]
|
|
1639
|
+
|
|
1640
|
+
expr = x == y
|
|
1641
|
+
self.assertEqualExpr(expr, [x, y], [1, -1], None, [0, 0])
|
|
1642
|
+
|
|
1643
|
+
expr = x + y == [1, 2]
|
|
1644
|
+
self.assertEqualExpr(expr, [x, y], [1, 1], None, [1, 2])
|
|
1645
|
+
self.assertRaises(Exception, lambda: x == [x, y])
|
|
1646
|
+
self.assertRaises(Exception, lambda: x == self.h)
|
|
1647
|
+
self.assertRaises(Exception, lambda: x != self.h)
|
|
1648
|
+
self.assertRaises(Exception, lambda: x + y != y)
|
|
1649
|
+
self.assertRaises(Exception, lambda: x + 5 != self.h)
|
|
1650
|
+
|
|
1651
|
+
def test_le_inequality(self):
|
|
1652
|
+
x, y = self.x[0:2]
|
|
1653
|
+
|
|
1654
|
+
# Test inequality of two highs_linear_expressions
|
|
1655
|
+
expr = x <= y
|
|
1656
|
+
self.assertEqualExpr(expr, [x, y], [1, -1], None, [-self.h.inf, 0])
|
|
1657
|
+
self.assertRaises(Exception, lambda: x <= self.h)
|
|
1658
|
+
|
|
1659
|
+
def test_ge_inequality(self):
|
|
1660
|
+
x, y = self.x[0:2]
|
|
1661
|
+
|
|
1662
|
+
# Test inequality of two highs_linear_expressions
|
|
1663
|
+
expr = x >= y # y - x <= 0
|
|
1664
|
+
self.assertEqualExpr(expr, [y, x], [1, -1], None, [-self.h.inf, 0])
|
|
1665
|
+
self.assertRaises(Exception, lambda: x >= self.h)
|
|
1666
|
+
self.assertRaises(Exception, lambda: x + 4 >= self.h)
|
|
1667
|
+
self.assertRaises(Exception, lambda: x + 4 >= (y <= 2))
|
|
1668
|
+
|
|
1669
|
+
def test_chain_inequality(self):
|
|
1670
|
+
x, y, z = self.x[0:3]
|
|
1671
|
+
|
|
1672
|
+
# test basic chain inequality
|
|
1673
|
+
expr = 2 <= x + y <= 6
|
|
1674
|
+
self.assertEqualExpr(expr, [x, y], [1, 1], None, [2, 6])
|
|
1675
|
+
|
|
1676
|
+
expr = 2 <= (x + y) <= 6
|
|
1677
|
+
self.assertEqualExpr(expr, [x, y], [1, 1], None, [2, 6])
|
|
1678
|
+
|
|
1679
|
+
expr = 2 <= x <= 6
|
|
1680
|
+
self.assertEqualExpr(expr, [x], [1], None, [2, 6])
|
|
1681
|
+
|
|
1682
|
+
# advanced chain use cases
|
|
1683
|
+
expr = y <= 6 + x <= y # -6 <= x - y <= -6
|
|
1684
|
+
self.assertEqualExpr(expr, [x, y], [1, -1], None, [-6, -6])
|
|
1685
|
+
|
|
1686
|
+
expr = x <= 6 <= x # x == 6
|
|
1687
|
+
self.assertEqualExpr(expr, [x], [1], None, [6, 6])
|
|
1688
|
+
|
|
1689
|
+
expr = x + y <= 6 <= x + y # 6 <= x + y <= 6
|
|
1690
|
+
self.assertEqualExpr(expr, [x, y], [1, 1], None, [6, 6])
|
|
1691
|
+
|
|
1692
|
+
expr = x + y + 1 <= 6 <= x + y + 2 # 4 <= x + y <= 5
|
|
1693
|
+
self.assertEqualExpr(expr, [x, y], [1, 1], None, [4, 5])
|
|
1694
|
+
|
|
1695
|
+
# test chain ordering with a constant
|
|
1696
|
+
t1 = x + y
|
|
1697
|
+
t2 = x - y
|
|
1698
|
+
self.assertEqualExpr(t1, [x, y], [1, 1])
|
|
1699
|
+
self.assertEqualExpr(t2, [x, y], [1, -1])
|
|
1700
|
+
|
|
1701
|
+
expr = (t1 + t2).simplify() # 2x + 0y
|
|
1702
|
+
self.assertEqualExpr(expr, [x, y], [2, 0])
|
|
1703
|
+
|
|
1704
|
+
t3 = 2 <= expr <= 4 # 2 <= 2x + 0y <= 4
|
|
1705
|
+
self.assertEqualExpr(t3, [x, y], [2, 0], None, [2, 4])
|
|
1706
|
+
|
|
1707
|
+
vx, vl = [x, y, x, y], [1, 1, 1, -1]
|
|
1708
|
+
|
|
1709
|
+
t3 = 2 <= (t1 + t2) <= 4 # 2 <= 2x + 0y <= 4
|
|
1710
|
+
self.assertEqualExpr(t3, vx, vl, None, [2, 4])
|
|
1711
|
+
|
|
1712
|
+
t3 = 2 <= t1 + t2 <= 4 # 2 <= 2x + 0y <= 4
|
|
1713
|
+
self.assertEqualExpr(t3, vx, vl, None, [2, 4])
|
|
1714
|
+
|
|
1715
|
+
t3 = (t1 + t2) <= 4 # -inf <= 2x + 0y <= 4
|
|
1716
|
+
self.assertEqualExpr(t3, vx, vl, None, [-self.h.inf, 4])
|
|
1717
|
+
|
|
1718
|
+
t3 = t1 + t2 <= 4 # -inf <= 2x + 0y <= 4
|
|
1719
|
+
self.assertEqualExpr(t3, vx, vl, None, [-self.h.inf, 4])
|
|
1720
|
+
|
|
1721
|
+
t3 = 2 <= t1 + t2 # 2 <= 2x + 0y <= inf
|
|
1722
|
+
self.assertEqualExpr(t3, vx, vl, None, [2, self.h.inf])
|
|
1723
|
+
|
|
1724
|
+
t3 = t1 + t2 + 5 # 2x + 0y + 5
|
|
1725
|
+
self.assertEqualExpr(t3, vx, vl, 5)
|
|
1726
|
+
|
|
1727
|
+
t3 = 5 + t1 + t2 # 2x + 0y + 5
|
|
1728
|
+
self.assertEqualExpr(t3, vx, vl, 5)
|
|
1729
|
+
|
|
1730
|
+
t3 = 5 <= t1 + t2 + 5 # 0 <= 2x + 0y <= inf
|
|
1731
|
+
self.assertEqualExpr(t3, vx, vl, None, [0, self.h.inf])
|
|
1732
|
+
|
|
1733
|
+
t3 = 5 + t1 + t2 <= 4 # -inf <= 2x + 0y <= -1
|
|
1734
|
+
self.assertEqualExpr(t3, vx, vl, None, [-self.h.inf, -1])
|
|
1735
|
+
|
|
1736
|
+
t3 = 2 <= 5 + t1 + t2 # -3 <= 2x + 0y <= inf
|
|
1737
|
+
self.assertEqualExpr(t3, vx, vl, None, [-3, self.h.inf])
|
|
1738
|
+
|
|
1739
|
+
t3 = 2 <= 5 + t1 + t2 <= 6 # -3 <= 2x + 0y <= 1
|
|
1740
|
+
self.assertEqualExpr(t3, vx, vl, None, [-3, 1])
|
|
1741
|
+
|
|
1742
|
+
# test chain with variables on both sides
|
|
1743
|
+
t3 = 5 + x - x <= y <= 10 # 5 <= y <= 10
|
|
1744
|
+
self.assertEqualExpr(t3, [y], [1], None, [5, 10])
|
|
1745
|
+
|
|
1746
|
+
t3 = 5 + 2 * x - 2 * x <= y <= 10 # 5 <= y <= 10
|
|
1747
|
+
self.assertEqualExpr(t3, [y], [1], None, [5, 10])
|
|
1748
|
+
|
|
1749
|
+
t3 = 5 <= y <= 10 + 2 * x - 2 * x # 5 <= y <= 10
|
|
1750
|
+
self.assertEqualExpr(t3, [y], [1], None, [5, 10])
|
|
1751
|
+
|
|
1752
|
+
t3 = 5 - x + x <= y <= 10 + y - y # 5 <= y <= 10
|
|
1753
|
+
self.assertEqualExpr(t3, [y], [1], None, [5, 10])
|
|
1754
|
+
|
|
1755
|
+
t3 = 10 >= y >= 5 + x - x # 5 <= y <= 10
|
|
1756
|
+
self.assertEqualExpr(t3, [y], [1], None, [5, 10])
|
|
1757
|
+
|
|
1758
|
+
t3 = 10 >= y >= 5 + 2 * x - 2 * x # 5 <= y <= 10
|
|
1759
|
+
self.assertEqualExpr(t3, [y], [1], None, [5, 10])
|
|
1760
|
+
|
|
1761
|
+
t3 = 10 + 2 * x - 2 * x >= y >= 5 # 5 <= y <= 10
|
|
1762
|
+
self.assertEqualExpr(t3, [y], [1], None, [5, 10])
|
|
1763
|
+
|
|
1764
|
+
t3 = 10 + y - y >= y >= 5 - x + x # 5 <= y <= 10
|
|
1765
|
+
self.assertEqualExpr(t3, [y], [1], None, [5, 10])
|
|
1766
|
+
|
|
1767
|
+
vx, vl, nl = list(self.x), [1] * len(self.x), [-1] * len(self.x)
|
|
1768
|
+
t3 = qsum(self.x) <= 10 # -inf <= sum(x) <= 10
|
|
1769
|
+
self.assertEqualExpr(t3, vx, vl, None, [-self.h.inf, 10])
|
|
1770
|
+
|
|
1771
|
+
t3 = qsum(self.x) <= y # -inf <= sum(x) - y <= 0
|
|
1772
|
+
self.assertEqualExpr(t3, vx + [y], vl + [-1], None, [-self.h.inf, 0])
|
|
1773
|
+
|
|
1774
|
+
t3 = y <= qsum(self.x) <= y # sum(x) == 0
|
|
1775
|
+
self.assertEqualExpr(t3, vx + [y], vl + [-1], None, [0, 0])
|
|
1776
|
+
|
|
1777
|
+
t3 = y >= qsum(self.x) >= y # sum(x) == 0
|
|
1778
|
+
self.assertEqualExpr(t3, vx + [y], vl + [-1], None, [0, 0])
|
|
1779
|
+
|
|
1780
|
+
t3 = qsum(self.x) == y # sum(x) - y == 0
|
|
1781
|
+
self.assertEqualExpr(t3, vx + [y], vl + [-1], None, [0, 0])
|
|
1782
|
+
|
|
1783
|
+
t3 = y == qsum(self.x) # sum(x) - y == 0
|
|
1784
|
+
self.assertEqualExpr(t3, vx + [y], vl + [-1], None, [0, 0])
|
|
1785
|
+
|
|
1786
|
+
t3 = y + 1 <= qsum(self.x) <= y + 6 # 1 <= sum(x) - y <= 6
|
|
1787
|
+
self.assertEqualExpr(t3, vx + [y], vl + [-1], None, [1, 6])
|
|
1788
|
+
|
|
1789
|
+
t3 = y + 6 >= qsum(self.x) >= y + 1 # 1 <= sum(x) - y <= 6
|
|
1790
|
+
self.assertEqualExpr(t3, vx + [y], vl + [-1], None, [1, 6])
|
|
1791
|
+
|
|
1792
|
+
t3 = qsum(self.x) >= y >= qsum(self.x) # sum(x) - y == 0
|
|
1793
|
+
self.assertEqualExpr(t3, vx + [y], vl + [-1], None, [0, 0])
|
|
1794
|
+
|
|
1795
|
+
t3 = qsum(self.x) <= y <= qsum(self.x) # sum(x) - y == 0
|
|
1796
|
+
self.assertEqualExpr(t3, vx + [y], vl + [-1], None, [0, 0])
|
|
1797
|
+
|
|
1798
|
+
t3 = qsum(self.x) + 5 >= y >= qsum(self.x) + 2 # -5 <= sum(x) - y <= -2
|
|
1799
|
+
self.assertEqualExpr(t3, vx + [y], vl + [-1], None, [-5, -2])
|
|
1800
|
+
|
|
1801
|
+
t3 = qsum(self.x) + 2 <= y <= qsum(self.x) + 5 # -5 <= sum(x) - y <= -2
|
|
1802
|
+
self.assertEqualExpr(t3, vx + [y], vl + [-1], None, [-5, -2])
|
|
1803
|
+
|
|
1804
|
+
t3 = (qsum(self.x) == 1 + qsum(self.x)).simplify() # [] == 1
|
|
1805
|
+
self.assertEqualExpr(t3, vx, [0] * len(vx), None, [1, 1])
|
|
1806
|
+
|
|
1807
|
+
self.assertRaises(Exception, lambda: x <= y <= 1)
|
|
1808
|
+
self.assertRaises(Exception, lambda: (qsum(self.x) + 5 >= y) >= qsum(self.x) + 2)
|
|
1809
|
+
self.assertRaises(Exception, lambda: qsum(self.x) + 2 <= (y <= qsum(self.x) + 5))
|
|
1810
|
+
self.assertRaises(Exception, lambda: qsum(self.x) + 2 <= y <= 5)
|
|
1811
|
+
self.assertRaises(Exception, lambda: 2 <= y <= 5 + qsum(self.x))
|
|
1812
|
+
|
|
1813
|
+
def test_order_priority(self):
|
|
1814
|
+
x, y, z = self.x[:3]
|
|
1815
|
+
|
|
1816
|
+
# prefer more variables
|
|
1817
|
+
self.assertEqualExpr(x <= y + z, [y, z, x], [1, 1, -1], None, [0, self.h.inf])
|
|
1818
|
+
self.assertEqualExpr(y + z >= x, [y, z, x], [1, 1, -1], None, [0, self.h.inf])
|
|
1819
|
+
self.assertEqualExpr(x >= y + z, [y, z, x], [1, 1, -1], None, [-self.h.inf, 0])
|
|
1820
|
+
self.assertEqualExpr(y + z <= x, [y, z, x], [1, 1, -1], None, [-self.h.inf, 0])
|
|
1821
|
+
self.assertEqualExpr(y + z == x, [y, z, x], [1, 1, -1], None, [0, 0])
|
|
1822
|
+
self.assertEqualExpr(x == y + z, [y, z, x], [1, 1, -1], None, [0, 0])
|
|
1823
|
+
self.assertEqualExpr(x + y == 2 * x + 2 * y + z, [x, y, z, x, y], [2, 2, 1, -1, -1], None, [0, 0])
|
|
1824
|
+
|
|
1825
|
+
# prefer constant
|
|
1826
|
+
self.assertEqualExpr(y <= x + 2, [y, x], [1, -1], None, [-self.h.inf, 2])
|
|
1827
|
+
self.assertEqualExpr(x + 2 >= y, [y, x], [1, -1], None, [-self.h.inf, 2])
|
|
1828
|
+
self.assertEqualExpr(x + 2 <= y, [y, x], [1, -1], None, [2, self.h.inf])
|
|
1829
|
+
self.assertEqualExpr(y >= x + 2, [y, x], [1, -1], None, [2, self.h.inf])
|
|
1830
|
+
self.assertEqualExpr(y + 2 == x, [x, y], [1, -1], None, [2, 2])
|
|
1831
|
+
self.assertEqualExpr(x == y + 2, [x, y], [1, -1], None, [2, 2])
|
|
1832
|
+
|
|
1833
|
+
# prefer 'left'
|
|
1834
|
+
self.assertEqualExpr(x + 2 <= y + 3, [x, y], [1, -1], None, [-self.h.inf, 1])
|
|
1835
|
+
self.assertEqualExpr(y + 3 >= x + 2, [x, y], [1, -1], None, [-self.h.inf, 1])
|
|
1836
|
+
self.assertEqualExpr(x + 2 >= y + 3, [y, x], [1, -1], None, [-self.h.inf, -1])
|
|
1837
|
+
self.assertEqualExpr(y + 3 <= x + 2, [y, x], [1, -1], None, [-self.h.inf, -1])
|
|
1838
|
+
self.assertEqualExpr(x + 2 == y + 3, [x, y], [1, -1], None, [1, 1])
|
|
1839
|
+
self.assertEqualExpr(y + 3 == x + 2, [y, x], [1, -1], None, [-1, -1])
|
|
1840
|
+
|
|
1841
|
+
self.assertEqualExpr(6 <= x + y <= 8, [x, y], [1, 1], None, [6, 8])
|
|
1842
|
+
self.assertEqualExpr(6 + x <= y <= 8 + x, [y, x], [1, -1], None, [6, 8])
|
|
1843
|
+
self.assertEqualExpr(6 + x <= y + 2 <= 8 + x, [y, x], [1, -1], None, [4, 6])
|
|
1844
|
+
self.assertEqualExpr(x <= 6 <= x, [x], [1], None, [6, 6])
|
|
1845
|
+
self.assertEqualExpr(x <= y + z <= x + 5, [y, z, x], [1, 1, -1], None, [0, 5])
|
|
1846
|
+
|
|
1847
|
+
def test_chain_inequality_hacks(self):
|
|
1848
|
+
x, y = self.x[0:2]
|
|
1849
|
+
|
|
1850
|
+
# Test hacks around chain inequality
|
|
1851
|
+
# These don't need to be supported, good to check if logic changes
|
|
1852
|
+
t = x + y
|
|
1853
|
+
self.assertEqualExpr(t, [x, y], [1, 1])
|
|
1854
|
+
|
|
1855
|
+
bool(t <= 10)
|
|
1856
|
+
expr = 5 <= t
|
|
1857
|
+
self.assertEqualExpr(expr, [x, y], [1, 1], None, [5, 10])
|
|
1858
|
+
expr = 5 <= t
|
|
1859
|
+
self.assertEqualExpr(expr, [x, y], [1, 1], None, [5, self.h.inf])
|
|
1860
|
+
|
|
1861
|
+
bool(t <= 10)
|
|
1862
|
+
expr = t <= 18
|
|
1863
|
+
self.assertEqualExpr(expr, [x, y], [1, 1], None, [-self.h.inf, 18])
|
|
1864
|
+
|
|
1865
|
+
bool(t <= 10)
|
|
1866
|
+
expr = t >= 5
|
|
1867
|
+
self.assertEqualExpr(expr, [x, y], [1, 1], None, [5, 10])
|
|
1868
|
+
expr = t >= 5
|
|
1869
|
+
self.assertEqualExpr(expr, [x, y], [1, 1], None, [5, self.h.inf])
|
|
1870
|
+
|
|
1871
|
+
expr = bool(t <= 10) and t >= 5
|
|
1872
|
+
self.assertEqualExpr(expr, [x, y], [1, 1], None, [5, 10])
|
|
1873
|
+
|
|
1874
|
+
# test hack if expression is modified
|
|
1875
|
+
bool(t <= 10)
|
|
1876
|
+
t += y
|
|
1877
|
+
expr = 5 <= t
|
|
1878
|
+
self.assertEqualExpr(expr, [x, y, y], [1, 1, 1], None, [5, self.h.inf])
|
|
1879
|
+
|
|
1880
|
+
# test hack if using 'equal' temporary expr
|
|
1881
|
+
bool(x + y <= 10)
|
|
1882
|
+
expr = 5 <= x + y
|
|
1883
|
+
self.assertEqualExpr(expr, [x, y], [1, 1], None, [5, 10])
|
|
1884
|
+
expr = 5 <= x + y
|
|
1885
|
+
self.assertEqualExpr(expr, [x, y], [1, 1], None, [5, self.h.inf])
|
|
1886
|
+
|
|
1887
|
+
# test hack if using 'not-equal' temporary expr
|
|
1888
|
+
bool(x + 3 * y <= 10)
|
|
1889
|
+
expr = 5 <= x + y
|
|
1890
|
+
self.assertEqualExpr(expr, [x, y], [1, 1], None, [5, self.h.inf])
|
|
1891
|
+
|
|
1892
|
+
def test_bounds_already_set(self):
|
|
1893
|
+
x, y = self.x[0:2]
|
|
1894
|
+
self.assertRaises(Exception, lambda: (1 <= 2 * x + 3 * y) <= 5)
|
|
1895
|
+
self.assertRaises(Exception, lambda: (x <= 4) <= 5)
|
|
1896
|
+
self.assertRaises(Exception, lambda: 2 <= (x <= 4) <= 5)
|
|
1897
|
+
self.assertRaises(Exception, lambda: 2 <= (4 <= x))
|
|
1898
|
+
self.assertRaises(Exception, lambda: 2 <= (x <= 4))
|
|
1899
|
+
self.assertRaises(Exception, lambda: 4 >= (x >= 2))
|
|
1900
|
+
|
|
1901
|
+
# Cannot a constant if bounds already exist
|
|
1902
|
+
self.assertRaises(Exception, lambda: (x + y <= 3) + 5)
|
|
1903
|
+
self.assertEqualExpr((x + y <= 3) + (self.h.expr() == 5), [x, y], [1, 1], None, [-self.h.inf, 8])
|
|
1904
|
+
|
|
1905
|
+
# Cannot a expr with constant if bounds already exist
|
|
1906
|
+
self.assertRaises(Exception, lambda: (x + y <= 3) + (x + 5))
|
|
1907
|
+
self.assertEqualExpr((x + y <= 3) + (x == -5), [x, y, x], [1, 1, 1], None, [-self.h.inf, -2])
|
|
1908
|
+
|
|
1909
|
+
def test_addition(self):
|
|
1910
|
+
x, y = self.x[0:2]
|
|
1911
|
+
|
|
1912
|
+
# Test addition of two variables
|
|
1913
|
+
expr = x + y
|
|
1914
|
+
self.assertEqualExpr(expr, [x, y], [1, 1])
|
|
1915
|
+
|
|
1916
|
+
# Test addition of two exprs (with bounds)
|
|
1917
|
+
e1 = 2 <= x - y <= 4
|
|
1918
|
+
e2 = 2 <= 2 * x - y <= 4
|
|
1919
|
+
self.assertEqualExpr(e1, [x, y], [1, -1], None, [2, 4])
|
|
1920
|
+
self.assertEqualExpr(e2, [x, y], [2, -1], None, [2, 4])
|
|
1921
|
+
|
|
1922
|
+
expr = e1 + e2
|
|
1923
|
+
self.assertEqualExpr(expr, [x, y, x, y], [1, -1, 2, -1], None, [4, 8])
|
|
1924
|
+
|
|
1925
|
+
expr = (e1 + e2).simplify()
|
|
1926
|
+
self.assertEqualExpr(expr, [x, y], [3, -2], None, [4, 8])
|
|
1927
|
+
|
|
1928
|
+
# Test multiplication/addition of two exprs (with bounds)
|
|
1929
|
+
expr = (2 * e1 + 3 * e2).simplify()
|
|
1930
|
+
self.assertEqualExpr(expr, [x, y], [8, -5], None, [10, 20])
|
|
1931
|
+
|
|
1932
|
+
def test_subtraction(self):
|
|
1933
|
+
x, y = self.x[0:2]
|
|
1934
|
+
|
|
1935
|
+
# Test subtraction of two highs_linear_expressions
|
|
1936
|
+
expr = x - y
|
|
1937
|
+
self.assertEqualExpr(expr, [x, y], [1, -1])
|
|
1938
|
+
|
|
1939
|
+
# Test subtraction of two exprs (with bounds)
|
|
1940
|
+
e1 = 2 <= x - y <= 4
|
|
1941
|
+
e2 = 2 <= 2 * x - y <= 4
|
|
1942
|
+
self.assertEqualExpr(e1, [x, y], [1, -1], None, [2, 4])
|
|
1943
|
+
self.assertEqualExpr(e2, [x, y], [2, -1], None, [2, 4])
|
|
1944
|
+
|
|
1945
|
+
expr = e1 + (-1.0 * e2)
|
|
1946
|
+
self.assertEqualExpr(expr, [x, y, x, y], [1, -1, -2, 1], None, [-2, 2])
|
|
1947
|
+
|
|
1948
|
+
expr = e1 + (-e2)
|
|
1949
|
+
self.assertEqualExpr(expr, [x, y, x, y], [1, -1, -2, 1], None, [-2, 2])
|
|
1950
|
+
|
|
1951
|
+
expr = e1 - e2
|
|
1952
|
+
self.assertEqualExpr(expr, [x, y, x, y], [1, -1, -2, 1], None, [-2, 2])
|
|
1953
|
+
|
|
1954
|
+
expr = (e1 - e2).simplify()
|
|
1955
|
+
self.assertEqualExpr(expr, [x, y], [-1, 0], None, [-2, 2])
|
|
1956
|
+
|
|
1957
|
+
# Test multiplication/subtraction of two exprs (with bounds)
|
|
1958
|
+
expr = (2 * e1 - e2).simplify()
|
|
1959
|
+
self.assertEqualExpr(expr, [x, y], [0, -1], None, [0, 6])
|
|
1960
|
+
|
|
1961
|
+
# test rsub
|
|
1962
|
+
expr = 5 - (x + y)
|
|
1963
|
+
self.assertEqualExpr(expr, [x, y], [-1, -1], 5)
|
|
1964
|
+
|
|
1965
|
+
def test_multiply(self):
|
|
1966
|
+
x, y = self.x[0:2]
|
|
1967
|
+
|
|
1968
|
+
# basic tests
|
|
1969
|
+
e1 = x * 3
|
|
1970
|
+
self.assertEqualExpr(e1, [x], [3])
|
|
1971
|
+
e1 = 3 * x
|
|
1972
|
+
self.assertEqualExpr(e1, [x], [3])
|
|
1973
|
+
|
|
1974
|
+
e1 = x - y
|
|
1975
|
+
self.assertEqualExpr(e1, [x, y], [1, -1])
|
|
1976
|
+
|
|
1977
|
+
e2 = 2 * e1
|
|
1978
|
+
self.assertEqualExpr(e2, [x, y], [2, -2])
|
|
1979
|
+
|
|
1980
|
+
e1 *= 3
|
|
1981
|
+
self.assertEqualExpr(e1, [x, y], [3, -3])
|
|
1982
|
+
|
|
1983
|
+
e2 = -1 * e1
|
|
1984
|
+
self.assertEqualExpr(e2, [x, y], [-3, 3])
|
|
1985
|
+
|
|
1986
|
+
e2 = 0 * e1
|
|
1987
|
+
self.assertEqualExpr(e2, [x, y], [0, 0])
|
|
1988
|
+
|
|
1989
|
+
e2 = highs_linear_expression(-1) * e1
|
|
1990
|
+
self.assertEqualExpr(e2, [x, y], [-3, 3])
|
|
1991
|
+
|
|
1992
|
+
self.assertRaises(Exception, lambda: e1 * x)
|
|
1993
|
+
self.assertRaises(Exception, lambda: e1 * highs_linear_expression(x))
|
|
1994
|
+
self.assertRaises(Exception, lambda: e1 * highs_linear_expression(x - x))
|
|
1995
|
+
|
|
1996
|
+
# Test with constant
|
|
1997
|
+
e1 = x - y + 4
|
|
1998
|
+
self.assertEqualExpr(e1, [x, y], [1, -1], 4)
|
|
1999
|
+
|
|
2000
|
+
e2 = e1 * 2.5
|
|
2001
|
+
self.assertEqualExpr(e2, [x, y], [2.5, -2.5], 10)
|
|
2002
|
+
|
|
2003
|
+
e1 *= 2.5
|
|
2004
|
+
self.assertEqualExpr(e1, [x, y], [2.5, -2.5], 10)
|
|
2005
|
+
|
|
2006
|
+
e2 = -1.0 * e1
|
|
2007
|
+
self.assertEqualExpr(e2, [x, y], [-2.5, 2.5], -10)
|
|
2008
|
+
|
|
2009
|
+
e1 *= -1.0
|
|
2010
|
+
self.assertEqualExpr(e1, [x, y], [-2.5, 2.5], -10)
|
|
2011
|
+
|
|
2012
|
+
e1 *= highs_linear_expression(-1.0)
|
|
2013
|
+
self.assertEqualExpr(e1, [x, y], [2.5, -2.5], 10)
|
|
2014
|
+
|
|
2015
|
+
# Test with bounds
|
|
2016
|
+
e1 = x - 2 * y == [1, 4]
|
|
2017
|
+
self.assertEqualExpr(e1, [x, y], [1, -2], None, [1, 4])
|
|
2018
|
+
|
|
2019
|
+
e2 = e1 * 2.5
|
|
2020
|
+
self.assertEqualExpr(e2, [x, y], [2.5, -5], None, [2.5, 10])
|
|
2021
|
+
|
|
2022
|
+
e1 *= 2.5
|
|
2023
|
+
self.assertEqualExpr(e1, [x, y], [2.5, -5], None, [2.5, 10])
|
|
2024
|
+
|
|
2025
|
+
e2 = -1.0 * e1
|
|
2026
|
+
self.assertEqualExpr(e2, [x, y], [-2.5, 5], None, [-10, -2.5])
|
|
2027
|
+
|
|
2028
|
+
e1 *= -1.0
|
|
2029
|
+
self.assertEqualExpr(e1, [x, y], [-2.5, 5], None, [-10, -2.5])
|
|
2030
|
+
|
|
2031
|
+
e1 *= highs_linear_expression(-1.0)
|
|
2032
|
+
self.assertEqualExpr(e1, [x, y], [2.5, -5], None, [2.5, 10])
|
|
2033
|
+
|
|
2034
|
+
e1 = highs_linear_expression(-1.0)
|
|
2035
|
+
e1 *= x + 4
|
|
2036
|
+
self.assertEqualExpr(e1, [x], [-1], -4)
|
|
2037
|
+
|
|
2038
|
+
e1 = highs_linear_expression(-1.0)
|
|
2039
|
+
e1 *= x - 4 <= 3
|
|
2040
|
+
self.assertEqualExpr(e1, [x], [-1], None, [-7, self.h.inf])
|
|
2041
|
+
|
|
2042
|
+
e1 = highs_linear_expression(1.0)
|
|
2043
|
+
e1 *= x - 4 <= 3
|
|
2044
|
+
self.assertEqualExpr(e1, [x], [1], None, [-self.h.inf, 7])
|
|
2045
|
+
|
|
2046
|
+
def test_simplify(self):
|
|
2047
|
+
x, y, z = self.x[0:3]
|
|
2048
|
+
|
|
2049
|
+
# basics
|
|
2050
|
+
expr = x + y + z
|
|
2051
|
+
self.assertEqualExpr(expr, [x, y, z], [1, 1, 1])
|
|
2052
|
+
expr = expr.simplify()
|
|
2053
|
+
self.assertEqualExpr(expr, [x, y, z], [1, 1, 1])
|
|
2054
|
+
|
|
2055
|
+
expr = z + x + y # simplify reorders variables
|
|
2056
|
+
self.assertEqualExpr(expr, [z, x, y], [1, 1, 1])
|
|
2057
|
+
expr = expr.simplify()
|
|
2058
|
+
self.assertEqualExpr(expr, [x, y, z], [1, 1, 1])
|
|
2059
|
+
|
|
2060
|
+
expr = x + x + x + x + x
|
|
2061
|
+
self.assertEqualExpr(expr, [x] * 5, [1] * 5)
|
|
2062
|
+
expr = expr.simplify()
|
|
2063
|
+
self.assertEqualExpr(expr, [x], [5])
|
|
2064
|
+
|
|
2065
|
+
expr = x - x + x - x + x
|
|
2066
|
+
self.assertEqualExpr(expr, [x] * 5, [1, -1, 1, -1, 1])
|
|
2067
|
+
expr = expr.simplify()
|
|
2068
|
+
self.assertEqualExpr(expr, [x], [1])
|
|
2069
|
+
|
|
2070
|
+
expr = -x
|
|
2071
|
+
expr += x
|
|
2072
|
+
expr *= -5
|
|
2073
|
+
self.assertEqualExpr(expr, [x, x], [5, -5])
|
|
2074
|
+
expr = expr.simplify()
|
|
2075
|
+
self.assertEqualExpr(expr, [x], [0])
|
|
2076
|
+
|
|
2077
|
+
# with constant
|
|
2078
|
+
expr = x + y + 1 + y
|
|
2079
|
+
self.assertEqualExpr(expr, [x, y, y], [1, 1, 1], 1)
|
|
2080
|
+
expr = expr.simplify()
|
|
2081
|
+
self.assertEqualExpr(expr, [x, y], [1, 2], 1)
|
|
2082
|
+
|
|
2083
|
+
# with bounds
|
|
2084
|
+
expr = 0 <= x + y + 1 + y <= 5
|
|
2085
|
+
self.assertEqualExpr(expr, [x, y, y], [1, 1, 1], None, [-1, 4])
|
|
2086
|
+
expr = expr.simplify()
|
|
2087
|
+
self.assertEqualExpr(expr, [x, y], [1, 2], None, [-1, 4])
|
|
2088
|
+
|
|
2089
|
+
def test_evaluate(self):
|
|
2090
|
+
h = self.h
|
|
2091
|
+
x, y = h.addVariables(2, lb=-h.inf)
|
|
2092
|
+
|
|
2093
|
+
h.addConstrs(-x + y >= 2, x + y >= 0)
|
|
2094
|
+
h.minimize(y)
|
|
2095
|
+
|
|
2096
|
+
self.assertAlmostEqual(h.val(x), -1)
|
|
2097
|
+
self.assertAlmostEqual(h.val(y), 1)
|
|
2098
|
+
self.assertAlmostEqual(h.val(x + y), 0)
|
|
2099
|
+
self.assertAlmostEqual(h.val(y - x), 2)
|
|
2100
|
+
self.assertEqual(h.val(y - x >= 2), True)
|
|
2101
|
+
self.assertEqual(h.val(y - x <= 1), False)
|
|
2102
|
+
|
|
2103
|
+
def test_repr_str(self):
|
|
2104
|
+
x, y = self.x[0:2]
|
|
2105
|
+
self.assertEqual(repr(x), "highs_var(0)")
|
|
2106
|
+
self.assertEqual(str(x), "highs_var(0)")
|
|
2107
|
+
|
|
2108
|
+
c = self.h.addConstr(x + y <= 5)
|
|
2109
|
+
self.assertEqual(repr(c), "highs_cons(0)")
|
|
2110
|
+
self.assertEqual(str(c), "highs_cons(0)")
|
|
2111
|
+
|
|
2112
|
+
expr = c.expr()
|
|
2113
|
+
self.assertEqual(repr(expr), "-inf <= 1.0_v0 1.0_v1 <= 5.0")
|
|
2114
|
+
self.assertEqual(str(expr), "-inf <= 1.0_v0 1.0_v1 <= 5.0")
|
|
2115
|
+
|
|
2116
|
+
expr = x + y
|
|
2117
|
+
self.assertEqual(repr(expr), "1.0_v0 1.0_v1")
|
|
2118
|
+
self.assertEqual(str(expr), "1.0_v0 1.0_v1")
|
|
2119
|
+
|
|
2120
|
+
expr = x + y + x + x + y
|
|
2121
|
+
self.assertEqual(repr(expr), "1.0_v0 1.0_v1 1.0_v0 1.0_v0 1.0_v1")
|
|
2122
|
+
self.assertEqual(str(expr), "3.0_v0 2.0_v1")
|
|
2123
|
+
|
|
2124
|
+
expr = y + x + 5
|
|
2125
|
+
self.assertEqual(repr(expr), "1.0_v1 1.0_v0 5.0")
|
|
2126
|
+
self.assertEqual(str(expr), "1.0_v0 1.0_v1 5.0")
|
|
2127
|
+
|
|
2128
|
+
expr = y + x == 5
|
|
2129
|
+
self.assertEqual(repr(expr), "1.0_v1 1.0_v0 == 5.0")
|
|
2130
|
+
self.assertEqual(str(expr), "1.0_v0 1.0_v1 == 5.0")
|
|
2131
|
+
|
|
2132
|
+
expr = y + x <= 5
|
|
2133
|
+
self.assertEqual(repr(expr), "-inf <= 1.0_v1 1.0_v0 <= 5.0")
|
|
2134
|
+
self.assertEqual(str(expr), "-inf <= 1.0_v0 1.0_v1 <= 5.0")
|
|
2135
|
+
|
|
2136
|
+
def test_lexicographic_optimization(self):
|
|
2137
|
+
# max f1 = X1
|
|
2138
|
+
# max f2 = 3 X1 + 4 X2
|
|
2139
|
+
# st X1 <= 2
|
|
2140
|
+
# X2 <= 4
|
|
2141
|
+
# 5 X1 + 4 X2 <= 20
|
|
2142
|
+
model = highspy.Highs()
|
|
2143
|
+
model.setOptionValue("blend_multi_objectives", False)
|
|
2144
|
+
num_vars = 2
|
|
2145
|
+
model.addVars(num_vars, np.array([0.0, 0.0]), np.array([2.0, 4.0]))
|
|
2146
|
+
obj1 = highspy.HighsLinearObjective()
|
|
2147
|
+
obj1.offset = 0
|
|
2148
|
+
obj1.coefficients = [1, 0]
|
|
2149
|
+
obj1.priority = 2
|
|
2150
|
+
obj1.rel_tolerance = 0.1
|
|
2151
|
+
obj1.abs_tolerance = 0.2
|
|
2152
|
+
obj2 = highspy.HighsLinearObjective()
|
|
2153
|
+
obj2.offset=0
|
|
2154
|
+
obj2.coefficients=[3, 4]
|
|
2155
|
+
obj2.priority=1
|
|
2156
|
+
model.addLinearObjective(obj1)
|
|
2157
|
+
model.addLinearObjective(obj2)
|
|
2158
|
+
model.addRow(0.0, 20.0, num_vars, np.arange(num_vars), np.array([5.0, 4.0]))
|
|
2159
|
+
model.run()
|
|
2160
|
+
|
|
2161
|
+
status = model.getModelStatus()
|
|
2162
|
+
self.assertEqual(status, highspy.HighsModelStatus.kOptimal)
|
|
2163
|
+
|
|
2164
|
+
def test_get_fixed_lp(self):
|
|
2165
|
+
# Min f = -3x_0 - 2x_1 - x_2
|
|
2166
|
+
# s.t. x_0 + x_1 + x_2 <= 7
|
|
2167
|
+
# 4x_0 + 2x_1 + x_2 = 12
|
|
2168
|
+
# x_0 >=0; x_1 >= 0; x_2 binary
|
|
2169
|
+
inf = highspy.kHighsInf
|
|
2170
|
+
model = highspy.Highs()
|
|
2171
|
+
num_vars = 3
|
|
2172
|
+
model.addVars(num_vars, np.array([0.0, 0.0, 0.0]), np.array([2.0, 4.0, inf]))
|
|
2173
|
+
num_cons = 2
|
|
2174
|
+
lower = np.array([-inf, 12], dtype=np.double)
|
|
2175
|
+
upper = np.array([7, 12], dtype=np.double)
|
|
2176
|
+
num_new_nz = 6
|
|
2177
|
+
starts = np.array([0, 2, 4])
|
|
2178
|
+
indices = np.array([0, 1, 0, 1, 0, 1])
|
|
2179
|
+
values = np.array([1, 4, 1, 2, 1, 1], dtype=np.double)
|
|
2180
|
+
model.addRows(num_cons, lower, upper, num_new_nz, starts, indices, values)
|
|
2181
|
+
model.changeColsIntegrality(1, np.array([2]), np.array([highspy.HighsVarType.kInteger]))
|
|
2182
|
+
model.setOptionValue("presolve", "off")
|
|
2183
|
+
model.run()
|
|
2184
|
+
mip_objective_function_value = model.getInfo().objective_function_value
|
|
2185
|
+
solution = model.getSolution()
|
|
2186
|
+
[status, fixed_lp] = model.getFixedLp()
|
|
2187
|
+
self.assertEqual(status, highspy.HighsStatus.kOk)
|
|
2188
|
+
model.passModel(fixed_lp)
|
|
2189
|
+
model.setSolution(solution)
|
|
2190
|
+
model.run()
|
|
2191
|
+
self.assertEqual(model.getInfo().objective_function_value, mip_objective_function_value)
|
|
2192
|
+
self.assertEqual(model.getInfo().simplex_iteration_count, 0)
|
|
2193
|
+
|
|
2194
|
+
def test_get_objectives(self):
|
|
2195
|
+
# Build a simple model with 3 vars and a primary (single) objective
|
|
2196
|
+
h = highspy.Highs()
|
|
2197
|
+
h.silent()
|
|
2198
|
+
|
|
2199
|
+
x, y, z, _ = h.addVariables(4, lb=0, ub=10)
|
|
2200
|
+
h.maximize(x + 2 * y + 3 * z + 5)
|
|
2201
|
+
|
|
2202
|
+
# Test getObjective (primary objective)
|
|
2203
|
+
obj_expr, sense = h.getObjective()
|
|
2204
|
+
self.assertEqual(list(map(int, obj_expr.idxs)), [0, 1, 2])
|
|
2205
|
+
self.assertEqual(obj_expr.vals, [1.0, 2.0, 3.0])
|
|
2206
|
+
self.assertEqual(obj_expr.constant, 5.0)
|
|
2207
|
+
self.assertEqual(sense, highspy.ObjSense.kMaximize)
|
|
2208
|
+
|
|
2209
|
+
# No multi-objectives yet
|
|
2210
|
+
self.assertEqual(h.getNumLinearObjectives(), 0)
|
|
2211
|
+
|
|
2212
|
+
# Add two linear objectives (multi-objective data structure)
|
|
2213
|
+
o1 = highspy.HighsLinearObjective()
|
|
2214
|
+
o1.offset = 10.0
|
|
2215
|
+
o1.coefficients = [1.0, 0.0, 0.0, 0.0]
|
|
2216
|
+
o1.priority = 5
|
|
2217
|
+
o1.abs_tolerance = 0.01
|
|
2218
|
+
o1.rel_tolerance = 0.02
|
|
2219
|
+
|
|
2220
|
+
o2 = highspy.HighsLinearObjective()
|
|
2221
|
+
o2.offset = -3.5
|
|
2222
|
+
o2.coefficients = [0.0, 1.0, 1.0, 0.0]
|
|
2223
|
+
o2.priority = 3
|
|
2224
|
+
o2.abs_tolerance = 0.0
|
|
2225
|
+
o2.rel_tolerance = 0.0
|
|
2226
|
+
|
|
2227
|
+
self.assertEqual(h.addLinearObjective(o1), highspy.HighsStatus.kOk)
|
|
2228
|
+
self.assertEqual(h.addLinearObjective(o2), highspy.HighsStatus.kOk)
|
|
2229
|
+
|
|
2230
|
+
# Verify count
|
|
2231
|
+
self.assertEqual(h.getNumLinearObjectives(), 2)
|
|
2232
|
+
|
|
2233
|
+
# Retrieve and verify first added linear objective
|
|
2234
|
+
lo0 = h.getLinearObjective(0)
|
|
2235
|
+
self.assertAlmostEqual(lo0.offset, o1.offset)
|
|
2236
|
+
self.assertEqual(list(lo0.coefficients), o1.coefficients)
|
|
2237
|
+
self.assertEqual(lo0.priority, o1.priority)
|
|
2238
|
+
self.assertAlmostEqual(lo0.abs_tolerance, o1.abs_tolerance)
|
|
2239
|
+
self.assertAlmostEqual(lo0.rel_tolerance, o1.rel_tolerance)
|
|
2240
|
+
|
|
2241
|
+
# Retrieve and verify second added linear objective
|
|
2242
|
+
lo1 = h.getLinearObjective(1)
|
|
2243
|
+
self.assertAlmostEqual(lo1.offset, o2.offset)
|
|
2244
|
+
self.assertEqual(list(lo1.coefficients), o2.coefficients)
|
|
2245
|
+
self.assertEqual(lo1.priority, o2.priority)
|
|
2246
|
+
self.assertAlmostEqual(lo1.abs_tolerance, o2.abs_tolerance)
|
|
2247
|
+
self.assertAlmostEqual(lo1.rel_tolerance, o2.rel_tolerance)
|
|
2248
|
+
|
|
2249
|
+
# Ensure original objective remains unchanged
|
|
2250
|
+
obj_expr2, sense2 = h.getObjective()
|
|
2251
|
+
self.assertEqual(list(map(int, obj_expr2.idxs)), [0, 1, 2])
|
|
2252
|
+
self.assertEqual(obj_expr2.vals, [1.0, 2.0, 3.0])
|
|
2253
|
+
self.assertEqual(obj_expr2.constant, 5.0)
|
|
2254
|
+
self.assertEqual(sense2, highspy.ObjSense.kMaximize)
|
|
2255
|
+
|
|
2256
|
+
def test_get_iis(self):
|
|
2257
|
+
h = highspy.Highs()
|
|
2258
|
+
# h.silent()
|
|
2259
|
+
# Build an infeasible LP problem
|
|
2260
|
+
# Problem: minimize x + y
|
|
2261
|
+
# Subject to: x + y <= 0.5 and x + y >= 2.0 (contradictory constraints)
|
|
2262
|
+
# Bounds: 0 <= x <= 1, 0 <= y <= 1
|
|
2263
|
+
|
|
2264
|
+
lp = highspy.HighsLp()
|
|
2265
|
+
lp.num_col_ = 2
|
|
2266
|
+
lp.num_row_ = 2
|
|
2267
|
+
|
|
2268
|
+
# Objective: minimize x + y
|
|
2269
|
+
lp.col_cost_ = [1.0, 1.0]
|
|
2270
|
+
|
|
2271
|
+
# Variable bounds: 0 <= x <= 1, 0 <= y <= 1
|
|
2272
|
+
lp.col_lower_ = [0.0, 0.0]
|
|
2273
|
+
lp.col_upper_ = [1.0, 1.0]
|
|
2274
|
+
|
|
2275
|
+
# Constraints:
|
|
2276
|
+
# Row 0: x + y <= 0.5
|
|
2277
|
+
# Row 1: -x - y <= -2.0 (equivalent to x + y >= 2.0)
|
|
2278
|
+
lp.row_lower_ = [-np.inf, -np.inf]
|
|
2279
|
+
lp.row_upper_ = [0.5, -2.0]
|
|
2280
|
+
|
|
2281
|
+
# Constraint matrix (CSC format)
|
|
2282
|
+
lp.a_matrix_.start_ = [0, 2, 4]
|
|
2283
|
+
lp.a_matrix_.index_ = [0, 1, 0, 1] # Row indices
|
|
2284
|
+
lp.a_matrix_.value_ = [1.0, 1.0, -1.0, -1.0] # Coefficients
|
|
2285
|
+
|
|
2286
|
+
# Pass model to HiGHS
|
|
2287
|
+
h.passModel(lp)
|
|
2288
|
+
|
|
2289
|
+
# Solve the problem
|
|
2290
|
+
h.run()
|
|
2291
|
+
|
|
2292
|
+
model_status = h.getModelStatus()
|
|
2293
|
+
self.assertEqual(model_status, highspy.HighsModelStatus.kInfeasible)
|
|
2294
|
+
|
|
2295
|
+
h.setOptionValue("iis_strategy", highspy.IisStrategy.kIisStrategyIrreducible)
|
|
2296
|
+
[status, iis] = h.getIis()
|
|
2297
|
+
|
|
2298
|
+
self.assertEqual(iis.valid_, True)
|
|
2299
|
+
self.assertEqual(iis.col_index_[0], 0)
|
|
2300
|
+
self.assertEqual(iis.col_index_[1], 1)
|
|
2301
|
+
self.assertEqual(iis.row_index_[0], 1)
|
|
2302
|
+
|
|
2303
|
+
self.assertEqual(iis.col_bound_[0], highspy.IisBoundStatus.kIisBoundStatusLower)
|
|
2304
|
+
self.assertEqual(iis.col_bound_[1], highspy.IisBoundStatus.kIisBoundStatusUpper)
|
|
2305
|
+
self.assertEqual(iis.row_bound_[0], highspy.IisBoundStatus.kIisBoundStatusUpper)
|
|
2306
|
+
|
|
2307
|
+
self.assertEqual(iis.col_status_[0], highspy.IisStatus.kIisStatusInConflict)
|
|
2308
|
+
self.assertEqual(iis.col_status_[1], highspy.IisStatus.kIisStatusInConflict)
|
|
2309
|
+
self.assertEqual(iis.row_status_[0], highspy.IisStatus.kIisStatusNotInConflict)
|
|
2310
|
+
self.assertEqual(iis.row_status_[1], highspy.IisStatus.kIisStatusInConflict)
|