diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 43bd428..4c18c8b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,10 +24,10 @@ jobs: - name: Set up python virtual environment with NVIDIA dependencies run: | mkdir -p venvs - python -m venv venvs/cu-opt - bash -c "source venvs/cu-opt/bin/activate && \ + python -m venv venvs/cu12 + bash -c "source venvs/cu12/bin/activate && \ pip install --upgrade pip -qq && \ - pip install --extra-index-url=https://pypi.anaconda.org/rapidsai-wheels-nightly/simple/ cuopt-cu12==25.10.0a47 nvidia-cuda-runtime-cu12==12.8.* nvidia-nvjitlink-cu12 -qq" + pip install --extra-index-url=https://pypi.anaconda.org/rapidsai-wheels-nightly/simple/ cuopt-cu12==25.10.0 nvidia-cuda-runtime-cu12==12.8.* nvidia-nvjitlink-cu12 -qq" - name: Download and extract latest GAMS distribution run: | @@ -39,9 +39,12 @@ jobs: - name: Compile gmscuopt run: | export GAMSCAPI="gamsdist/apifiles/C/api" - export CUOPT="venvs/cu-opt/lib/python3.12/site-packages/libcuopt" - export JITLINK="venvs/cu-opt/lib/python3.12/site-packages/nvidia/nvjitlink/lib" + export CUOPT="venvs/cu12/lib/python3.12/site-packages/libcuopt" + export JITLINK="venvs/cu12/lib/python3.12/site-packages/nvidia/nvjitlink/lib" + export CUOPT_VERSION="`cat "$CUOPT/VERSION"`" + export CUOPT_HASH="`cat "$CUOPT/GIT_COMMIT"`" gcc -Wall gmscuopt.c -o gmscuopt.out \ + -DCUOPT_VERSION=\"$CUOPT_VERSION\" -DCUOPT_HASH=\"$CUOPT_HASH\" \ -I $GAMSCAPI $GAMSCAPI/gmomcc.c $GAMSCAPI/optcc.c $GAMSCAPI/gevmcc.c \ -I $CUOPT/include $JITLINK/libnvJitLink.so.12 -L $CUOPT/lib64 -lcuopt patchelf --set-rpath \$ORIGIN gmscuopt.out @@ -51,11 +54,19 @@ jobs: mkdir release cp gmscuopt.out release/ cp assets/* release/ - cp venvs/cu-opt/lib/python3.12/site-packages/libcuopt/lib64/libcuopt.so release/ - cp venvs/cu-opt/lib/python3.12/site-packages/libcuopt/lib64/libmps_parser.so release/ - cp venvs/cu-opt/lib/python3.12/site-packages/libcuopt_cu12.libs/libgomp-5fc1ad8c.so.1.0.0 release/ - cp venvs/cu-opt/lib/python3.12/site-packages/rapids_logger/lib64/librapids_logger.so release/ - cp venvs/cu-opt/lib/python3.12/site-packages/librmm/lib64/librmm.so release/ + cp venvs/cu12/lib/python3.12/site-packages/libcuopt/lib64/libcuopt.so release/ + cp venvs/cu12/lib/python3.12/site-packages/libcuopt/lib64/libmps_parser.so release/ + cp venvs/cu12/lib/python3.12/site-packages/libcuopt_cu12.libs/libgomp-*.so.1.0.0 release/ + cp venvs/cu12/lib/python3.12/site-packages/rapids_logger/lib64/librapids_logger.so release/ + cp venvs/cu12/lib/python3.12/site-packages/librmm/lib64/librmm.so release/ + cp venvs/cu12/lib/python3.12/site-packages/nvidia/cu12/lib/libcudss.so.0 release/ + cp venvs/cu12/lib/python3.12/site-packages/libcuopt_cu12.libs/libtbb-*.so.2 release/ + cp venvs/cu12/lib/python3.12/site-packages/libcuopt_cu12.libs/libtbbmalloc-*.so.2 release/ + cp venvs/cu12/lib/python3.12/site-packages/nvidia/cusolver/lib/libcusolver.so.11 release/ + cp venvs/cu12/lib/python3.12/site-packages/nvidia/cublas/lib/libcublas.so.12 release/ + cp venvs/cu12/lib/python3.12/site-packages/nvidia/cublas/lib/libcublasLt.so.12 release/ + cp venvs/cu12/lib/python3.12/site-packages/nvidia/nvjitlink/lib/libnvJitLink.so.12 release/ + cp venvs/cu12/lib/python3.12/site-packages/nvidia/curand/lib/libcurand.so.10 release/ - name: Upload artifact to GitHub Actions (always) uses: actions/upload-artifact@v4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6dadc6d --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/venv/* +/release/* +trnsport.gms +trnsport.lst +gmscuopt.out +cuopt.opt \ No newline at end of file diff --git a/assets/optcuopt.def b/assets/optcuopt.def index 5ebae18..25c15dd 100644 --- a/assets/optcuopt.def +++ b/assets/optcuopt.def @@ -1,7 +1,8 @@ * * optcuopt.def * -presolve boolean 0 0 1 1 Controls whether presolve is enabled. Presolve can reduce problem size and improve solve time. Enabled by default for MIP, disabled by default for LP. +solution_file string 1 "" 1 1 Controls the name of a file where cuOpt should write the solution +user_problem_file string 1 "" 1 1 Controls the name of a file where cuOpt should write the user problem num_cpu_threads integer 0 -1 -1 maxint 1 1 Controls the number of CPU threads used in the LP and MIP solvers (default GAMS Threads) time_limit integer 0 maxint 0 maxint 1 1 Controls the time limit in seconds after which the solver will stop and return the current solution (default GAMS ResLim) prob_read string 1 "" 1 1 Reads a problem from an MPS file @@ -10,10 +11,12 @@ pdlp_solver_mode enumint 0 1 1 2 Controls the mode under which PDLP should opera 1 1 stable2 2 1 methodical1 3 1 fast1 + 4 1 stable3 method enumint 0 0 1 2 Controls the method to solve the linear programming problem 0 1 concurrent 1 1 pdlp 2 1 dual_simplex + 3 1 method_barrier iteration_limit integer 0 maxint 0 maxint 1 2 Controls the iteration limit after which the solver will stop and return the current solution (default GAMS IterLim) absolute_dual_tolerance double 0 0.0001 0 maxdouble 1 2 Controls the absolute dual tolerance used in PDLP's dual feasibility check relative_dual_tolerance double 0 0.0001 0 maxdouble 1 2 Controls the relative dual tolerance used in PDLP's dual feasibility check @@ -29,6 +32,30 @@ per_constraint_residual boolean 0 0 1 2 Controls whether PDLP should compute the save_best_primal_so_far boolean 0 0 1 2 Controls whether PDLP should save the best primal solution so far first_primal_feasible boolean 0 0 1 2 Controls whether PDLP should stop when the first primal feasible solution is found crossover boolean 0 0 1 2 Controls whether PDLP should crossover to a basic solution after an optimal solution is found +folding enumint -1 1 1 2 Controls whether to fold the linear program. Folding can reduce problem size by exploiting symmetry in the problem + -1 1 automatic (default) cuOpt decides whether to fold based on problem characteristics + 0 1 disable folding + 1 1 force folding to run +augmented enumint -1 1 1 2 Controls which linear system to solve in the barrier method + -1 1 automatic (default) cuOpt selects the best linear system to solve + 0 1 solve the ADAT system (normal equations) + 1 1 solve the augmented system +dualize enumint -1 1 1 2 Controls whether to dualize the linear program in presolve. Dualizing can improve solve time for problems, with inequality constraints, where there are more constraints than variables. + -1 1 automatic (default) cuOpt decides whether to dualize based on problem characteristics + 0 1 don't attempt to dualize + 1 1 force dualize +ordering enumint -1 1 1 2 Controls the ordering algorithm used by cuDSS for sparse factorizations. The ordering can significantly impact solver run time + -1 1 automatic (default) cuOpt selects the best ordering + 0 1 cuDSS default ordering + 1 1 AMD (approximate minimum degree) ordering +barrier_dual_initial_point enumint -1 1 1 2 Controls the method used to compute the dual initial point for the barrier solver. The choice of initial point will affect the number of iterations performed by barrier + -1 1 automatic (default) cuOpt selects the best method + 0 1 use an initial point from a heuristic approach based on the paper "On Implementing Mehrotra’s Predictor–Corrector Interior-Point Method for Linear Programming" (SIAM J. Optimization, 1992) by Lustig, Martsten, Shanno. + 1 1 use an initial point from solving a least squares problem that minimizes the norms of the dual variables and reduced costs while statisfying the dual equality constraints. +eliminate_dense_columns boolean 1 0 1 2 Controls whether to eliminate dense columns from the constraint matrix before solving. Eliminating dense columns can improve performance by reducing fill-in during factorization. However, extra solves must be performed at each iteration +cudss_deterministic boolean 0 0 1 2 Controls whether cuDSS operates in deterministic mode. Deterministic mode ensures reproducible results across runs but may be slower +presolve boolean 0 0 1 1 Controls whether presolve is enabled. Presolve can reduce problem size and improve solve time. Enabled by default for MIP, disabled by default for LP. +dual_postsolve boolean 1 0 1 2 Controls whether dual postsolve is enabled. Disabling dual postsolve can improve solve time at the expense of not having access to the dual solution. Enabled by default for LP when presolve is enabled. This is not relevant for MIP problems mip_absolute_tolerance double 0 0.0001 0 maxdouble 1 3 Controls the MIP absolute tolerance mip_relative_tolerance double 0 0.0001 0 maxdouble 1 3 Controls the MIP relative tolerance mip_integrality_tolerance double 0 1e-05 0 maxdouble 1 3 Controls the MIP integrality tolerance diff --git a/gmscuopt.c b/gmscuopt.c index 2a2480c..6cf8d2e 100644 --- a/gmscuopt.c +++ b/gmscuopt.c @@ -51,6 +51,10 @@ main (int argc, char *argv[]) goto GAMSDONE; } +#if defined(CUOPT_VERSION) && defined(CUOPT_HASH) + printOut(gev, "GAMS/cuOpt link was built against cuOpt version: %s, git hash: %s\n", CUOPT_VERSION, CUOPT_HASH); +#endif + status = gmoRegisterEnvironment(gmo, gev, msg); if (status) { printOut(gev, "Could not register GEV: %s\n", msg);