Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ GAMSDIST=/path/to/gams ./build-link.sh

`build-link.sh` compiles `gmscuopt.out` for CUDA 13, sets its RPATH (needs `gcc` and `patchelf`), and copies it together with the cuOpt and CUDA libraries and the files from `assets/` into `$GAMSDIST`. Since that includes `gamsconfig_cuopt.yaml`, merge it into `gamsconfig.yaml` as described in the [README](README.md#manual-installation). The CI workflows in `.github/workflows` build the release archives for CUDA 12 and 13 on x86_64 and arm64.

New or changed cuOpt options go into `assets/optcuopt.def` and have to be passed on to cuOpt in `gmscuopt.c`. The option table of the cuOpt page in the GAMS documentation is generated from this file with `python3 optdef2md.py`, which writes `optcuopt_s.md`.
New or changed cuOpt options go into `assets/optcuopt.def` and have to be passed on to cuOpt in `gmscuopt.c`. The option table of the cuOpt page in the GAMS documentation is generated from this file with `python3 optdef2md.py --source "GAMS-dev/cuoptlink-builder <release tag>"`, which writes `optcuopt_s.md` and records the release in its header.

## Testing

Expand Down
2 changes: 1 addition & 1 deletion assets/optcuopt.def
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mip_probing boolean 0 1 1 1 Toggles the probing-cache step of cuOpt's internal M
dual_postsolve boolean 0 1 1 2 Controls whether dual postsolve is enabled when using Papilo presolver for LP problems. Enabled by default for LP when Papilo presolve is selected.
time_limit double 0 1e10 0 maxdouble 1 1 Controls the time limit in seconds after which the solver will stop and return the current solution (default GAMS ResLim)
work_limit double 0 1e10 0 maxdouble 1 1 Controls the work limit (machine-independent measure of solver effort) after which the MIP solver will stop and return the current solution
node_limit integer 0 maxint 0 maxint 1 1 Controls the maximum number of branch-and-bound nodes the MILP solver will explore before stopping and returning the current best feasible solution (if any).
node_limit integer 0 maxint 0 maxint 1 1 Controls the maximum number of branch-and-bound nodes the MILP solver will explore before stopping and returning the current best feasible solution (if any) (default GAMS NodLim)
prob_read string 1 "" 1 1 Reads a problem from an MPS file
solution_file string 0 "" 1 1 Name of a file where cuOpt should write the solution
user_problem_file string 0 "" 1 1 Name of a file where cuOpt should write the user problem (MPS format)
Expand Down
13 changes: 9 additions & 4 deletions optdef2md.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
GamsOptionsSpecWriter for other solver links): one subsection per option group, one table row
per visible option, with doxygen anchors <SOLVER><option name> to link to options.

Usage: python3 optdef2md.py [assets/optcuopt.def] [-o optcuopt_s.md]
Usage: python3 optdef2md.py [assets/optcuopt.def] [-o optcuopt_s.md] [--source "<repo> <tag>"]
"""

import argparse
Expand Down Expand Up @@ -121,8 +121,9 @@ def table_row(solver, opt):
return f"| \\anchor {solver.upper()}{opt['name']} {opt['name']} | {cell} | {escape(default)}|"


def write_md(solver, deffile, groups, options):
lines = [f"<!-- This file is autogenerated by optdef2md.py from {Path(deffile).name}. -->"]
def write_md(solver, deffile, groups, options, source=None):
origin = f"{Path(deffile).name} of {source}" if source else Path(deffile).name
lines = [f"<!-- This file is autogenerated by optdef2md.py from {origin}. -->"]
for number_, (name, title) in sorted(groups.items()):
opts = sorted((o for o in options if o["group"] == number_ and o["visible"]), key=lambda o: o["name"].lower())
if not opts:
Expand All @@ -144,15 +145,19 @@ def main():
parser.add_argument("deffile", nargs="?", default=str(Path(__file__).parent / "assets" / "optcuopt.def"),
help="option definition file opt<solver>.def (default: %(default)s)")
parser.add_argument("-o", "--output", help="output file (default: opt<solver>_s.md in the current directory)")
parser.add_argument("--source", help="origin of the def file recorded in the output header, "
"e.g. \"GAMS-dev/cuoptlink-builder v0.0.9b\"")
args = parser.parse_args()
if args.source and "--" in args.source:
sys.exit("--source must not contain '--' (it goes into an HTML comment)")

stem = Path(args.deffile).stem
if not stem.startswith("opt"):
sys.exit(f"{args.deffile}: expected a file named opt<solver>.def")
solver = stem[3:]
groups, options = parse_def(args.deffile)
output = Path(args.output or f"opt{solver}_s.md")
output.write_text(write_md(solver, args.deffile, groups, options))
output.write_text(write_md(solver, args.deffile, groups, options, args.source))
print(f"Wrote {output} ({sum(o['visible'] for o in options)} options)")


Expand Down
Loading