Repository navigation
Conversation
A temporary directory whose path approaches or exceeds the 248-character limit for directories made MP2NL terminate abnormally after the conversion. The writer now keeps the directory as given when its absolute form fits, otherwise uses the 8.3 form or the extended-length form, and reports an error when the directory cannot be used. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…NL subsolvers Cases of the fast set run with a 5 s limit by default (--timeout overrides). New solver entries '<driver>_mp2nl' run an MP driver through MP2NL. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A convex QP objective became a rotated cone with the coefficient instead of its square root; qcones2qc dropped the square of a fixed first variable; the exponential-cone check ignored a constant term. Tests socp_14..18, expcones_08. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e right direction With a negative .objweight of the first objective the pass objective's nonlinear part was relaxed the wrong way. Tests multiobj_NL_01, multiobj_QP_02. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…argument Needed for big-M of logical constraints with such functions. New option cvt:pre:funcbndtol (default 1e-12 relative margin; negative: old behavior). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…' for functions Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… Debug and ASan runs Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…tive multi-objective errors Indicator, PWL and nonlinear constraints in the right groups; duals of the fixed model; a clear error when several objectives are passed natively and one is not linear (COPT dropped a quadratic one silently). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ong-path forms The solver is run through std::system(), and the file stub went onto that command line unquoted: a temporary directory with a space or another shell character in its path broke the solver call. The stub is now quoted (double quotes on Windows, single quotes elsewhere; on Windows a stub with a double quote, which no file name can contain, is reported). On Windows the whole command is also wrapped in one more pair of quotes, which cmd.exe /c removes when the command has more than two. A quoted solver path gets ".exe" before its closing quote. The 8.3 and extended-length forms of a long temporary directory are removed: Windows does not accept a TMP longer than MAX_PATH anyway, so they only extended the usable length from about 225 to 259 characters, and the extended-length form would reach third-party solvers. A temporary directory that cannot be used still ends with a message instead of an uncaught exception. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nl-solver-test runs NLSolver with a stand-in solver (nlsol-fake-solver) that checks its command line and writes back the stub it received: QuoteCommandArg; a custom stub and an automatic one in a temporary directory whose name has shell characters; a missing temporary directory; on Windows, one too long for NLSolver's subdirectory. The last two expect NLUtils::myexit() rather than an uncaught exception. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DECLARE_SOLVER_API_FUNCTIONS(mp2nl) instead of (MP2NL): the library now exports AMPLSClose_mp2nl and AMPLSGetModel_mp2nl, matching AMPLSOpen_mp2nl and the other MP libraries (AMPLSOpen_gurobi / AMPLSClose_gurobi, ...). AMPLSOpen_mp2nl, which released drivers look up, is unchanged. Callers of the former AMPLSClose_MP2NL can look up both names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NLSolver reports an unusable temporary directory via NLUtils::myexit(), which exits by default; MP2NL then wrote no solution file. MP2NL now uses an NLUtils whose myexit() throws, and Solve() catches it: the failure and its message are reported to AMPL in the solution file. NLSolver forgets the directory name before reporting, so a throwing myexit() cannot make the destructor delete a directory it did not create. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ounds Since the result of exp is bounded by its argument (z >= 0 gives 1) and widened by cvt:pre:funcbndtol, the explicified exp result no longer has lower bound 0 with best bounds: check for a value just below 1. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…obj=0 and cvt:nlobj=0 When several objectives are handled natively and one is quadratic or nonlinear, the message now also names the options that move quadratic and nonlinear objective terms into constraints (synonyms passquadobj, passnlobj): all objectives are then linear and the native multi-objective optimization works. New end2end case multiobj_QP_02 with cvt:quadobj=0 (Gurobi, Xpress, COPT; CPLEX's native multi-objective optimization does not take the quadratic constraint, its message is unchanged). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…in scipmp The small-fixes commit had added a second "unreleased" section next to an existing "Unreleased" one; merge them. scipmp: use the spelling of the other files. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… supported The synonyms passquadobj and passnlobj are no longer named in the error messages or changelogs. The Xpress changelog states only that Xpress 10 is supported (customer-facing text: no Optimizer build numbers or older versions). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The quadratic form of a cone whose first variable is fixed by its bounds used (c0*v)^2 as the right-hand side, which drops the cone's v >= 0: sqrt(x^2+y^2) <= t with t fixed at -3 was solved (Gurobi, Xpress, CPLEX, SCIP, BARON: objective 4.24). The right-hand side is now c0^2*v*|v|. Found in the review of the merged branches (finding B-F1). Test conic/socp_19_fixed_x0_negative; changelog entry for the fixed-head fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With cvt:pre:funcbndtol=0 the domain of a piecewise-linear approximation, clipped by the function values, can end 1 ulp below an integer bound (exp(log(5)) = 4.999...): the breakpoint x = 5 was lost and the solver extrapolated there (log(x) - 0.27x over integer x in [1,5]: x = 5, 0.324 reported instead of x = 4, 0.306). ConsiderIntegrality() now rounds the ends with a relative tolerance of 1e-9. The help of cvt:pre:funcbndtol no longer calls 0 "exact bounds". Review findings B-F2, B-F3. Test logical/funcbnd_log_02_int. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MP2NLUtils::myexit() now throws its own type, NLSolverExit, and Solve() catches only that: other exceptions (NL feeder errors, bad_alloc) keep their handling by BackendApp, with their own exit code, as before d062836. The changelog notes that on Windows '%' in the temporary directory path is still expanded by the command interpreter. Review findings D-F2, D-F1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd cvt:nlobj=0 With Gurobi 14 the quadratic objective is passed as a nonlinear one, so both options (as the error message says) are needed for native multi-objective optimization; Gurobi 13, Xpress and COPT accept either. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ps integers - Strict comparisons (<, >) that are true at the root now propagate the context into their arguments: a comparison shared by a disjunction and an if-then-else condition lost one of its implications (wrong optimum). - An integer variable fixed at a fractional value stays integer (infeasible), instead of being made continuous; contradictory bounds keep the type. - abs() of a variable fixed at a negative value: the constant result took a garbage variable index; use a fixed variable. - Unary encoding: comparisons x==c with c outside the variable's domain (or fractional) are fixed to 0; their flags were left free and counted. - MakeComplementVar accepts contradictory bounds (the model is infeasible). - CP-SAT: cvt:pre:continuous_fixed_vars is off by default (new hook FixedVarsContinuousDefault()); contradictory or empty domains give infeasible instead of an error. - Five regression cases in end2end fast/logical. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ReportKappaExact() used the .kappa suffix definitions, so the exact condition number overwrote the estimate and .kappa_exact was never set. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The sense 'F' was passed to CPXaddindconstr, which CPLEX 22.2 mishandled (wrong results or violated indicators; the LP writer printed '?'). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ted by the shell NLSolver::Solve(): - remove <stub>.sol before the subsolver runs; a solve that wrote none fails instead of reporting the result of the previous solve (reused stub, passes of the multi-objective emulation); - the subsolver's exit code (not the raw wait status) is reported, and a solution written before a nonzero exit is kept; - solver options are split at white space (quotes group words) and quoted for the shell, one argument each: ';', '$' and quotes no longer act as commands. Easy API: quadratic objectives with one or two terms were written as an NL sum with fewer than three arguments (invalid); nonlinear variables were counted per Hessian nonzero with only one index marked (CONOPT: wrong optimum). MP2NL model API: logical constraints are not counted as nonlinear objectives; after a solve, primal values, duals and suffixes that the subsolver did not return are dropped (the previous values stay until then: they are the initial guess of the next pass). Tests for the exit code, the stale solution, the shell and the quoting. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…bounds reported as infeasible - A domain hole of a variable made x == ub and x >= ub rewrite into each other endlessly (stack overflow): equality is no longer classified by IfPreprocessHole. - Contradictory (lower > upper) hard bounds of a variable are reported as infeasible (exit code 200) instead of being passed to the solver, where Xpress and SCIP failed for an indicator flag: option cvt:pre:infeasvarbnd (default 1). The exit code now survives the three rethrowing wrappers in the constraint keeper. - Bounds of integer variables are rounded inwards: option cvt:pre:roundintbnd (default 1). - Regression cases holes_eq_bound_loop_01 and indicator_contradict_bounds_01. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…overs implied-integer variables - cvt:pre:roundintbnd is the tolerance of rounding the bounds of integer and implied-integer variables inwards (default 1e-9, negative: off). - Integral constants (shared fixed variables) are marked implied-integer; best-known bounds are rounded too, so [1, 1/6] becomes [1, 0]. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The mark changed the count of auxiliary integer variables that auxint_01 checks through MP2NL. The rounding of integer bounds (cvt:pre:roundintbnd) still covers integer and implied-integer variables. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…asibility Best-known bounds are deduced from the model's constraints, so their contradiction (beyond pre:eps / pre:epsrel) proves infeasibility as well. Before, only a warning was issued and the contradictory bounds reached the solver; Xpress then stopped with "Non binary variable used as an indicator binary" instead of reporting infeasibility. Controlled by cvt:pre:infeasvarbnd, as for hard bounds. Test: end2end logical/indicator_contradict_bounds_02 (generated example). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The static presolve folded an indicator only if its binary was fixed when the indicator was added. A binary fixed later (e.g., by a root logical constraint flattened afterwards) reached the solver as a constant, made continuous by PrepareVariables(); Xpress and SCIP then stopped with "Non binary variable used as an indicator binary". Now the indicator converters (le/ge/eq/quad, new base BasicIndicatorConverter_MIP) fold such an item: the subconstraint is added if the binary has the indicator's value, otherwise the item is dropped. IfNeedsConversion() makes accepted indicators convert, and ConvertDelayedItems() revisits indicators behind the conversion cursor (ConstraintKeeper::ConvertNeededBehindCursor()). No big-M rows on the constant binary when indicators are linearized. Option cvt:pre:indfixedflag (0/1*), subject to cvt:pre:all; 0 restores the old behavior. Tests: end2end logical/fixed_indicator_flag_* (objective on all solvers; final-model structure with Gurobi, accepted and linearized indicators, with and without folding, cvt:pre:all=0). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add headers missing from the add_prefix() lists (ampls-ccallbacks.h, expr-linear.h, constr_nonlinear.h, eexpr_hashed.h, var_bnd_impl.h, redef/MIP: cond_literal.h, disj2ind.h, indicator_fixed_flag.h, int_div.h, rounding.h) and src/wrap_xml.h to parse-xpress-options, so that IDEs such as Qt Creator show them in the project tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each pass runs the subsolver, which prints its banner. When the previous pass left both banners alone on the line, the next banner followed them, and the line read "MP2NL 0.2: MINOS 5.51: MINOS 5.51: optimal solution found." MP2NL now ends that line and prints its banner again first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Windows check: Ctrl-C with Xpress
|
| Ctrl-C during | Result |
|---|---|
| the MIP | <BREAK>, "Fixed MIP for mip:basis skipped: the solve was interrupted.", the MIP's incumbent; exit 0 within ~0.2 s |
| the fixed LP | the same skip message and the MIP's results |
| after the fixed LP | normal results with duals |
| model input, before the solve | "interrupted before the solve" (solve result 471) instead of a full solve (see fix 2) |
| through AMPL | <BREAK>, the skip message, solve_result "limit" |
No access violation, no hang, no exit code other than 0 or the console's own Ctrl-C exit (below). Your step 5 (lim:time=5, no Ctrl-C) solves the fixed LP as before.
Fixed on the way.
a814c42bd: after a MIP stopped at a time, node or solution limit,XPRSloadmipsol()on the copy failed with ?902 (the copy is still presolved), so the report had no basis or duals. The copy is now postsolved first. New end-to-end casemip_basis/fixed_mip_limit(lim:mipsol=1) fails without the fix.1e7fed24d: a Ctrl-C while the model was read and converted printed<BREAK>, butSolve()cleared the flag and Xpress ignores an interrupt before an optimization starts, so the full solve ran. The flag is now cleared once, when the handler is installed (picking up an earlier Ctrl-C viaInterrupter::Stop()), andSolve()then skips the solve. Also: a Ctrl-C during the fixed LP was reported as "Fixed model status: Unfinished ... failed"; it now gives the skip message, and the interrupt check is directly beforeXPRSlpoptimize/XPRSoptimizeon the copy.
Not covered / known.
- A Ctrl-C in the first ~1 s of startup, while the driver loads Xpress and checks the license, ends the process with
0xC000013Aand no.solfile: MP installs its handler only once the backend exists. This predates the PR and applies to every MP driver. - A Ctrl-C before AMPL has started the solver is taken by AMPL, which then runs the solve.
- "A second Ctrl-C ends the driver" could not be exercised: the driver exits within ~0.6 s of the first one.
Checks on the final build: AMPLS fixed-model test passes; Xpress mip_basis (32 cases) and multi_sol have no failures; suf_std (2) and multi_obj (5) fail the same cases without these commits. Not run: Linux/macOS with these commits, CI.
Tested and written with Claude Code.
1e7fed2 cleared the interrupt flag only when the handler was set, once per run, so with the multi-objective emulation a Ctrl-C in one pass skipped every later pass: the emulator continues after an interrupted pass with a feasible point, and the result became "interrupted before the solve" although a solve ran. Now only a Ctrl-C before the first Solve() skips it; later passes run as before 1e7fed2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
It's of course a review made 99.99% by AI, since it is impossible to keep up with this: 148 commits and counting.
For what is worth:
Reviewed at f3a5304c3.
Built and tested on Windows 11, MSVC 2026 Release (HiGHS 1.16.0, Xpress 10.0.0, AM 2360 PL 20261117):
- AMPLS tests
ampls-solve-error-test.py(HiGHS) andampls-fixed-model-test.py(Xpress, including the linear MIP) pass. - Xpress end-to-end
mip_basis(32 cases) andmulti_solpass.suf_std(2) andmulti_obj(5) fail the same cases at the base. - Ctrl-C on Windows, in every solve phase and through AMPL: no crash and no hang. Details are in the earlier comment.
- Solver banners checked through AMPL: a plain HiGHS solve, and MP2NL with MINOS and multi-objective emulation.
- The CI failures come from the infrastructure, not from this PR. The PR #292 build fails the same way. The errors are:
- "No image label found to route agent pool" on the Linux jobs;
- pip failing to download the Python 3.7 wheels on Windows;
std::to_charsbeing unavailable before macOS 13.3, innl-writer2.cc, which this PR doesn't change.
Fixed during this review:
f3a5304c3: with multi-objective emulation, a Ctrl-C during one pass made the later passes skip their solve (introduced in1e7fed24d).6a1d0e45b: AMPLS wrote backspaces into the.solmessage for a banner that was never printed.9aca8c66f: MP2NL with multi-objective emulation printed the subsolver's name twice.
Follow-ups (not blocking)
- From Filipe's review: item 4 (the divisor warning on solvers with native division) and items 7–9 (repeated scans, the second presolve pass, duplicated multi-objective code), as agreed.
- Xpress:
- Predating the PR: with multi-objective emulation, a pass that stops early (time limit or Ctrl-C) leaves the problem presolved. The next pass then fails to change the objective (?902 now, ?268 in driver 20260624), and the solve result is 500. Postsolving before the next pass should fix it.
- Check the interrupt again right before
XPRSoptimize(after tuning). SetHandlerstores the handler before its data (src/solver.cc:592). A Ctrl-C between the two stores calls the handler with null data.- A
.basfile is still written after a skipped or failed fixed solve. - The return code of
XPRSpostsolveon the copy is ignored. fixed_mip_limitdoesn't check that a limit was actually reached.
- Gurobi:
- The MIP gap is computed against the MIP's objective, while the reported objective is the fixed model's.
- Predating the PR: a Ctrl-C doesn't stop the fixed-model solve.
- SCIP: the fixed LP may fail outright with an LP solver other than SoPlex (
SCIP_LPPAR_PRESOLVING). Unverified. - MP2NL:
- After a failed subsolver run, the start of the error text can be taken for the subsolver's banner.
subsolver_banner_isn't reset between solves (AMPLS afterAMPLSReportError).- With verbose output, there's an extra blank line between passes.
- Stochastic-programming adapter, predating the PR (
src/sp.h,DoAddTerm): a random variable inside a coefficient is indexed with a negative index.- The shape is real: AMPL writes
2*xi*xaso2(o2(n2,xi),x). - Only the old
random()encoding can reach it, because MP doesn't read theRsegment.
- The shape is real: AMPL writes
- Tests: there's no unit test for the version and banner logic in
solver-test.cc, and no automated Ctrl-C test. - Predating the PR: a Ctrl-C in the first second of startup ends any driver with no
.solfile.
…port what they pass A primal-dual start was passed only when AMPL sent both primal and dual initial values, so a plain primal start (let x := ...) was ignored, e.g. by Gurobi's NL barrier, BARON and Knitro. Core (backend-mip.h): - PartialStartApplies(): models without unfixed integer variables (after reformulation; not IsMIP(), which Gurobi 13 reports for continuous models with nonlinear general constraints), and drivers without MIP starts. - There, primal or dual values alone make a start, as allowed by the new option alg:startpartial (bitmask, default 3; 0 restores the old behavior). - AddPrimalDualStart() returns bits: 1 primal values passed to the solver, 2 dual values passed. Debug suffixes .test_ini_pri/.test_ini_dua follow them. Warnings alg:start:primal / alg:start:dual report incoming values not passed (dual values only if no primal values were passed, so that re-solves do not warn). - alg:start value 0: the text says that an incoming LP basis is still used. Drivers: value presolve fills a missing vector with zeros, so each driver passes a vector only if it came from AMPL, and returns the bits. COPT takes an LP start only with both vectors; primal values count as passed when COPT solves a MIP (HasMIPItems()) or the model is nonlinear (MIP start, NL start). CBC: MIP start for MIPs. BARON: models with integer variables get the start from AddMIPStart(), which never wrote it before (IsMIP() is always false). SCIP: primal values alone go as a partial solution via AddMIPStart(). CP-SAT: no hints in AddPrimalDualStart(). Xpress: RowVectorMatches() drops only the dual values. HiGHS: no zero row duals with its MIP start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New cases in fast/warmstart: primal values only (pstart_nl_01 with a constraint, pstart_nl_02 without constraints, pstart_lp_01), dual values only (dstart_lp_01), integer variables fixed by bounds (mipstart_fixed_01), continuous variables in SOS1 (pstart_sos_01), an LP re-solve (resolve_lp_01.run); per-driver expectations, warning checks via solve_message, alg:startpartial=0 negative controls. The dual check of warmstart_01 moves to a case for drivers that pass dual values. The runner gives KnitroMPSolver and CbcMPSolver the warmstart tag. knitromp gets no starting point at all (also with primal and dual values; to be fixed separately), so it fails warmstart_01, pstart_nl_01 and pstart_lp_01. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aration) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fractional value of an integer variable was reported only when it rounded to 0: the integrality test passed the rounded value as the reference with an infinite relative tolerance, and Violation::Check requires both tolerances to be exceeded. MOSEK 12 beta, for example, returned "integer optimal" solutions with integer variables at 10.5 without any warning. Now a value is reported if its distance from the nearest integer exceeds sol:chk:inttol (default raised from 1e-5 to 1e-4, as in the MIPLIB 2017 checker; solvers' defaults are 1e-5 or smaller) and sol:chk:inttolrel times the integer's absolute value. The new relative tolerance defaults to 0 (absolute test only); a positive value can excuse floating-point errors of very large values. Documentation: new subsection "Integrality of variables" in the solution check guide. Unit tests SolCheckTest.*. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Messages that refer to variables or constraints by their generic names (solution check report, contradictory variable bounds, errors in algebraic constraints, SDP matrix errors) now suggest "option <solver>_auxfiles rc;" when AMPL did not pass names. When it did, the AMPL name follows _svar[i] or _scon[i], e.g. "_svar[1] (x)"; original variable names reach the converter for such messages before name presolve. BasicSolver records whether names were read (ampl_names_read()) and gives the hint (AuxfilesHint()). Warning titles "_svar bounds" and "_svar best-known bounds" become "Contradictory variable bounds" and "Contradictory deduced bounds"; the text says "deduced" instead of "best-known". Unit test SolCheckTest.Report__auxfilesHint__onlyWithoutNames. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Primal or dual start values alone (
|
| Driver | What it does now |
|---|---|
| gurobi | PStart and DStart are set separately |
| cplex | CPXcopystart with NULL for a missing vector; returns 0 on error |
| xpress | XPRSloadlpsol with NULL for a missing vector; a row-count mismatch drops only the duals |
| highs | dual values alone go with a NULL column vector |
| mosek | one call per vector; no duals for integer problems |
| copt | LP start only when complete, because COPT_SetLpSolution rejects NULL; NL and MIP models get the primal values through the MIP start (HasMIPItems(), HasNLExpressions()) |
| scipmp | primal values alone are left to AddMIPStart(), so no second, zero-filled solution is added |
| baronmp | continuous models through AddPrimalDualStart(); MINLP starts are written by AddMIPStart(), decided by HasUnfixedIntVars() (before, this code was never reached) |
| cbcmp, knitromp, cpsat, mp2nl | bits only; mp2nl sets y0 only when dual values came |
- Changelogs (
f1f2ddf48): MP, Gurobi, BARONMP. - Tests (
dff692006,test/end2end/cases/categorized/fast/warmstart/):pstart_nl_01,pstart_nl_02: NL barrier, primal values only, with and without constraints. Gurobi checks the log line "Loaded warm-start solution" andsolve_result_num < 200.pstart_lp_01,dstart_lp_01: primal-only and dual-only LP starts, with the expected warnings for drivers that cannot take them.mipstart_fixed_01: all integer variables fixed. CP-SAT returned MODEL_INVALID here with an intermediate version of the change.pstart_sos_01: native SOS.resolve_lp_01.run: a re-solve gives no warning.- Negative controls with
alg:startpartial=0go throughANYSOLVER_options. Plainmp_optionswould also reach MP2NL's MP subsolver. - The runner now gives Knitro and CBC the
warmstarttag.
- knitromp (
cb26f75ad):knitromputils.hcompiles with clang; the extra qualification in a member declaration was removed.
Checked
- End-to-end fast set on 12 drivers: gurobi 13.0.3, xpress, highs, cplex, baronmp, mp2nl, copt, mosek, scip, gcg, gecode, cpsat. Failing cases are the same as before the change. All new cases pass where they apply.
warmstartfolder on the same drivers: only failures that also occur without the change (highsknap_40_pstart×2, mp2nlwarmstart_01 warmstart=2).- Gurobi 13.0.3 and 14.0.0: the primal start reaches the NL barrier. With Gurobi 14, staying near the start may need
nlbar:initmu. - Review: two-round reviews of the diff by two models. Each confirmed finding was fixed and has a test.
Known open points
- knitromp receives no starting point at all, also with both vectors (this was already so before the change). Because of the new
warmstarttag, it failswarmstart_01 warmstart=2,pstart_nl_01andpstart_lp_01until this is fixed. - cbcmp was not run: the Cbc libraries for macOS are x86_64 only.
- COPT warns
alg:start:primalon a re-solve when all dual values were zero, because AMPL then sends no duals. This is documented. - HiGHS: not checked whether the dual values stay after the MIP-start call of
Highs_setSolution. This would not be caused by this change.
🤖 Generated with Claude Code
Solution check: integrality; names in messages (
|
Problem: d2c371b meant MP2NL to keep cvt:pre:infeasvarbnd=1 by removing its own default of 0 and following the converter's default, which was 1 then. e4ae0db changed the converter's default to 0, so MP2NL silently got 0 again: contradictory variable bounds (lower > upper, also deduced by the converter) went to the NL subsolver. Checked with infeasvarbnd_01.mod (bounds [3, 2] deduced from x >= 3, x <= 2; presolve 0) through MP2NL: CONOPT failure 531, LINDO Global failure 500, Xpress ASL failure 500 instead of infeasible; Knitro 205, BARON 200. With 1 all report infeasible (200). The end2end cases did not show it because they set cvt:pre:infeasvarbnd=1 explicitly. Change: the default comes from the ModelAPI again, as the other converter defaults that differ per driver (NLAssignLevelDefault, NLReifLevelDefault): - model_api_base.h: DeclareInfeasVarBndDefault() returns 0, so every other driver keeps 0. - mp2nlmodelapi.h: returns 1, with the reason in a comment. - converter.h: declareInfeasVarBnd_ is initialized from ModelAPI::DeclareInfeasVarBndDefault(); the option help prints the actual default ("Default {}") instead of a fixed "0*" and says why MP2NL uses 1 and when to set 0 (subsolver's relaxation or IIS). - CHANGES.mp.md, CHANGES.mp2nl.md: MP2NL's default and the visible change (infeasible instead of a subsolver error). - end2end iis_feasrelax: 'infeasvarbnd_01 MP2NL default' (no mp_options; conopt, lindoglobal, xpressaslmp2nl, knitro, baron: infeasible) and 'infeasvarbnd_01 MP2NL infeasvarbnd=0' (old behavior; knitro, baron: infeasible). Tests (macOS, Release; MP2NL and libmp2nl-lib built from this branch, ASL drivers from the root build): - iis_feasrelax with conopt, lindoglobal, xpressaslmp2nl, knitro, baron: no failures; with the previous libmp2nl-lib the new default case fails for conopt, lindoglobal and xpressaslmp2nl, so it detects the defect. - copt built from this branch: option help shows Default 0; iis_feasrelax passes (24 cases run, incl. the infeasvarbnd=0 cases). - fast set with conopt through MP2NL, new vs previous library: same 163 failing cases except the new case, which fails only with the previous library. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With cvt:pre:sort, the preprocessing of NumberofVarConstraint sorted all its arguments, including the reference variable x of `numberof x in (...)`, which must stay first. When x had a larger index than the compared expressions (for example, when abs() elsewhere in the model made AMPL write x after them in the NL file), the constraint counted another value, which could give a wrong optimum. Now only the compared arguments are sorted. Tests: new e2e cases fast/logical numberof_ref_sort_01 and numberof_ref_sort_02 (wrong optimum before the fix). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
numberof compares its arguments for equality, so either direction of an argument's value can change the result. The context of the numberof result was propagated to the arguments, so that an argument such as max(), min(), abs() or another numberof was reformulated for one direction only. This failed with "Part of expression redefinition could be lost" or, with a nested numberof, gave a wrong optimum. The arguments of NumberofConst and NumberofVar constraints now always get the mixed context; the result's own context is unchanged. Tests: new e2e cases fast/logical numberof_ctx_01 (nested numberof, wrong optimum before) and numberof_ctx_02 (max() argument, error before). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BackendApp::Run() wrote an mp::Error's code to the .sol file whenever it was at least 0. SCIP's NL reader links an older copy of MP whose Error constructors default to code 1 (EXIT_FAILURE), so a model that scipmp could not convert, such as one with `not alldiff(...)`, was reported with solve result 1 (solved), and AMPL kept the previous variable values as if they were a solution. An error code in the solved range 0-99 is now reported as failure (500). The AMPLS C API wrapper likewise returns -1 for such codes instead of the code. specifications.md (AMPLS and mp::Error contracts), CHANGES.mp.md and CHANGES.scipmp.md are updated. Tests: new e2e case fast/logical not_alldiff_fail_01 (solve result failure for HiGHS, Gurobi, SCIP, CPLEX, COPT); with this fix the existing case knap_40 also passes on SCIP. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The converter's numeric decisions get their tolerances from one place, the new class NumericTolerances (num_tolerances.h): - integrality: new option cvt:pre:inteps (synonyms pre:inteps and the former cvt:pre:roundintbnd, roundintbnd), default 1e-6 (was 1e-9), effective value max(inteps, ulps margin); values from 0.5 are rejected; negative: the ulps margin only; - floating-point margin of computed values: new option cvt:pre:ulps, default 16 units in the last place (was fixed at 16); - comparison tolerance: cvt:pre:feastol (absolute). The converter sets them once after option parsing (StartModelInput()); cvt:pre:all=0 makes all of them exact. RoundIntBound() and PrepareVariables() (integrality of fixed values, before a fixed 1e-6) use them. A no-op ModelAPI hook SetIntegralityTolerance() passes cvt:pre:inteps to solver APIs that round bounds themselves (CP-SAT). The help of cvt:pre:all, cvt:pre:feastol and cvt:pre:feastolrel describes their present use. Shared constants (fixed continuous variables) are never rounded. Previous behavior: cvt:pre:inteps=1e-9 is the former default of cvt:pre:roundintbnd. Tests: unit tests RoundIntBoundUsesUlpTolerance (expectations for the new default), NumericTolerancesIntegrality, DecisionMarginFromConstant, SharedConstantsNeverRounded (converter-flat-test), CmpTolTest.PreAll0__exactTolerances and CmpTolTest.IntEpsHalf__rejected (converter-mip-test). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comparisons inside logical expressions are decided from the bounds of their expressions with the margin d = max(cvt:pre:feastol, m), where m is cvt:pre:ulps units in the last place of the compared constant (DecideByBounds(), DecideEqualityByBounds()): - a non-strict comparison holds within d: x >= 4 at x <= 3.9999995 is no longer decided false, and (x+1)/3 >= 2 at x <= 5 is no longer decided false by the computed bound 1.9999999999999998 (the returned solution violated the model); - a strict comparison is false as the negation of the opposite non-strict one with the same d, and true only exactly, up to m; a strict comparison decided false only within the tolerances gives the warning strict_cmp_tol; - where m exceeds a positive cvt:pre:feastol, comparisons of continuous expressions are not decided; integer-valued expressions with an integral right-hand side are decided with d = feastol. For integer-valued expressions, a right-hand side within cvt:pre:inteps of an integer is that integer (PreprocessRoundRHS(); equalities, also after normalizing the coefficient: SnapIntegerEqualityRhs(), false without such an integer): x <= 0.3/0.1 in a disjunction allows x = 3, x == 0.3/0.1 is no longer false. An equality's right-hand side within m of a bound of its expression becomes that bound (0.3*b == 0.1*3). cvt:pre:ineq2bndeq rewrites comparisons of continuous expressions as equality to a bound only within d of it (was cvt:mip:eps): x <= 5e-5 at x in [0, 1e-4] became x == 0, and not (1e-5*x > 5e-5) could make a model infeasible. Previous behavior: cvt:pre:feastol=0 gives exact decisions; cvt:pre:feastol=0 cvt:pre:inteps=-1 cvt:pre:ulps=0 the previous results, except the cvt:pre:ineq2bndeq fix, which no option restores; cvt:pre:all=0 disables all rounding and tolerances. The expected counters of the e2e case test_ineq_unify_02 change (condlin lt/le/ge/gt 0/0/2/0 -> 2/2/4/2; objective -44 unchanged), because comparisons cvt:mip:eps/k from a bound are no longer rewritten. Tests: unit tests DecisionMarginCoversRoundingError, DecideByBoundsSymmetric (converter-flat-test) and 11 CmpTolTest cases (converter-mip-test); new e2e cases fast/logical cmp_bound_fp_01/02, cmp_tol_le_cont_01, cmp_tol_ge_cont_01, cmp_tol_neg_scaled_01, cmp_tol_int_rhs_01/02, cmp_tol_int_eq_01, cmp_tol_eq_scaled_01, cmp_tol_decide_01, cmp_tol_bin_eq_01, cmp_tol_strict_true_01, cmp_tol_eq_feastol_01, cmp_tol_big_bnd_01..03, cmp_tol_big_int_01, cmp_tol_strict_false_01, with old-behavior variants (feastol=0, exact, ulps=0, inteps=-1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The result bounds of floor, ceil, round, trunc and div were obtained by rounding the computed bounds of the argument. A computed bound can miss the exact one by a rounding error, e.g., (2/3)*5 + (1/3)*2 = 3.9999999999999996 instead of 4, so floor() got the upper bound 3, which cut off the optimum or made a feasible model infeasible. A fractional argument bound is now first moved outward by the floating-point margin, cvt:pre:ulps units in the last place (RoundBoundOutward()), never by a feasibility tolerance: floor(x) at x <= 3.9999995 is still at most 3. Integral bounds are taken as exact. Previous behavior: cvt:pre:ulps=0. Tests: unit test RoundBoundOutwardToleratesRoundingError (converter-flat-test); new e2e cases fast/int_ops round_bnd_fp_01..05 (ceil, floor, nested ceil(min(floor)), div, round; wrong optimum or infeasible before) and floor_data_bnd_01 (data bound within feastol of an integer: unchanged result). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comparisons x == const of an integer variable used a unary encoding (one binary variable per value) for domains of up to 1e7 values, which could exhaust memory, e.g., with x != 4 for x in 0..100000. New option cvt:uenc:maxdom (default 10000) is the largest domain encoded; larger domains use reified inequalities for each compared value. The limit is checked again with the final bounds (DontNeedEqEncForVar()), whose upper bound is now rounded down, not up. For integer variables, the compared constants (encoding keys) within cvt:pre:inteps of an integer are that integer (IsVarConstCmp()), so that one flag serves each value, also with cvt:pre:eqresult=0; CreateUnaryEncoding() tests integrality of the keys with the same tolerance. Previous behavior: cvt:uenc:maxdom=10000001 (faster for alldiff and similar expressions comparing many values of a larger domain). Tests: unit tests UEncMaxDomain (converter-flat-test) and CmpTolTest.UEncMaxDom__noEncodingForLargeDomain (converter-mip-test); new e2e cases fast/logical cmp_tol_uenc_01 (domain of 1e5 values, killed by the memory guard before) and alldiff_dom_01 with the variant maxdom=10000001. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With cvt:pre:ineqrhs=0, the right-hand side of a comparison is not rounded before the reformulation, and the offset 1 of a strict comparison of an integer-valued expression was applied to the fractional right-hand side: x < 3.5 became x <= 2.5 and excluded x = 3. The output right-hand side is now the next integer (IntStrictRhs(): body < c gives body <= ceil(c-t) - 1, body > c gives body >= floor(c+t) + 1, t = cvt:pre:inteps); no change at the default cvt:pre:ineqrhs=1. New warning strict_cmp_eps when the gap cvt:mip:eps of a strict comparison of a continuous expression is not smaller than the range of the expression, so that its strict side can be empty (e.g., 1e-6*x < 3e-6 for x in [0, 6]). Tests: unit test CmpTolTest.IntStrictFractionalRhs__nextInteger (converter-mip-test, also with cvt:pre:ineqrhs=0); new e2e cases fast/logical cmp_tol_int_lt_01 (default and ineqrhs=0, which failed before) and cmp_tol_strict_eps_01 (infeasible encoding with the warning; with cvt:mip:eps=1e-7 solved). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CP-SAT driver rounded bounds of integer-valued rows and variables with its own rule (within 1e-9 of an integer, else inward) and compared numberof values with a fixed 1e-6. It now receives the converter's integrality tolerance cvt:pre:inteps through the ModelAPI hook SetIntegralityTolerance() and takes such bounds and values within max(own rule, inteps) of an integer as that integer (BoundTolerance(), RoundBoundInward(), MakeDomain(), VarDomainToInt64()), as the MIP drivers do: x <= 3 - 1e-7 allows x = 3. Coefficients and constants keep the stricter rule. specifications.md and CHANGES.cpsat.md are updated. Previous behavior: cvt:pre:inteps=-1 (for bounds; numberof values then use the 1e-9 rule). Tests: new e2e case fast/logical cmp_tol_numberof_01 (numberof 0.3/0.1 in (...) counts integer variables at 3) with the variant exact (cvt:pre:inteps=-1 cvt:pre:ulps=0: infeasible, MIP solvers only). It is in this commit because CP-SAT passes numberof natively; it also exercises the converter changes for the MIP drivers. The cmp_tol_* cases of the previous commits pass on CP-SAT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- With recomputed values (sol:chk:mode bits 32-512), the solver's value of a functional expression is compared with the recomputed one only on the side its context requires (ContextSignedDifference()), as in the check with the solver's values. Bits 64 and 128 reported false violations, e.g., of a count required to be at least 2 whose solver value was below its true value. - The unary-encoding link constraint has no violation of its own (its placeholder reported 1000), which gave false warnings with bits 4 and 128. - New option sol:chk:logtol (synonym chk:logtol), default 1e-5: the tolerance of truth values inside logical expressions in the check (non-strict comparisons, integrality in floor, ceil and round, numberof), which used sol:chk:feastol before. sol:chk:feastol and feastolrel now measure violations only. Strict comparisons are evaluated exactly, because MP encodes them with the gap cvt:mip:eps. With the solver's values, a conditional comparison whose result differs from its truth is a violation of 1 (was the gap). 0: exact evaluation, as in AMPL. Previous behavior: sol:chk:logtol=1e-6 (the default sol:chk:feastol) restores the former truth tolerance; the context comparison, the unary-encoding check and the violation of 1 are fixes without an option. Tests: unit tests SolCheckTest.ContextSignedDifference and SolCheckTest.ConditionalTruthWithinLogTol (converter-flat-test); new e2e cases fast/logical chk_ctx_count_01, chk_ctx_max_01 (also with sol:chk:mode=128), chk_logtol_01 (also with logtol=0), chk_uenc_01 (sol:chk:mode=128 and 4). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Where the floating-point margin m (cvt:pre:ulps units in the last place of the compared constant c) exceeded cvt:pre:feastol, i.e., from |c| of about 5.4e8 at the defaults, NumericTolerances::DecisionMargin() returned "do not decide", and such comparisons went to the solver (review findings W1F-01, W1F-06, W1F-07): - b <==> x <= U, b <==> x > U and y = 0 ==> x > U at x <= U = 1e13 gave wrong results, because the solver's gap cvt:mip:eps is below the spacing of doubles at U; - comparisons whose bounds miss a large right-hand side by far were passed on, and Gurobi reported a feasible model infeasible or a wrong optimum (random models with coefficients of 2.5e8 to 1e11); - the rule was not monotone in cvt:pre:feastol: x >= 1000 at x <= 10 was decided at the default and at 0, but not at 1e-12. The decision margin is now d = max(cvt:pre:feastol, m), as with cvt:pre:feastol=0 where m is larger. Integer-valued expressions with an integral right-hand side keep d = cvt:pre:feastol (exact bounds; from |c| of about 2.8e14, m >= 1 would decide x >= c true at x <= c-1). The branches for a negative margin in DecideByBounds(), DecideEqualityByBounds() and IfPreprocess2BndEq() are removed. Help of cvt:pre:ulps, specifications.md and CHANGES.mp.md are updated. Tests: unit tests DecisionMarginFromConstant (updated), DecisionMarginAboveFeastol (converter-flat-test), CmpTolTest.BigRhs__decidedWithFPMargin, CmpTolTest.FarFromRhs__decidedAtSmallFeastol and CmpTolTest.HugeIntegerRhs__notDecidedByFPMargin (converter-mip-test); the first four fail on the previous commit. New e2e cases fast/logical cmp_tol_big_rhs_le_01, cmp_tol_big_rhs_gt_01, cmp_tol_big_rhs_impl_01, cmp_tol_far_01 (also with cvt:pre:feastol=1e-12, checking that no conditional comparison is passed) and cmp_tol_big_coef_01 (Gurobi infeasible before; CP-SAT excluded: fractional coefficients). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tolerances of the converter's decisions; numberof and error-status fixes (
|
The two cases (commit 6274be4) contain the fractional coefficient 1/3, which the CP-SAT driver rejects ("failure"), independently of the comparison decided from bounds that the cases test. Exclude CP-SAT with "solvers_exclude" so that other solvers still run them. Checked: CP-SAT skips both cases; HiGHS passes both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep bound snapping for continuous expression bodies. Check the exact residual in a HiGHS and Gurobi regression where the wrong point otherwise has the right objective.
TASK-050: preserve an exact integer equality RHS
Review attribution — OpenAI Codex, with two independent review rounds including a separate GPT-6.1-sol reviewer. |
|
Closing: MP is now maintained inside AMPL's integration repository, and these changes (together with the follow-up fixes on |
Summary
This pull request combines three topic branches that were developed and tested together,
plus one Gurobi 14 commit that is not yet on master:
task-041/nl-writer-long-temp-path: the NL writer and MP2NL on long temporary paths(Windows), and MP2NL error reporting;
task-043/start-vector-sizes: row and column vectors passed to and from the solvers(Xpress row order, driver audit), function bounds for
exp/a^x/log,multi-objective messages;
task-045/logical-conversion-fixes: logical-constraint conversion, inlining of linearsubexpressions, feasrelax, solution pools, and driver fixes from a systematic review;
new randomly generated test models;
7a43570ffromtask-007/gurobi-14-release, which was merged without it: a warning on afailed NL IIS query, and
.funcnonlinear/.globalon NL constraints.It replaces the separate pull requests of these branches. The changelogs ("unreleased"
sections) describe every user-visible change; this description lists the main ones.
Main changes
Conversion of logical constructs, all solvers:
abs()of negative fixed variables;cvt:pre:indfixedflag, 0 restoresthe old behavior);
div/mod/floor/ceil/round/truncresult bounds are passed also withoutcvt:pre:boundsbest;Inlining. Linear and quadratic subexpressions are also inlined into the expressions
that define other variables:
cvt:pre:unnest, default 63;cvt:pre:linfill(default 10) andcvt:pre:quadfill;cvt:pre:unnest=31 cvt:pre:linfill=-1restores the old model.With NL output, linear terms are no longer written as nonlinear, so CPLEX and Xpress through
MP2NL no longer reject such models as "not convex quadratic".
Bounds:
cvt:pre:roundintbndrounds integer bounds inwards with a tolerance;cvt:pre:infeasvarbnd=1declares contradictory bounds infeasible; the default warns andpasses them on;
exp,a^x,logandlog_afollow from the argument; none for abase ≤ 0 or 1;
cvt:pre:funcbndtol.feasrelax (Gurobi, CPLEX, COPT, HiGHS):
Messages. Warnings and errors are wrapped at 60 characters;
tech:msgwidth=0restoresthe old output.
Drivers:
kappa_exact;InfUnbdInfoonly for continuous models;AMPLSSolve()solves again (regression in 20261029).Tests:
cases/categorized/fast_random: 4100 randomly generated logical models, with expectedresults from enumeration. It is not run by default;
test/end2end/generators/logical_models.pyreproduces those models exactly;fixed_sos2_pl(fixed model with SOS).Compatibility
New defaults change models passed to solvers. The old behavior is restored by:
cvt:pre:unnest=31 cvt:pre:linfill=-1(inlining);cvt:pre:indfixedflag=0;cvt:pre:roundintbnd=-1;cvt:pre:funcbndtol=-1;tech:msgwidth=0.One instance of the INFORMS showcase (battery, Gurobi) became slower with the new inlining
in some seeds. With other seeds both formulations stop at the time limit. It is
equivalent, and is documented as variability.
Testing
Builds: Release, Debug and ASan/UBSan of the MP build and of the private driver build;
GCC 16 where the ABI allows it.
converter-flat,converter-mip,nl-solver,nl-readerandutilpasson Release, Debug and ASan.
failures against the previous runs. Each failure that remains is known and listed in the
task record.
previous runs where compared.
before the fix and re-tested after it.
The tree equals the tested merge of the three branches, apart from the order of changelog
entries, the master changelog date, and the new test models.
🤖 Generated with Claude Code