Changelog¶
Unreleased¶
- Benchmarks: every table measured again, on one machine. All 29 published data sets were run
again on 2026-11-23/24 on the Apple M4 Max Mac the other tables came from, on optimaru 0.6.0,
which searches as 0.7.0 does (the pickup-delivery CP-SAT rows on the model the benchmark now
carries, with #144's horizon). The two VRPTW tables, school timetabling's track-1 table and the
ruin_recreate_as_move_weightA/B runs in the meeting and conference scheduling guides came from a 4-core cloud machine before and now come from the Mac too, so no table or guide names another machine.benchmarks/README.mdsays how far the numbers repeated against the tables they replace.
0.7.0¶
From 0.6.1. Breaking: a request that sets a field which acts only through a cost, while its
constraints leave that cost out, is now refused with ValueError instead of solved as if the
field were not there; default selections are unaffected except employee scheduling's
desired_shifts. Routing profiles gain forbidden and preferred jobs (technician skills) and may
share travel (same_travel_as). The engine's C++ moved to core/ and local search to search/;
nothing changes in the installed package's import paths.
- Breaking: a parameter needs its cost. A request that sets a field which acts only through a
cost (a vehicle's
max_end_time, a visit'smax_end_time, a worker'sunavailable_dates, a knapsack'smandatory_items, ...) while its constraints leave every such cost out is refused withValueError, naming the field, where it is set and the costs to add; before, the solve ignored the field without a word. The effective selection counts (the defaults whenconstraintsis None, a pick at weight 0 included). It is checked where the input is the JSON model (solve_request,solve(model)); compiled problems are solved as given. With an API key set, the request is sent as it is (school timetabling also checks before sending), and the refusal comes from the server once it runs this release. Default selections are unaffected (they hold every cost, pickup-delivery's opt-insquared_order_age_costat weight 0, soorder_timestill needs that cost weighted to act), except employee scheduling'sdesired_shifts, whosedesired_shift_costis not among the defaults: a request that sets it now has to pick that cost. Each use case'smodels.parameter_uses(model)lists what an input sets, and docs/use-cases/README.md ("Parameters and their costs") has the table for all 22 use cases. - Routing: forbidden and preferred jobs per travel profile. A vehicle routing
TravelProfilelists the visits its vehicles may not serve (forbidden_visits) and those they are preferred for (preferred_visits); a pickup-delivery one does the same by request id (forbidden_requests,preferred_requests, both stops of a request kept together). Two new constraints in each use case score them:profile_forbidden_visit_cost/profile_forbidden_request_cost(hard, weight 1000, one unit per visit or per stop), which is always on: a constraint list that leaves it out, or picks it soft or at weight 0, still gets it hard at its defaults; andprofile_preferred_visit_cost(soft, weight 600 per visit) /profile_preferred_request_cost(soft, weight 300 per stop), about ten minutes of driving for one job, which a request with preferred jobs on a profile some vehicle drives on must list (ValueErrorotherwise; a profile no vehicle drives on prefers nothing). A plan with such lists is scored on the default constraints, as one with groups is, on the constraint assembly, which takes fewer steps per second than the core path; the group operators and the pickup-delivery request operators never place a job on a vehicle that forbids it, and a job no vehicle may take stays unassigned. Unknown ids, an id twice in a list and an id both forbidden and preferred are refused, and so is a pickup-delivery request required on, or pinned to, a vehicle whose profile forbids it. The compiled plans take the lists asProfileVisits/ProfileRequestsentries (profile_visits=/profile_requests=), named per vehicle byprofile_visits_index/profile_requests_index. On a plan without lists the search is the one it was. Engine-only: the CP-SAT reference has no plugin for them. - Routing: a profile may drive as another one does.
TravelProfile.same_travel_asnames another profile whosedurations,distancesandmissing_valuethis one uses, so profiles that differ only in their job lists (one per technician skill set, say) share one set of travel dicts. Profiles that drive alike share one matrix in the engine, and so do all the profiles that give no travel (straight lines), where each had a copy before: on a compiled plan such profiles now share oneVehicle.profile_index. - The engine's C++ moves to
core/. The header-only engine lives incore/optimaru/at the top of the repository instead ofoptimaru/cpp/optimaru/, sooptimaru/holds the Python package and its use cases. Includes stay#include "optimaru/...", and nothing changes in the installed package or its import paths; a build from source reads the headers from the new place. - Benchmarks: the pickup-delivery CP-SAT lane runs again. Since 0.6 the lane failed: it solved
with external-solver v0.3.0's pickup-delivery model, which reads the 0.5 input, and that library
is frozen. The model is now kept in the benchmark (
benchmarks/pickup-delivery/cpsat,pickup_delivery_cpsat.model), ported to depots,start_depot/end_depotand travel profiles, with atravel_distance_costplugin; the expected-failure mark is gone, and its parity tests (external-solver v0.3.0's, ported, plustests/test_model.pyfor depots and profiles) check it against the engine. - Source layout: the parts of local search live under
search/. In the engine,core/optimaru/keepssearch/local_search.hppandsearch/operators.hppand now also holds what the step loop draws on:search/moves/,search/ruin_recreate/,search/accept/andsearch/select/, which were folders of their own next tosearch/.construct/,stop/,score/andmodel/stay where they were. A use case files its own moves and acceptors the same way:<ns>/search/moves/and<ns>/search/accept/(bin packing, knapsack, pickup-delivery, project job scheduling, school timetabling, semiconductor scheduling and vehicle routing have them). Nothing changes in the Python package or in what the solvers do; C++ that includes these headers follows the new paths ("optimaru/moves/list_move.hpp"is now"optimaru/search/moves/list_move.hpp","vrp/moves/group_moves.hpp"is"vrp/search/moves/group_moves.hpp").
0.6.1¶
From 0.6.0. School timetabling solves on the optimaru API like every other use case once an API key is set, and its request takes a minimal starting solution. Nothing changes for a solve on this machine; the routing notebooks follow the 0.6 input, and the docs site carries the optimaru mark.
- School timetabling solves on the optimaru API too. With an API key set,
solve_requestsends itsTimetableRequesttoPOST /api/use-cases/school-timetabling/solve/jobs, as the other request use cases do, andsolve(problem_dict, ...)is sent as that request (the keywords, andconfigas the request's fields andsolver_parameters) and returns the dict a local solve returns. Until now both solved on this machine with aRuntimeWarning. Aconstraints=selection travels as its picks whether it is specs, names or anAssembly;on_new_bestis refused, as everywhere._api.local_solveis gone: every use case is served. - School timetabling:
TimetableRequest.initial_solutiontakes a minimal start. Besides a wholeTimetableResultModel, it takes{"lessons": [...]}whose lessons carry only acourse_idand aslot, ignoring keys it does not know (StartingSolutionModel), assolve(initial_solution=...)always did. A server on this release accepts such a start inrequest.initial_solution. - Docs site: the optimaru mark. The engine docs (GitHub Pages and optimaru.com/engine-docs/) show the optimaru mark as their favicon and header icon, on a plain white or black header with optimaru's green as the accent.
- Routing notebooks on the 0.6 input.
examples/vehicle-routing.ipynbandexamples/pickup-delivery.ipynbbuild their vehicles from depots (start_location_index/end_location_indexin the compiled layer,DepotModelwithstart_depot/end_depotin the JSON models), explain travel profiles where they explained the driving matrix, print kilometers next to driving hours, and ask for optimaru 0.6.0 or later. Saved with outputs from 0.6.0, they print and draw the same routes, scores and charts as on 0.5.1.
0.6.0¶
From 0.5.2. One breaking change: vehicle routing and pickup-delivery take depots, a start and
an end depot per vehicle, and travel profiles keyed by id in place of return_to_depot and one
driving matrix, so input written for 0.5 is refused (see the first entry). Nothing else changes
the package's input or results: solve_request no longer needs the package to be spelled
optimaru, the C++ sources moved into one tree per use case, and the benchmarks gain time-window
series for vehicle routing.
- Vehicle routing and pickup-delivery: depots, start and end depots, travel profiles (breaking).
The input names its depots (
depots, a list ofDepotModelwith anidand alocation), and a vehicle names where its route starts (start_depot) and where it ends (end_depot, its start depot or another). Without anend_depotthe route is open, as before withoutreturn_to_depot.VehicleModel.depot(vehicle routing),VehicleModel.home(pickup-delivery),return_to_depotand the input'sdriving_secondsmatrix are gone; old input is refused. Driving comes from travel profiles:profilesmaps a name to aTravelProfilewhosedurations(seconds) anddistances(meters) are dicts keyed by depot and stop ids,{from_id: {to_id: value}}, andVehicleModel.profilepicks one ("default"unless set). A pair the dicts leave out costs the profile'smissing_value, 10,000,000 by default (MISSING_TRAVEL_VALUE); a profile without one of the dicts, and every vehicle whenprofilesis empty, drives straight lines between the coordinates (haversine meters, at 50 km/h for the seconds); an empty dict is refused, since it would make every pair missing.to_planturns the dicts into one square matrix per profile over the depots, then the stops: for 1,000 places with both dicts given, 0.11 s to parse and validate 40 MB of JSON and 0.06 s to build the matrices on an M4 Max, so the JSON stays keyed by id. A new opt-in constraint,travel_distance_cost(soft, weight 0), prices the meters (its previews walk the candidate route, wheretravel_time_costanswers from prefix sums); the solutions reporttotal_driving_metersand each vehicle'sdriving_meters, andvehicle_metricsno longer echoesreturn_to_depot. In the compiled layerVehicletakesstart_location_index,end_location_index(-1 for an open route) andprofile_index, the plans takedurations=/distances=(lists of matrices, one per profile; None for the straight-line fallback), anddriving_time/ the newdriving_distancetake an optionalprofile. With one profile the solvers search exactly as before (seeded, step-limited solves of both use cases, open and closed routes, both scoring paths, return the same routes and scores as before). The public CP-SAT library the pickup-delivery benchmark pins (external-solver v0.3.0) is frozen and reads the 0.5 input, so that benchmark's CP-SAT lane is marked as an expected failure. The two routing notebooks ask foroptimaru<0.6until they are ported to the new input. solve_requestwrappers: the package is no longer written out. The decorator behind thesolve_requestof the request use cases refused a function that was not under a package spelledoptimaru. It now reads the package from its own module. Nothing changes for an installed optimaru; a copy of the package under another import name no longer fails when one of those use cases is imported.- Source layout: one C++ tree per use case.
optimaru/<use case>/cpp/include/<ns>/andcpp/src/are merged intooptimaru/<use case>/cpp/<ns>/, where a header sits next to its source, filed by role under the engine's folder names:solverandconstraints.hppat the top,model/(domain.hpp, demo data, travel times),score/(the monolithic calculators),constraints/, andmoves/,construct/,accept/where a use case has its own. The demo iscpp/main.cpp. Nothing changes in the Python package or in what the solvers do; C++ that includes a use case's headers follows the new paths ("vrp/domain.hpp"is now"vrp/model/domain.hpp","vrp/score_calculator.hpp"is"vrp/score/score_calculator.hpp"), withoptimaru/<use case>/cppas the include directory. - Benchmarks: vehicle routing with time windows.
benchmarks/vehicle-routingruns two new series,--series solomon(Solomon's 56 instances of 100 customers) and--series homberger(Gehring & Homberger's 300, 200 to 1000 customers), against the OR-Tools Routing solver with a time dimension. They are scored by the DIMACS convention under which CVRPLIB lists its best-known solutions: distance alone, every distance truncated to one decimal (the harness works in tenths). The files and best-known solutions are read at a pinned commit of the PyVRP/Instances repository, and the rescoring replays each route's schedule, so a missed window is reported as infeasible.--jobs Nruns N single-threaded runs side by side.scripts/publish_benchmarks.pyreadsvrptw-solomon.jsonandvrptw-homberger.jsoninto a results block of their own and two homepage data sets, and every homepage data set now names the machine it was measured on (--machine, so one publish run takes one machine's results). A run that is both incomplete and over capacity now printsn unassignedrather thaninfeasible, as the publisher already did. The publisher refuses a sampled run (--limit-per-bucket) of Set X or Gehring & Homberger, whose tables would read as the whole series.
0.5.2¶
From 0.5.1. Two additions: solve and solve_request can run on the optimaru API with an API
key, and project job scheduling gets a move that rebuilds the schedule from its order (on by
default, so its results differ from 0.5.1). The rest is benchmarks, CI, tests and notebooks.
-
Solving on the optimaru API with one setting. The optimaru API is the Enterprise edition: this engine run as a hosted service, whose solve request is the Python call. With an API key, in the environment (
OPTIMARU_API_KEY) or in code (optimaru.use_api("om_live_...")),solve(model, ...)andsolve_request(request, ...)send the problem there, wait for the solve job and return what they return on this machine: a new solved model, or the response model.OPTIMARU_API_URLoruse_api(key, url=...)names another API thanhttps://app.optimaru.com, andoptimaru.use_local()solves here again.configtravels as theSolverConfigfields that differ from the defaults andconstraintsas the picks in their order, so the same seed and step limit give the same result there as here on the same engine version. What cannot be sent is refused, not solved here without notice: a problem built from the compiled classes (pass its model), thesolve(problem)of vehicle routing, pickup and delivery, order picking and employee scheduling (callsolve_request), a callback (on_new_best,select), a non-finite number and a setting the engine refuses. School timetabling keeps solving here, with aRuntimeWarningonce (the API takes it in a request of its own); the compiledSolverclass used directly is the engine itself and always runs here. What the API refuses or fails at raisesoptimaru.ApiError(status,code,detail,retry_after). A solve is a job the call waits for, for at most twice its time limit (times its parallel starts, for a request) and ten minutes more: a look at it that fails for a reason that passes (the network, a 5xx, a 408, a 429) is tried again for a tenth of that wait and at least a minute, as is the read of its result, and interrupting a solve once its job exists cancels it. The key goes to that API only (https, or http to localhost without a proxy; no redirect followed), and the first solve sent there is logged at INFO on theoptimarulogger. No new dependency: the standard library and pydantic. Without a key nothing changes and nothing is sent. Every use case'ssolve, and thesolve_requestof the four request use cases and of school timetabling, are wrapped for this (__wrapped__is the function that solves here); their signatures are unchanged. -
CI: benchmarks run when a pull request touches them. A CP-SAT comparison job (and the vehicle routing benchmark job) runs on a pull request that changes its benchmark project or its use case, all of them when the shared runner (
benchmarks/cpsat-common/),ci.ymlor the Python and build files every benchmark installs (optimaru/*.py,setup.py,pyproject.toml,CMakeLists.txt) change, and all on a manual run of CI and on a weekly one (Sunday 18:00 UTC). A change to the C++ engine alone runs the three jobs whose C++ bench checks scores against Python (conference and meeting scheduling, school timetabling) and no other. A push tomainruns the CP-SAT jobs only up to their install, which keeps the build caches warm for pull requests. A smoke run takes one instance per scale (--one-per-scaleskips the seedsseeded()repeats a scale on), and the school timetabling job also runs track 1's cross-check gate.school-timetabling-bench.ymlandvrp-public-bench.ymlare run by hand only. A CI run took 7 to 9 minutes on every pull request, most of it in the smoke runs; one that changes no benchmark now waits only for the build and test jobs (the longest about 2.5 minutes). -
Project job scheduling: a move that rebuilds the schedule from its order.
SerialScheduleMove(SolverConfig.serial_schedule_moves, on by default; drawn on at most a fifth of the steps,custom_move_probability = 0.2) reads the start dates of the working schedule, changes the order they give (one allocation's place, a few neighbours, a precedence chain or a project, an execution mode, or the order of the schedule pushed to the right) and places every allocation again as early as its predecessors and the renewable resources allow, late projects first. Single changes of a delay stalled some percent above what the order allows. After 30 s on one thread the RG30 makespans are 63 / 75 / 55 / 73 / 72 (66 / 82 / 59 / 76 / 75 before; OR-Tools CP-SAT on 8 workers 62 / 74 / 56 / 73 / 71), the 20 generated instances of that shape end shorter on all 20 (21% in sum), and the comparison ladder is better on 9 instances and the same on 11. A seed's result differs from 0.5.1;serial_schedule_moves = Falsegives the earlier search. -
Benchmarks: every table has 20 instances or more. The 17 generated comparisons run ladders of 20 instances: a few sizes with several seeds of the generator each, the first instance of a size keeping its name and the others numbered from 2 (
medium-2, ...;cpsat_plugins.benchmark.seeded), and food packaging 20 plants of different sizes. The RCPSP runner generates instances in the shape of RG30 (--synthetic N,--synthetic-seeds), published as a second table beside Pat1-Pat5 (20 instances of 30 to 120 activities); the synthetic pickup-delivery table has one row per size and instance seed (21 rows, 10 to 400 requests;--synthetic-seeds); school timetabling's track 2 runs 20 schools of 3 to 60 classes (--sizes ladder, or any class count that is a multiple of 3) and writes its results as JSON (--out), whichscripts/publish_benchmarks.pyreads astimetabling.jsonin place of numbers copied by hand (anextra.jsonis refused). Track 2's CP-SAT time (wall) now includes building the model, so it is not comparable with olderRESULTS_track2.mdfiles. The Li & Lim head-to-head table adds the first 15 requests of each instance. - Benchmarks: every instance is generated in Python. The C++ quality benches read instance files and generate nothing; no solver, constraint or published comparison table changes.
- School timetabling, track 1:
school_timetabling_cpsat/gen_quickstart.pygenerates the S/M/L schools and the fixed cross-check instance, and writes each as JSON (CP-SAT, the evaluator) and as a token file (.sttxt, the C++ bench).st_quality_benchis nowst_quality_bench <instance.sttxt> <seed> <seconds> [parallel_solver_count]andst_quality_bench crosscheck <crosscheck.sttxt>;school-timetabling-comparewrites the instances itself, as before from--seed. The bench used to build them withstd::shuffle, which gives another school per standard library; the Python generator draws fromrandom.Random(seed)alone. The presets are the same, the schools are new ones:RESULTS.mdhas a track-1 table on them (the engine's S 175 / M 350 / L 666 soft at 30 s) and says which instances each older table is of. Track 2 and track 3 already generated in Python and are unchanged, as is the homepage's table (track 2). - Conference scheduling and meeting scheduling:
cs_quality_benchandms_quality_benchtake a dumped instance of the CP-SAT comparison (<instance.cstxt|.mstxt> <seed> <seconds> [knobs]) in the place ofdemoandscaled:N, whose generators are gone (0.5.1 is the last release with them; they are also in thev0.5.0tag).benchmarks/<slug>/dump_instances.pywrites the instances, as bed allocation's does, so a tuning run and the comparison solve the same problems.<ns>_quality_bench crosscheck <file>scores a fixed assignment, and the dump script prints the use case's own score of it:--check <bench>compares the two, and every constraint's raw cost, on every instance, and CI'sbenchmark-cpsatjob runs it. - The three readers refuse an index outside its table, and a seed or a budget that is not a whole number.
- The guides keep the tuning history measured on
scaled:Nand say where those instances came from. Each has a new table of the as-move default againstasMove=0on the comparison's instances: it wins on the smaller ones and not on the largest two of either use case (meeting scheduling'sxlarge: a mean objective 17.5% worse over 12 seeds). No default changes with this. tests/test_layout.pyholds a C++ bench to reading a file that a Python writer names.-
Tests and docs pick the defaults by name, not by position, in every use case. Lists such as
[*get_constraints()[:-1], WorkloadImbalanceCost(weight=1)]or[:3],[:9],[1:]meant "every default, with this one replaced"; a constraint added to the catalog, as the extending guides teach, would have been silently dropped or would have displaced another pick (#117 fixed maintenance scheduling). The tests of 16 use cases, the snippets in the READMEs andpython.mdof seven, the docstrings of five packages and a CP-SAT parity test now select by name in catalog order: the docs with the plain comprehension ([X(...) if spec.name == "x_cost" else spec for spec in get_constraints()]), the tests withtests/_picks.py(replace_default,without,only), which fails on a name that matches no pick or several. Meeting scheduling's and tournament scheduling's raw-cost metadata tests took their unit constraints as the first five or two oflist_constraints(); they now name them (UNIT_CONSTRAINTS), and their guides say to add a new unit constraint's name there instead of editing a slice. The five extending guides that explained a slice (and employee scheduling's, which named one in a test) no longer do. No expected score changed: the picks are the same lists.tests/test_layout.pyfails on an index or slice ofget_constraints(),constraint_info()orlist_constraints()in the tracked tests, docs, package sources, benchmarks, notebooks and the root README. -
Notebooks on 0.5.1. Every notebook in
examples/is saved with outputs from optimaru 0.5.1 and asks for it;examples/README.mdnames that version. Facility location's next steps nameswap_facility_moves, and bin packing's description of its search names the trade move. Twelve of the twenty-two print and draw exactly what they did on 0.5.0. Bin packing and facility location print new numbers from their new moves: bin packing's rush drums are now repaired by the search, as its text now says. With warm starts fixed (#110) the restart experiments moved for 0.5.0 were run again. Food packaging's rounds go back to 50,000 steps, where they show their point and print what they printed on 0.4.3; sports league scheduling's new-seed restarts climb again, and its text no longer says that a restart stalls at once; it says what a climbing new-seed line means. The others keep the step budgets that make their cells repeat (knapsack's rounds and move sets, food packaging's rush-order replan, maintenance scheduling's runs, rounds and urgent-job replan); bed allocation's new admissions keep seed 3, since seed 7 returns one plan at every budget, and drop the 3,000,000-step restart, which returned the 100,000-step plan; its text now says a long restart can drift as far from the old plan as a solve from scratch.
0.5.1¶
From 0.5.0. One fix first: in the seven use cases that search in stages, a solve that
starts from a given solution (with_initial_solution, a request's initial_solution)
searches as in 0.4.3 again; 0.5.0 could return the given solution unchanged (#110). What
else changes a result: bin packing and facility location have new moves, so a seed's
result there differs from 0.5.0; tournament scheduling searches a solve with
constraints= as it searches the default one, so a seed's result with constraints=
differs; and in employee scheduling the default solve no longer judges a pinned shift on
the four per-shift constraints, as the docs and the solve with constraints= already had
it, so a schedule whose pinned shift breaks one of them scores 0 there where it scored
-1hard. What changes without changing a result: a solve with constraints is faster where
some of them are at weight 0, with the same scores for a seed and a step limit; school
timetabling solves with a new soft constraint that has no weight field, where it raised;
and every demo instance is generate_demo_data(), with the five earlier names kept as
aliases. The entries on notebooks, benchmarks, tests and guides are about the repository,
not the wheel.
- Benchmarks: external-solver
v0.3.0. The benchmark projects pin the external-solver release that follows optimaru 0.5, the links into its sources point at that tag, and their lock files record the version of this checkout (0.5.1 with this release). Inv0.3.0the worker count of a CP-SATsolveisparallel_solver_count, the name of the engine's keyword (num_workersis still read), and its employee scheduling plugins say constraint where they said rule (SchedulePluginwasRulePlugin); the runners and the READMEs here use the new names. No table changes: the CP-SAT models are unchanged sincev0.2.3. - Notebooks on 0.5.0. Every notebook in
examples/is saved with outputs from optimaru 0.5.0 and asks for it;examples/README.mdnames that version. The four that build a request use the names of 0.5:time_limit_seconds, and in employee schedulingdefault_constraints(),model_input.constraintsandconstraint_totals. Twelve of the twenty-two print and draw exactly what they did on 0.4.3, and four move within the noise of solves that stop on the clock. The other six are of use cases whose search changed, and some of their experiments no longer showed their point; those now run on a step budget or another seed: knapsack's comparison of move sets (20,000 steps each,core_repack_movesoff beside the other moves) and its restart rounds, bed allocation's new admissions, food packaging's rounds and rush-order replan, maintenance scheduling's short runs, restart rounds and urgent-job replan. Maintenance scheduling's comparison of ruin and recreate on and off is gone: over 8 and 12 seeds it makes no clear difference there on 0.5.0. - Fixed: a solve from a given solution in the seven use cases with stages (#110). In
0.5.0 bed allocation, food packaging, knapsack, maintenance scheduling, max-cut, quadratic
assignment and sports league scheduling ran late acceptance in stages on every solve, also
one that starts from a solution the caller gave (
with_initial_solution, a request'sinitial_solution). A stage starts over from the start's score, which on such a solve is where the search already stands: it loosened nothing and was taken at each stall in the place of the ruin-and-recreate kick. A solve whose improvements come from the kicks then returned its start once the budget had room for stages. - Now only a solve that the construction starts has stages (
optimaru::nothing_placed, or the use case's own seed flag). A solution that places only a part counts as given. - The engine also ends the stages by itself when a search stalls before it has found
anything better than its start, whatever started it: a construction that no move improves
has none either, which matters to a caller who sets
AcceptanceSettings::history_growthdirectly. - Measured, a food packaging week with one new job, four seeds: improved on 4 of 4 at every step limit in 0.4.3 and again now, on 0 of 4 from 200,000 steps up in 0.5.0.
- Measured, a bed allocation plan with five new stays, 12 seeds: a mean medium score of -10.33 after 10 million steps in 0.4.3 and now (the same table, seed by seed), -10.58 in 0.5.0, where 2 of the 12 seeds ended worse under a larger step limit than under a smaller one.
- On 36 instances of the seven benchmark ladders a solve from a given plan finds exactly what a build without stages finds, new best by new best. The 46 instances solved from the construction end on the same score as in 0.5.0 at 300,000 and at 3 million steps, so the benchmark tables stand.
- The notebooks' restart experiments were moved to step budgets for 0.5.0 (the entry above) and have not been run again on this.
- Bin packing:
TradeMoveand a fill tie-break.used_bins_costcounts bins, so every packing with the same number of bins has the same score, and the search wandered from one to the next: on Falkenauer's triplets it ended one bin above the best known count. Two additions, both on by default.TradeMove(bp/moves.hpp,SolverConfig.trade_moves) trades up to two items of one bin for up to two of another so that the fuller of the two bins gets fuller, or, when no trade does that, so that both keep their loads with other items. And late acceptance takes a step that keeps the score when it does not lower the sum of the squared bin loads, and otherwise one time in eight (bp/fill_late_acceptance.hpp,SolverConfig.fill_tie_break). That sum is not part of the score: the score, the limits andon_new_bestare as they were. On the 24 sampled Falkenauer instances (two seeds, 10 s) no run ends above the capacity bound (39 of the 48 did before). The bound is the best known count the OR-Library file states for 23 of them, and one below it foru120_19. A seed's result in bin packing differs from 0.5.0. - Benchmarks: the bin packing table measured again. With the two additions above the
engine uses the best known number of bins the OR-Library file states on 23 of the 24
Falkenauer instances of the table (on 6 before) and one bin fewer on
u120_19, and CP-SAT is ahead on none (on the six triplet instances of 60 and 120 items before). The table of generated instances inbenchmarks/bin-packingis measured again as well, with each part of the search switched off in turn. - Facility location:
SwapFacilityMove, and a solve from scratch in stages. The search could close a facility (CloseFacilityMove) but not put another in its place, so it kept the facilities it first settled on: on the 200-consumer comparison instance it ended with 11 of CP-SAT's 12 facilities, 1.4% behind.SwapFacilityMove(SolverConfig.swap_facility_moves, on by default) opens a closed facility and closes the one that serves its surroundings in one move; the closed one's consumers go to their nearest facility with room, and each facility with room takes the consumers nearer to it. A solve that starts from nothing now also restarts late acceptance with a doubled history when it stalls (late_acceptance_sizeis the first stage's length), and from the first restart on it draws the macro moves on a tenth of the stepscustom_move_probabilityallows. A solve from a given assignment has no stages and keeps the full gate. - Measured on the six instances of
benchmarks/facility-location(30 s, three seeds): the mean cost above CP-SAT's is 0.07%, from 1.91%. - A short solve: after 50,000 steps the mean cost of a 200-consumer instance over 8 seeds is 3.10 million, against 3.22 million; it is lower at every step limit from 20,000 to 2 million, also with 30 and with 1,200 consumers.
- From a given assignment (36 seeds, 300,000 steps): 0.15% to 0.80% above CP-SAT's cost on the 60- and the 200-consumer instance, against 2.40% to 3.00%. A plan that needs one more facility for its new consumers keeps its facilities, as before: no move opens a facility without closing another.
- A seed's result in facility location differs from 0.5.0.
- Engine:
AcceptanceSettings::later_stage_custom_move_share. Withhistory_growth, the gate on a use case's own move operators (custom_move_probability) is multiplied by this once late acceptance has started over for the first time. A later stage takes worse solutions for a long while, the adaptive selector counts outcomes and not what a move costs, and macro moves that each make a pass over the solution then take the steps of the moves that polish; the first stage, the descent from the start, keeps the gate as set. 1 by default (no change); facility location sets 0.1. - Benchmarks: the facility location table measured again. The engine has CP-SAT's score on the four instances up to 200 consumers (on two before) and is 0.02% and 0.29% behind on the two larger ones (1.4% to 3.3% behind on four before).
- Python: every demo instance is
generate_demo_data(). The function that returns a use case's demo instance had five names; six use cases already called itgenerate_demo_data, five did not:order_picking.build_demo_data,meeting_scheduling.demo_data(the package,modelsand_core),tournament_scheduling.models.demo_data,conference_scheduling.demo_conferenceandsports_league_scheduling.demo_schedule. They aregenerate_demo_datanow, with the same arguments and the same instance. The five old names remain as plain aliases of it in the modules that had them, without a warning, and are no longer in__all__.tests/test_layout.pychecks from the source that a demo function has no other name. - Tests: maintenance scheduling picks the defaults by name, not by position.
test_offset_zero_reproduces_the_plain_scorestookget_constraints()[:5]as "the four date constraints andcrew_conflict_cost", so a constraint added to the catalog would have silently replaced one of them. It now takes every default with the tag conflicts squared and states offset 0 on each, so a new constraint is covered without a change; the snippet inpython.mdand the step inextending.mdthat warned about the slice follow. - Tests: the pickup-delivery and order-picking plugin tests compare a solve with an
independent recompute. Check (f) of
pdp_plugin_testandop_plugin_testcompared the solution's score withScoreCalculator::score()of the same solution, but that call stores its result in the solution first, so both sides were one number. The check now keeps the score the plugin solve reported and compares it with the monolithic recompute; with the travel or walking weight doubled in the assembly it fails, as it passed before. - Employee scheduling: the default solve no longer judges a pinned shift on the per-shift
constraints.
es.solve(schedule)andes.calculate_score()counted a pinned shift inrequired_skill_cost,employee_unavailability_cost,undesired_day_costanddesired_day_cost, while the components behindconstraints=andsolve_request, the constraint descriptions andpython.mdtreated it as settled history that is not judged again. So the same schedule scored differently on the two paths: a pinned shift on a skill its employee lacks scored-1hardon the default solve and 0 withconstraints=. The default solve now skips it too, so that schedule scores 0 on both, and a pinned shift on an unavailable, undesired or desired day no longer costs or earns its minutes there. The constraints between shifts (shift_overlap_cost,max_one_shift_per_day_cost,min_rest_cost) andshift_count_imbalance_costcount a pinned shift on both paths, as before. A schedule without pinned shifts scores as before; no benchmark instance pins a shift.es_plugin_testnow pins shifts in its parity check and solves with pinned violations underScoreChecks::Fullon both paths. - Benchmarks: every public-instance runner has one form. Pickup & delivery and
project-job scheduling ran theirs as a command of the comparison package, while bin
packing, quadratic assignment and assembly-line balancing kept a loose
bench/package beside the project, run asuv run --project cpsat python -m bench.run_bench. Those three now follow the first two:<use case>_cpsat/public_benchmark.py(helpers inpublic_benchmark_data.py) with the command<slug>-public-bench, run withuv runfrombenchmarks/<slug>/cpsat;bench/RESULTS.mdiscpsat/PUBLIC_BENCHMARKS.md, downloads are cached in the package's ignored.cache/, and bin packing's search-quality check isbin-packing-quality-bench(bin_packing_cpsat/quality_bench.py). Flags, output and--jsonare unchanged; the tests arecpsat/tests/test_public_benchmark.pyand need no network.tests/test_layout.pychecks that nobenchmarks/<slug>/bench/package is left and that everypublic_benchmark.pyhas its<slug>-public-benchentry. A checkout that ran the old runners keeps its downloads inbenchmarks/<slug>/bench/.cache/: still ignored, no longer read, so delete thatbench/directory or move the archives tocpsat/<use case>_cpsat/.cache/. - Benchmarks: school timetabling's comparison is a package with a command. Its
three-track harness was a separate script project (
benchmarks/school-timetabling,st-bench, not installed) whose four scripts imported each other as top-level modules and put the CP-SAT model and the engine onsys.pathby hand, run asuv run run_bench.py. It is now the packageschool_timetabling_cpsatin thebenchmarks/school-timetabling/cpsatproject, next to the CP-SAT modelteacher_scheduling, as every other use case has it:run_bench.pyisbenchmark.py, run asuv run school-timetabling-compare(--track2,--track3), andevaluate,cpsat_quickstartandgen_canonicalrun asuv run python -m school_timetabling_cpsat.<module>. Thest-benchproject and its lock are gone, oneuv syncthere builds the engine extension too, andschool-timetabling-bench.ymlsyncs and runs only that project. Flags, outputs and the generated instances are unchanged (the S, M and L schools are byte-identical);out/is now undercpsat/when run with the default--out-dir. - Tournament scheduling:
TeamCountMoveand the guided change values run with picked constraints too.ts.solve(schedule, constraints=[...])searched without the macro move that empties or refills whole teams, because the move read the monolithic calculator's counters, so on the demo it stayed on the 7-team optimum (medium 1.19523) where the default solve reaches medium 0 (6 teams of 12 slots). The move now reads its counts through a small type: the calculator's on the default path, as before, and counts of its own on the assembly, recounted from the schedule each time the move is drawn;value_recommendercounts the day's teams off the schedule there.team_count_movesandvalue_recommendernow apply to both paths, and the same seed and step limit end on the same schedule on both. - Demo, 1 million seeded steps: with the default constraints picked, medium 0 (soft
-1.54919), from medium 1.19523; with
team_count_movesoff, medium 1.19523 on both paths. - The default path is unchanged: the same final score and the same number of new bests
from the same seed and steps (demo and the 800-slot
xlargeinstance), and 2.33 million steps per second onxlargebefore and after (medians of three seeded runs at 4 million steps, interleaved). - The assembly pays for the move as the default path does: 1.20 million steps per second
on
xlarge, from 1.73, and a better end after 1 million seeded steps (soft -6.97615, from -9.31891, which the default path also reaches). - A seed's result with
constraints=differs from 0.5.0. - School timetabling: a new soft constraint no longer needs a fast-path weight field to
solve. Python read every soft constraint's weight off
canon.ObjectiveWeightsby name, on both paths, so a soft component added to the catalog made everyst.solve()raiseAttributeErroruntil it had a field there (C++ struct, binding, stub), which the guide made part of its first step. Now a solve withconstraints=weighs it at the pick's weight, and the default path, whose monolithic calculators do not score it yet, reports it inpenaltiesand weighs it at its component default inobjective_value, as the field will;weights=andmodels.ObjectiveWeightsModelrefuse any other value for it (after the usual checks: a bool, NaN or a negative weight raises as anywhere else). A constraint with a field is read as before, and a field the catalog does not know fails the import. The example ofdocs/use-cases/school-timetabling/extending.mdadds the field in step 5, with the monolithic terms; its steps 2 to 5 were applied, built and tested again. - School timetabling docs: the speed of a solve with
constraints=as measured. The python guide said the assembly runs at 35–55% of the monolith's move throughput (track 2 at 10 s), and a fixed-step run on 0.4.3 had shown about 25%. Seeded single-thread solves of the track-2 schools (S and M 2 million steps, L 4 million, seeds 1 to 3) give a median of 46% on S, 62% on M and 37% on L, and 25% to 71% for one seed: the rate of both paths moves with the search. The python guide, the extending guide's step 5 and the track-2 notes inbenchmarks/school-timetabling/RESULTS.mdnow say so. - Engine: a constraint at weight 0 costs a move nothing. An opt-in constraint that is off
(weight 0) adds an exact 0 to the score, but a solve with constraints still computed it: on
an assignment-shaped use case every move called its
delta_cost()orcost(), on a sequence-shaped one every applied list edit did (the previews already left it out), and a global was sent every change. Soget_constraints(), which holds the opt-in constraints at their weight 0, ran slower than the same picks without them, and slower with every opt-in constraint added. - A unit constraint at weight 0 is now left out of every move: member changes, list edits,
batch ends, previews and the trial snapshot. Only a reset costs it, and
constraint_costs()costs it on the current solution when it reports, so its raw cost is still reported. A report right after a reset costs nothing extra, which is whatsolveand the Pythonconstraint_costs()do; a C++ caller that reports between moves pays onecost()per unit for each such constraint, every time. - A global is still sent every change by default, because a global may serve more than its
own cost (aggregates a move source or another component reads). One that only feeds its
own
cost()can declareidle_at_weight_zero()(GlobalConstraint, described indocs/extending.md): at weight 0 it is then sent no change and is reset before its raw cost is reported. Assembly-line balancing'sworkload_imbalance_costand max-cut'spartition_imbalance_cost, the two globals with a default weight of 0, do. - A member of a compiled delta group is still evaluated with its group at weight 0; only its fold is left out.
- No score changes, bit for bit: the weighted constraints are visited in the order they
always were. Checked on seeded, step-limited solves with
get_constraints(), three seeds each (assembly-line balancing 1 million steps, max-cut 2 million, vehicle routing and pickup and delivery 300,000): the final score and the sequence of new bests are those of main before this change. A solve withoutconstraints=does not go through this code. - Measured on the same solves, one thread, medians of six runs with before and after taken in turns: assembly-line balancing (100 tasks) from 1.78 to 4.51 million steps per second, pickup and delivery (100 requests, 10 vehicles) from 54 to 70 thousand, max-cut (400 vertices) from 3.53 to 3.59 million. Vehicle routing (100 visits, 10 vehicles) stays where it was, 14 and 13 thousand, inside the spread of its runs (12 to 14).
- The step-by-step guides said that a pick at weight 0 is still computed and measured what it cost; those passages and their figures are re-measured on this version.
0.5.0¶
Upgrading from 0.4. Two things can break a caller; the entries below have the details.
pydantic 2.11 or newer is required (was 2.5). And JSON written by the models uses the new
names only: time_limit_seconds and parallel_solver_count in a request (were timelimit
and num_workers), constraints and constraint_totals in employee scheduling (were
rules and rule_totals). The earlier names are still read, in JSON, as keywords and as
attributes, so what a caller sends keeps working, and employee scheduling's Python names
with "rule" in them (default_rules(), Rule, RULE_MODELS and the others) are the
constraint names under a second name. Seven use cases search differently, so a seed's
result there differs from 0.4.3: bed allocation, food packaging, knapsack, maintenance
scheduling, max-cut, quadratic assignment and sports league scheduling. So does a solve
with constraints in vehicle routing or pickup and delivery that asks for more than one
parallel start: it runs them now. The entries on notebooks, benchmarks and guides are
about the repository, not the wheel.
- Vehicle routing and pickup and delivery: parallel starts on a solve with constraints.
parallel_solver_count(also a request's field;num_workersis its earlier name) had no effect when a plan was scored with constraint plugins: a list passed asconstraints, a request with a vehicle limit, a pinned stop or a required vehicle, or a plan with groups. Those solves now run that many starts, start i onrandom_seed + iand on its own copy of the constraints, and return the best, as a solve on the core rules does. With one start nothing changes. On generated grouped plans four starts end 0.8% to 2.4% shorter than one in the same 4 s (vehicle routing, four classes) and 2.1% shorter (pickup and delivery), longer in none of the 25 pairs. In C++,Solver::solve(plan, makeCalculator)takes a factory that builds one calculator per start; the overload that takes a calculator stays a single start. Vehicle routing'ssolve_requestleaves visit groups to the engine, as pickup and delivery's does since 0.4.3. Both solvers refuse a badSolverConfigbefore the plan is touched: the check ran after the unassigned pool was cleared, and in pickup and delivery after the pair construction. - Notebooks. Every notebook in
examples/is saved with outputs from optimaru 0.4.3 and asks for it;examples/README.mdnames one version again. Nineteen of the twenty-two show what they showed before. Three move within the run-to-run noise of solves that stop on the clock, and no text quotes a number that moved: conference scheduling and meeting scheduling print slightly different scores, and order picking's chart of rounds takes another path through its middle rounds to the same printed end. - Benchmarks: the lock files record optimaru 0.4.3. The benchmark projects install
optimaru from this checkout, and their locks name its version: they still said 0.4.2 after
the release, so the first
uv syncrewrote them. Nothing else moves; the projects stay on external-solverv0.2.3, which needs no change for 0.4.3. solvefor a problem,solve_requestfor a pydantic request, in every use case. The pydantic path had two shapes: four use cases took a request throughmodels.solve_request, the others took their problem model throughsolve, and school timetabling took dicts. Every use case now has both entry points, and the package exports both (optimaru.<use case>.solve_requestismodels.solve_request).- New: a request model in the other 17 and in school timetabling:
models.<Name>Request, the problem model asmodel_inputwith the settings of one solve, andmodels.solve_request(request, *, constraints=None), which returns whatsolvereturns for that model. School timetabling'sTimetableRequestholds the problem as the newTimetableProblemModelwithmode,weightsandinitial_solution, andsolve_requestreturns the newTimetableResultModel; the package now imports its models with itself. - Renamed: the settings of a request have the names of
solve's keywords in every use case:time_limit_seconds(wastimelimit),random_seed,parallel_solver_count(wasnum_workers),stop_at_first_feasible, and the newfull_assert, besidesolver_parameters. The shared base isoptimaru._models.SolveRequest.timelimitandnum_workersare still accepted as aliases, in JSON, as keywords and as attributes; a dump uses the new names.model_copy(update=...)reads the old names too, and refuses a name given with its old name. - Employee scheduling:
ScheduleRequesthasrandom_seedandstop_at_first_feasibleat the top level like the others;settings.random_seedandsettings.stop_at_first_feasibleare the same fields under another name (a top-level value wins once it is given). Itssolve_requesttakesconstraints=, a list of specs that replacesmodel_input.constraintsfor the solve, and it readssolver_parametersandfull_asserttoo. - pydantic 2.11 or newer. The request models read their earlier field names through
validate_by_name/validate_by_alias, which pydantic has from 2.11 (the floor was 2.5). - Constraints, not rules. Employee scheduling called its constraints rules in its API and
guides; every use case now says constraints.
SchedulingInput.rulesisSchedulingInput.constraints,default_rules()isdefault_constraints(),Rule,RuleBaseandRULE_MODELSareConstraintModel,ConstraintModelBaseandCONSTRAINT_MODELS,rule_model()isconstraint_model(), andRuleTotal/ScheduleSolution.rule_totalsareConstraintTotal/constraint_totals. The earlier names are kept as aliases:rulesandrule_totalsare read from JSON and as attributes (rule_totalsread-only), and the old functions and classes are the new ones under a second name. Breaking for JSON consumers: a dump writes the new names only, so code that readsrulesfrom a dumped input orrule_totalsfrom a dumped solution must readconstraintsandconstraint_totals. The same holds fortimelimitandnum_workersin a dumped request. The guides and docstrings of the other use cases say "core constraints", "coupling constraints" and so on where they said rules for constraints. - Late acceptance in stages of growing history. A late acceptance history is a trade
between converging fast and finding more, and the use cases set one short length (400 to
3,200 steps), so a small instance converged within a fraction of a second and the kicks
alone had the rest of the budget: quadratic assignment, which has no kicks, did nothing
for the last 29.9 of 30 seconds on 14 facilities. The engine's new
AcceptanceSettings::history_growth(C++; off by default) restarts late acceptance from the start's score with the history that many times longer once the search has converged and found no new best for half as long as the next stage would take, as long as that stage fits in the budget; the best solution is kept as always. It is on, at 2, in food packaging, knapsack, max-cut, quadratic assignment and sports league scheduling, wherelate_acceptance_sizeis now the first stage's length. Measured on every instance of their five benchmark ladders at 30 s over three seeds: 62 runs better, 33 equal, 1 worse (a knapsack by 1 in 17,470). In the published tables sports league scheduling has 7 to 13% less travel, quadratic assignment ties CP-SAT up to 16 facilities (it was behind at 14 and 16), and the mean gap to the best known values of the 28 QAPLIB instances with a reference goes from 2.22% to 0.22%, 18 of them at the best known value. Every other use case searches exactly as before. In the five, the ruin & recreate kicks fire differently from the first step on: stagnation counts from the last improving move, and a kick waits at least two histories. With a time limit, the stage a solve reaches depends on the clock; a solve whose step limit ends it before the clock matters repeats for a seed. A stage does not know theunimproved_*limits: one shorter than a stage ends the solve inside it, with the best solution so far. A history stops growing at 2^20 entries (16 MB per start). - Knapsack:
CoreRepackMove. Sorted by value per weight, what the greedy leaves to decide sits in a narrow band around the first item the capacity leaves out, and an improving exchange there is two items for one or larger, which no flip or swap reaches: the 500 to 5,000 item instances of the benchmark stayed 1 to 3 below their optimum. The new move (ks/moves.hpp,SolverConfig.core_repack_moves, on by default) takes a window of that order around the break item, frees the capacity its selected items hold and fills it with the most valuable subset of the window, a small 0/1 knapsack solved exactly by dynamic programming over the weight; the acceptor judges the trade. It looks at the capacity only (the score judges resources, groups and dependencies), declines when its table would pass a million cells, and is drawn on at most one step in a thousand. All seven benchmark instances now end on CP-SAT's value, the four large ones within 0.01 s. Parallel starts run the solver's own search (a registered move does not reach the engine's multi-start threads). - Late acceptance in stages: bed allocation and maintenance scheduling too. Measured on their eleven benchmark instances at 30 s over three seeds. Maintenance scheduling: 13 of 15 runs better, the mean soft score 24%, 27%, 3.4%, 3.8% and 0.1% better from the smallest instance up (the two worse runs: 28 jobs on seed 1, the published one, and 48 jobs by 2 in 259). Bed allocation: 2.8%, 1.7% and 3.7% better up to 183 stays, the 20-stay instance on CP-SAT's value on every seed, and within 0.3% either way on the three larger instances, where few stages fit. Facility location was measured too and stays as it was: its 60-consumer instance got worse on all three seeds.
- Stages: a restart no longer delays the next one. The patience before a kick or a
stage is read from the average gap between new bests, and the gap from the last best of
one stage to the first of the next spans the whole restart, so after a stage that found
something the search waited about twice that stage's length before it moved on. That gap
is now left out of the average. Measured on the six ladders with stages and kicks or
restarts to gain from, at 30 s over three seeds: sports league scheduling 2.0% less
travel on average (11 runs better, 4 worse), max-cut 5 better and none worse, bed
allocation and food packaging level (+0.4%, +0.1%), maintenance scheduling level (6
better, 5 worse), quadratic assignment the same on every run. The stages are their own
engine header now,
accept/history_stages.hpp(optimaru::HistoryStages), with unit tests of the lengths, the cap and when a stage is due. - Benchmarks: the seven tables with stages and QAPLIB measured on this build (2026-11-12). Of their 46 instances the engine has the best score on 45 (18 of them ties) and CP-SAT on one: the 14-job maintenance schedule, -3145 against -3133. In 0.4.3, before the entries above, CP-SAT had the better score on 14 of the 43 instances those tables had. QAPLIB: mean gap 0.26% (2.22% before), 17 of 28 at the best known value.
- Benchmarks: three more rungs, five tables and QAPLIB measured again.
random25(quadratic assignment),g1600(max-cut) andteams12(sports league scheduling) join their comparison ladders. - Docs: adding a constraint, step by step, in every use case. Each use case has
docs/use-cases/<slug>/extending.md("Adding a constraint" under its name on the docs site). It takes one new constraint through that use case's own files in six steps: change a constraint that exists from Python, write a new one as a component, check it, make it cheaper per move, put it on the default fast path, measure. Every snippet comes from a patch that was compiled and tested, and every figure was measured, on 0.4.3, on the use case's demo or a generated instance; each guide says how its two scoring paths differ (which constraints the default path scores, what a step is, whether a pick at weight 0 is still computed, whenon_reset()runs) instead of repeating one text. The "Adding a hard or soft cost" list in each use case's README is now a pointer to that guide, anddocs/extending.mdstays the reference for the contracts.tests/test_layout.pyrequires the guide for every use case and holds it to the code: the number of constraints its first paragraph states, and every test and C++ test target it names.
0.4.3¶
- Vehicle routing: visit groups with a partial order. Visits that share a
group(VisitModel.group, a name;Visit.group_indexon a plan) are one job: they ride one vehicle together, or all stay unassigned.after(Visit.after_visit_indices) lists the visits of the same group served before a visit, a partial order on the group; an order with a cycle or one that leaves the group is refused. Two new hard constraints at weight 1000 score it:visit_group_cost(the grouped visits not where most of their group is, the same counting as pickup-delivery'srequest_group_cost, now the engine'soptimaru::GroupPlacement) andvisit_order_cost(per vehicle, the pairs served the wrong way round). Both answer the move previews. Groups are placed whole before the engine's construction, and the use case's first domain move,groupRuinRecreate, carries a group between vehicles as one unit (SolverConfig.group_ruin_recreate,group_ruin_max_visits); it is registered only for a plan with groups, so a plan without them is solved exactly as before. Every entry point scores a grouped input on the constraint assembly (solve_request,vrp.solve(plan),Solver.solve(plan)), on a single start, andcalculate_score(plan)reads a grouped plan the same way (C++:vrp::calculateScore). Engine-only: the CP-SAT reference reads neither field.list_constraints()andconstraint_info()have two more rows. - Every acceptance rule has its parameters. Vehicle routing, quadratic assignment and
semiconductor scheduling let
SolverConfig.acceptor_typename seven rules, but each bound the parameters of only some of them, soGREAT_DELUGEkept its water level at the start's score,STEP_COUNTING_HILL_CLIMBINGran at a fixed size, and in vehicle routingSIMULATED_ANNEALINGstarted at temperature 0, which is hill climbing. The three now share one set of attributes with the same defaults:entity_tabu_size(7),simulated_annealing_starting_temperature((0, 0) = automatic) andsimulated_annealing_temperature_fraction(0.01),great_deluge_water_level_step((0, 0)),step_counting_hill_climbing_size(400),record_to_record_start_gap(0.02) andrecord_to_record_end_gap(0.0), each checked when it is set. Only one default search changes: simulated annealing in vehicle routing, which now starts at 1% of the start's soft level (the driving time; the medium level of unassigned visits does not count). In C++ the fields are the newoptimaru::AcceptanceConfigbase (optimaru/solver_config.hpp), the automatic temperature is the engine's (AcceptanceSettings::start_temperature_fraction), andoptimaru::python::bind_acceptor_type()binds the enum. - Pickup and delivery joins the shared pieces. Its
SolverConfighas the acceptance attributes above (it hadacceptor_typeand the two record-to-record gaps), so simulated annealing no longer starts at temperature 0 there either: it starts at 1% of the start's driving time. In C++ itsScoreis the engine'sHardMediumSoftScore, and its bindings usebind_score(),bind_constraints()andbind_acceptor_type(). Its two record-to-record gaps are now checked when set (finite and >= 0, aValueErrorotherwise); nothing else changes in Python. - Pickup and delivery: a grouped plan is scored the same by every entry point. The C++
Solver::solve(plan), and with it Python'sSolver(config).solve(plan), scored a plan with request groups on the seven core rules, which leaverequest_group_costout, so a split group came back as feasible; onlypdp.solve(plan)andsolve_requestswitched to the default constraints. The engine now switches itself (PdpRoutePlan::hasRequestGroups()), on a single start, andcalculate_score(plan)(C++:pdp::calculateScore) reads a grouped plan the same way instead of overwriting its score with the core rules'. As in vehicle routing, a request alone in its group changes nothing: such a plan stays on the core rules, where 0.4.2 switched for anygroup. Withpair_construction_heuristicoff, a grouped plan now starts as any other does there: the engine's construction places every stop, wherepdp.solve(plan)used to leave the caller's unassigned pool for the search to route.request_group_costanswers the move previews since it counts withoptimaru::GroupPlacement, and answers them piecewise for a plan without groups; the default set still applies every move, because its three request-coupling constraints do not preview. - Pickup and delivery notebook re-run on 0.4.2.
examples/pickup-delivery.ipynbis saved with outputs from optimaru 0.4.2: the same problem now ends at 5.2 hours of driving, where 0.4.1 ended at 5.4. Its rounds of more search are 10,000 steps each (were 0.3 seconds), because 0.4.2 settles within one 0.3-second round and both lines of the chart stayed flat. - Benchmarks: the projects pin external-solver
v0.2.3. That release lists the engine's newrequest_group_costamong the pickup-delivery constraints the CP-SAT model has no plugin for (selecting it there is an unknown-constraint error, as withrequired_vehicle_cost); its models are those ofv0.2.2, so no published result moves. The benchmark projects' lock files record optimaru 0.4.2. Six of the projects (conference scheduling, food packaging, meeting scheduling, order picking, sports league scheduling, task assigning) had no[build-system]table, so uv did not install them and the commands their READMEs give (uv run <slug>-compare,uv run pytest -q) did not run; they have the table the other fifteen have now, and declare pytest in adevdependency group, so a plainuv syncinstalls it.tests/test_layout.pyholds every benchmark project to a[build-system]table and to one external-solver tag, and the links into external-solver to that tag. - Layout and names: one form for what every use case has. No behavior changes.
- The C++ quality benches left the package tree:
optimaru/<use case>/cpp/bench/is nowbenchmarks/<slug>/cpp/<ns>_quality_bench.cpp(bed allocation, conference scheduling, meeting scheduling, school timetabling; conference scheduling's file wasquality_bench.cpp), next to the comparison it belongs to, as the C++ tests are undertests/<use case>/cpp/. The bench targets and their binaries' paths underbuild/are the same. A use case'scpp/holds onlyCMakeLists.txt,bindings.cpp,include/andsrc/. - School timetabling's C++ tests carry the use case's prefix like every other target:
st_canonical_test,st_canonical_plugin_test(werecanonical_test,canonical_plugin_test; files, targets and ctest names). - Semiconductor scheduling's tests use the names the other use cases' tests use:
fixtures/web_demo.json(wasdata/web-demo.json) andcpp/fab_fixtures.hpp(wasfab_test_support.hpp). - Three benchmark projects are named after their use case like the other seventeen
that run an external-solver model:
flight_crew_scheduling_cpsat,project_job_scheduling_cpsatandsports_league_scheduling_cpsat(wereflight_crew_cpsat,project_job_cpsat,sports_league_cpsat), with the commandsflight-crew-scheduling-compare,project-job-scheduling-compare,project-job-scheduling-public-benchandsports-league-scheduling-compare.scripts/publish_benchmarks.pyno longer keeps a table of exceptions for them. - Every benchmark project declares pytest in the
devdependency group. Ten declared it as an extra and school timetabling's CP-SAT project in a group namedtest, so a plainuv syncthere installed no pytest anduv run pytest -qcould not start. The READMEs and CI now sayuv syncwithout--all-groups --all-extras/--extra dev. - Guide titles: the use case's name in sentence case, without "(C++ / Python)"; every
python.mdis# optimaru.<use case> (Python); sixcpsat/README.mdtitles follow the other nine (<Use case> CP-SAT). tests/test_layout.pyholds thecpp/contents and thedevgroup.
0.4.2¶
- Pickup and delivery: request groups. Requests that share a
group(DeliveryModel.group, a name;Delivery.group_indexon a plan) are one job: they ride one vehicle together, or all stay unassigned. Their stops stay ordinary stops, visited in any order between other requests' stops. The new constraintrequest_group_cost(hard, weight 1000, flippable) counts the grouped requests that are not where most of their group is. Construction and the request moves place a group as one unit, each request at its cheapest slot pair once the earlier ones are in, and leave all of it unassigned when no single vehicle has room; the pair move, the pair exchange and the pair ruin stay inside a group. Arequired_vehicleon one request, a pinned stop or a request already on an initial route binds the whole group to that vehicle, and two requests of a group bound to different vehicles (by a required vehicle or a pinned stop) are refused.solve_requestscores groups whenever a request names one, and so doespdp.solve(plan)for a plan with agroup_indexset (both then score the whole default set). Engine-only: the CP-SAT reference does not readgroup.list_constraints()andconstraint_info()have one more row, beforeunassigned_requests_cost. A plan without groups is solved exactly as before. - Engine:
MemberChangeGlobalConstraint. A global constraint that keeps its aggregates from joins and leaves alone derives fromoptimaru::MemberChangeGlobalConstraint<Solution>(optimaru/score/decomposed_objective.hpp) and writeson_member_changed()only; ten use cases declared that base themselves. The comment that opens each use case'sconstraints/common.hppnow holds what is particular to the use case and points to the engine header anddocs/extending.mdfor the rest. No score changes. - Bindings: the part every use case repeated is two engine helpers.
optimaru::python::bind_constraints()bindsconstraint_costs(),list_constraints()andconstraint_info()off a default assembly, andbind_score()(optimaru/python/score_binding.hpp) binds theScoreclass of the engine's two score types. The Python functions, their arguments and their results are the same; the docstrings of_core.constraint_costsand_core.list_constraintsare now the same text in every use case. - Engine: the three-level score is one type.
optimaru::HardMediumSoftScore(optimaru/score/hard_medium_soft_score.hpp) replaces the identicalScorestructs that bed allocation, food packaging, project job scheduling and vehicle routing each declared, withto_engine_score(),to_engine_score_limit()andfrom_engine_score()for the fold into the engine's two levels. Each use case'sScore,toEngineScore()andfromEngineScore()keep their names and results.kNoLevelFloormoves tooptimaru/score/levels.hpp. Nothing changes in Python. - Pickup and delivery: the search works in whole requests. Three new move operators take
a pickup and its dropoff out of a route together and put them back together, at the
cheapest feasible slot pair, so the acceptor is offered plans with every request whole
instead of split ones to reject.
requestRuinRecreatetakes 1 torequest_ruin_max_requestsrequests out (random, related, the costliest, one route's, or adjacent stretches of nearby routes) and reinserts them in random order or by regret, with blinking; requests waiting unassigned join the reinsertion.bundleRelocatemoves up tobundle_max_requestsrequests whose pickups follow each other on a route to one other route, andbundleExchangeswaps two such bundles. A slot pair is checked in O(1) from a per-route timeline (departures, latest feasible arrivals, loads), against the capacity, the time windows and the vehicle limits that are set (max_end_time,max_route_duration,max_travel_time,max_stops, pinned stops, a required vehicle). Construction uses the same scan, so the first plan keeps those vehicle limits too (it checked capacity and time windows only).SolverConfiggainsrequest_ruin_recreate,request_ruin_max_requests(20),bundle_movesandbundle_max_requests(3); the two switches are on by default, so a seeded solve no longer walks the path it did, and the two counts refuse a value below 1.pdp_demo's control flag is--stop-moves-onlynow (it was--no-pair-moves) and turns every request-level operator off. Both results blocks ofbenchmarks/pickup-deliveryare measured again (30 s, seed 0). On the 56 Li & Lim instances the engine's mean distance goes from 7.5% above the best known to 0.8% below it (the harness minimizes distance only, so a plan with more vehicles can be shorter than the best known), the worst instance from +22.0% to +2.4%, the instances more than 1% above from 43 to 2, and the vehicles used from 485 to 409 (best known: 402). The generated instances of 25 to 400 requests come out 2% to 10% shorter. - Engine (C++): features no use case used are removed. Gone from the engine headers: the
chain solution shape (
Shape::Chain,ChainObjective, the chain overload ofSolver::solve(), thechain::link helpers),WeightedObjective,explain_score(),rescore()andScoreBreakdown, background solves (solve_in_background(),BackgroundSolve) and derived state (DerivedState,Solver::add_derived_state(), the fourth argument ofEditor). None of the 22 use cases used any of them, so the Python package does not change, and a seeded, step-limited solve gives the same result as before. What a C++ caller uses instead:DecomposedObjective::constraint_totals()for the score per constraint, andSolver::solve()on a thread of its own, stopped withrequest_stop(), for a solve in the background. - School timetabling benchmark: the CP-SAT package keeps only what the benchmark runs.
benchmarks/school-timetabling/cpsatstill carried parts of the application it came from that no benchmark and no test of the model used: a workbook importer, timetable and school-system exports, a timetable inspection report, a sample workbook, and settings read from environment variables. They are removed (about 2,250 lines) with the two dependencies only they needed (openpyxl,pydantic-settings). The model, its constraints and the three benchmark tracks are unchanged. - More instances in every engine-vs-CP-SAT comparison. Each of the 17
comparisons on generated or demo instances now runs a ladder of five to
seven instances of growing size, 99 in all (was 38), and every results
block is measured again. The smallest rungs are ones both solvers finish;
on the largest the exact model often returns nothing within the budget,
and the tables say so.
benchmarks/README.mdnow states how a CP-SAT run is timed: the 60 s stop past the budget, and the level-by-level solve of the models whose score does not fit one 64-bit objective. - Conference scheduling, maintenance scheduling, meeting scheduling, sports
league scheduling and task assigning had only their demo data. Their
benchmark.pyhas a seeded generator in the shape of that data, and the demo instance stays as one rung. Food packaging runs its demo generator at six sizes. - The benchmark projects pin external-solver
v0.2.2(wasv0.1.0; the models are the same). Its level-by-level solve used to end without a solution when the first level found none in its share of the budget (10 s of 30 s with three levels); the first level now keeps the time that is left. Two rungs whose whole result was that early end, the 4-line plant of food packaging and the 240-task instance of task assigning, are back in their ladders, and the five comparisons that use the level-by-level solve (conference scheduling, food packaging, meeting scheduling, task assigning, tournament scheduling) were measured on that release. - The comparison runner takes
--solver engineor--solver cp-sat, so the single-threaded engine runs and the CP-SAT runs can be measured side by side. The publisher joins the two files (compare/<slug>.engine.json,compare/<slug>.cp-sat.json) after checking that they belong together, and refuses a comparison that lacks a run of either solver. Every result records its seed and workers. pickup-delivery-public-benchandproject-job-public-benchtake--out FILEand rewrite it after every instance, so an interrupted sweep keeps what it measured.- The publisher refuses a routing file that was run on chosen instances
(
--only) or whose two series used different seeds, and publishes a pickup-delivery file of one backend with the other as not run. - The SALBP details workbook must name its columns: a missing header is an error, no longer a fallback to fixed columns.
- A parallel start that reaches the target stops the others. With
parallel_solver_countabove 1 and a target (stop_at_first_feasible,best_score_limit), each start used to stop on its own, sosolve()returned only when the slowest start had reached the target or run out the time limit. Now the first start to reach it ends the run: the others stop at their next step and hand over their best so far, and the best of all starts is returned. That solution can score lower on the levels below the target than the best of all starts run to the end did, which is what the earlier return costs. Which start gets there first depends on the threads, so in that combination the same seed can give a different solution from run to run; without a target, or with one start, a seeded solve is as reproducible as before. C++: the same holds forSolver::solve_multistart()andoptimaru::solve_parallel_starts(). - Benchmarks on whole public data sets. The public-instance harnesses now run
whole sets or stated samples instead of a few instances, and every results
block is measured again on 0.4.1: CVRPLIB Set X (all 100) and Augerat's Set A
(all 27), the Li & Lim PDPTW set (all 56, beside the best-known solutions),
RG30 Pat1–Pat5, Falkenauer bin packing (three per class), QAPLIB (the 33
instances with 30 to 50 facilities) and SALBP-1 (five per data set).
scripts/publish_benchmarks.pywrites those tables and one homepage entry per data set. What changed in the harnesses: - Vehicle routing. Set X does not fix the fleet, and the best-known solutions
of 22 of its instances use more routes than the
-kNof their name, which the harness used as the fleet. Every backend now gets a fleet that cannot bind on Set X (30% above the capacity lower bound, plus three); Set A keeps-kN.--series aruns Set A and--only NAMEpicks instances of a series. - Pickup and delivery. One Li & Lim unit is ten seconds instead of one, so
travel is rounded to a tenth of a unit and a request of the
lrandlrcclasses can no longer be left out for free (their 10-unit service time was under a whole service minute).--instance,--requestsand--syntheticrepeat,--allruns the archive (whole instances unless--requestsis given),--jsonprints the results with each run's outcome, and the engine runs single-threaded whatever--workerssays, as the READMEs stated. - Project scheduling. The RG30 archive is checked by the SHA-256 of its five
instance files: the archive itself is rebuilt upstream, and the pinned archive
checksum no longer matched.
--all, a repeatable--instanceand--jsonare new, and the engine runs single-threaded there too. - Quadratic assignment.
--allstopped atkra30a: the harness re-scores each QAPLIB reference permutation and read every solution file as the facility of each location, while four files list the location of each facility. Both readings are tried.kra32's file states 88900 while its permutation scores 88700, which is recorded as an erratum; any other mismatch still stops the run. - Bin packing.
--sample-per-class Npicks N evenly spread instances of each Falkenauer class. - Assembly line balancing. The best-known values of the medium (n=50) data sets were read from the wrong columns of their details workbook, which has one more column; the columns are now found by their headers.
- Meeting scheduling:
parallel_solver_countruns that many starts. It was ignored: the solver set the engine's start count and then called the engine's single-start entry point, sosolve(..., parallel_solver_count=4)searched once, on one thread. It now runs the engine's multi-start, as the other use cases do: start i searches withrandom_seed + iand the best score wins. A solve with one start, and one withconstraints=...(always single-start), returns what it returned before. - C++: every
Solver::Configfield is snake_case, and the common ones come from a shared base (breaking for C++ callers). AConfigmixedtime_limitandseedwithparallelSolverCount,ruinRecreateMaxRuinCountandnearbyProbability; every camelCase field is now snake_case (parallel_solver_count,ruin_recreate_max_ruin_count,nearby_probability, ...). The fields each of the 22 use cases declared for itself (the limits, the seed, the parallel starts, the score checks,on_new_best, and the ruin & recreate knobs) are declared once, inoptimaru::SolverConfigBase<Score>andoptimaru::RuinRecreateConfigof the newoptimaru/solver_config.hpp, which also holds what every solver did with them:check_config(),settings_from()andsolve_parallel_starts(). A use case'sConfigderives from the bases and declares only its own knobs. Python is not affected: everySolverConfigkeeps its attributes and their defaults, and a seeded solve walks the same path. - Maintenance scheduling:
SolverConfiggainsruin_recreate_as_move_weightandruin_recreate_as_move_max_ruin. The C++ solver already had the two knobs (destroy-and-repair as an ordinary move judged by the acceptor; 0, the default, turns it off), but Python could not set them. - Semiconductor scheduling: a wrong problem type is a
TypeError.solve(),calculate_score(),constraint_costs()andconstraint_items()raisedAttributeErrorfor a value that was neither aSemiconductorSchedulenor amodels.SemiconductorScheduleModel; they now say which two types they take, as the other use cases do. - Flight crew scheduling ignores
FCS_*environment variables. Three overrides a tuning session left in the solver (FCS_DESCENT_WEIGHT,FCS_ASMOVE_WEIGHT,FCS_ASMOVE_MAXRUIN) are gone. - Engine (C++): unused settings removed.
AcceptanceSettings::rrt_steps,rrt_exponentialandrrt_compare_to_bestwere set by nothing; record-to-record travel keeps the schedule it always ran, linear against the best score.Solver::clear_stop()is gone too: a stopped solver stays stopped. - Notebooks. The notebooks in
examples/are saved with outputs from optimaru 0.4.1 again. The conference-scheduling notebook read ahardkey thatconstraint_costs()no longer returns and did not run; a few sentences that named a result the outputs no longer show are reworded, and the food-packaging rounds use 50,000 steps. - Importing a use case imports its models. In 15 use cases
import optimaru.<use case>leftoptimaru.<use case>.models, and with it pydantic, for the first call that needed a model. They now import it with the package, asassembly_line_balancing,bin_packing,knapsack,max_cut,pickup_deliveryandquadratic_assignmentalready did (school timetabling, whosesolve()takes dicts, still does not). pydantic is a dependency ofoptimaru, so nothing new has to be installed; the first import of one of the 15 takes about 35 ms longer (vehicle_routing15 ms to 48 ms,employee_scheduling25 ms to 72 ms, measured withpython -X importtimeon one machine), which is the time the first model call used to take. On the package,with_initial_solution(andvehicle_routing.solve_request) is now themodelsfunction itself, with its docstring and annotations, instead of a wrapper around it. - A star import of five modules binds their own names only.
modelsinknapsack,max_cut,quadratic_assignmentandsemiconductor_scheduling, andemployee_scheduling.helpers, had no__all__, sofrom ... import *also bound the names they import (pydantic'sBaseModelandField, for example). They now list their own classes and functions, as the other modules do. Every__all__in the package is sorted.
0.4.1¶
- One
solve()for every use case (breaking for seven).optimaru.<use case>.solve(problem, ...)now exists in all 22, takes the same keywords (time_limit_seconds,random_seed,parallel_solver_count,stop_at_first_feasible,full_assert,on_new_best,config,constraints) and returns the solved problem, with the score on it. - Breaking: in
assembly_line_balancing,bin_packing,facility_location,knapsack,max_cut,quadratic_assignmentandsemiconductor_scheduling,solve()returned theScore. It now returns the problem it was given: writeuc.solve(problem).scorefor a compiled problem, or readscore_hard/score_softfrom the solved pydantic model. - Breaking: given a pydantic model,
solve()inassembly_line_balancing,knapsack,max_cut,quadratic_assignmentandsemiconductor_schedulingwrote the result into that model. It now returns a new solved model and leaves the one passed in as it was, as the other use cases do: writemodel = uc.solve(model). Code that keeps reading the model it passed in does not fail, it reads the unsolved values. (calculate_score(model)still fills in the score fields of the model it is given.) - New:
solve()inbin_packing,conference_scheduling,facility_location,food_packaging,maintenance_schedulingandsports_league_schedulingalso takes the use case's pydantic problem model and returns a solved model, as the others do. (Employee scheduling, order picking, pickup & delivery and vehicle routing keepmodels.solve_requestfor their request models.) - New:
solve()inemployee_scheduling,pickup_deliveryandvehicle_routing; thefull_assertkeyword in the 15 use cases whosesolve()lacked it;SolverConfig.full_assertin those three andSolverConfig.parallel_solver_countinemployee_scheduling. - Stricter:
SolverConfiginpickup_deliveryandvehicle_routingrejectsparallel_solver_count <= 0andlate_acceptance_size < 0, and in those two andorder_pickingaruin_recreate_rewardslist that does not hold exactly 4 values, with theValueErrorthe other use cases raise. - Engine: repeated instances in
ConstraintAssembly. A by-name edit or lookup (weight(),level(),hard(),soft(),exponent(),offset(),clip(),find(),drop(), andadd()'s replacement) of a name the assembly holds several times now throwsstd::invalid_argument. It used to touch the first instance only, soweight("x", 0)afteradd_instance()left the second instance in the score. New overloads take the instance, counted from 0:weight(name, instance, w)and the same for the other setters,find(name, instance)anddrop(name, instance).instance_count(name)says how many there are anddrop_all(name)removes them all.find(name)throws for such a name as well, where it used to return the first instance;contains(name)never throws. A name held once behaves as before, and so does the Python API, which never edits a repeated name. - Engine: repeated picks share the raw cost. The second and later picks
of a constraint used to run its cost and delta code once more each. They
now join as repeats (
ConstraintAssembly::add_repeats(), which the Python bindings use), andDecomposedObjectiveasks one instance of a unit constraint per unit and shapes the answer for each pick. Scores do not change. A vehicle-routing solve withTravelTimeCost()andTravelTimeCost(exponent=2)took about a quarter more steps per second, and one with a third pick atexponent=3about half more (400 visits). Picks are still computed separately when the engine handles them differently (one with a negative threshold next to one without), for constraints with domain parameters (employee scheduling), for the members of a compiled delta group, and for global constraints.add_instances()keeps independent instances. - Docs: the cost of a negative threshold. The guides now say that a
negative
offsetwithclip=True(a fixed charge per non-zero unit) is recomputed for every unit a move changes, which about halves the steps per second of a vehicle-routing solve. - Docs and messages. The guides, docstrings and comments describe each use
case in its own terms and no longer compare it with the examples it was
derived from. Two
optimaru.project_job_schedulingerror messages changed wording with them (a non-renewable global resource, a standard job with no execution mode). No behaviour changes. - Repository layout. The source tree now has the shape of the package it
builds.
optimaru/is the one Python package. The engine headers moved frominclude/optimaru/tooptimaru/cpp/optimaru/(the include path stays#include "optimaru/..."), and each use case moved fromuse-cases/<slug>/{cpp,python}into its subpackageoptimaru/<use case>/, with its C++ inoptimaru/<use case>/cpp/. Tests moved totests/(engine, shared constraint base, one directory per use case), and the guides todocs/. The standalone per-use-case packages (vrp_routing,st_timetabling, ...) and their 22 copies of the constraint-spec base are gone: everything importsoptimaru.<use case>.setup.pyfinds the use cases and their sources itself. The installed package and its API do not change. - License. A new
THIRD-PARTY-LICENSESfile ships in the wheels and the sdist. It carries the notices and license texts of the C++ runtime libraries that the wheel repair tools bundle into the musllinux wheels (libstdc++ and libgcc, GPL-3.0-or-later with the GCC Runtime Library Exception) and the Windows wheels (the Microsoft Visual C++ runtime). The 0.4.0 wheels bundle the same libraries without it. - Builds. One
uv syncat the root builds every extension in place, and one CMake project (cmake -B build) builds the engine and every use case's C++ tests.OPTIMARU_USE_CASESnarrows either build to some use cases. - Docs.
docs/extending.mdis a step-by-step guide to adding a move or a cost, and a documentation site (MkDocs, with an API reference generated from the sources) is built fromdocs/and published on GitHub Pages. The engine layout in the README lists every directory.CONTRIBUTING.mdand a section near the top of the README give the short version of adding a constraint or a move and link to the guide. - Bindings. The part of
SolverConfigthat every use case shares (the limits, the seed,parallel_solver_count,late_acceptance_size,full_assert,ruin_recreate_rewards) is bound by one helper,optimaru::python::bind_solver_config, instead of 22 copies. Names, defaults and error messages are unchanged. - Engine internals. The step loop (
search/local_search.hpp) and the decomposed objective (score/decomposed_objective.hpp) are shorter: the move mix, the kick's polish loop and the adaptive selectors share one sampling and scoring path, the score levels fold in one place, and the built-in per-constraint profiler (the undocumentedES_PROFILEenvironment variable) is gone; use a sampling profiler instead. A seeded, step-limited solve gives the same result as before. Two source-incompatible changes for C++ code that includes the engine headers:ListMove::Kindenumerators are PascalCase like every other engine enum (Kind::Segment,Kind::TailSwap, ...), andGreedyRepair::candidate_countis replaced byruin_candidate_count. - Initial solutions.
with_initial_solutioninoptimaru.flight_crew_schedulingandoptimaru.project_job_schedulingraisesValueErrorfor a problem that repeats an id, like the other use cases.
0.4.0¶
First release.
- Python package.
pip install optimaruinstalls one package with every use case as a subpackage (optimaru.vehicle_routing,optimaru.school_timetabling, ...), as prebuilt wheels for Linux, macOS and Windows on Python 3.11 and later. No C++ toolchain is needed. - Engine. A header-only C++17 metaheuristic engine under
include/optimaru/, with no dependencies and no domain code: - three solution shapes (assignment, sequence and chain) and derived state kept up to date around every write;
- incremental scoring with
Score(int64 hard, double soft), written as anObjectiveor summed from named components (WeightedObjective,DecomposedObjective); - construction heuristics (first fit, first fit decreasing, cheapest insertion), acceptors (hill climbing, late acceptance, entity tabu, simulated annealing, great deluge, step counting hill climbing, record-to-record travel) and assignment and sequence moves mixed by weight;
- nearby selection and adaptive ruin and recreate (random, related, worst, SISR and route ruin with regret-k recreate);
- stop conditions on wall time, stall time, steps, stall steps and a target
score; multi-start solves and background solves (
solve_in_background()) that report status, stop on request and rethrow a failure fromwait(); - score explanation (
explain_score(),rescore()) and a full-check mode (ScoreChecks::Full) that compares every incremental score with a full recompute. - 22 use cases, each a C++ domain with a pybind11 Python package, tests and
a README: assembly-line balancing, bed allocation, bin packing, conference
scheduling, employee scheduling, facility location, flight crew scheduling,
food packaging, knapsack, maintenance scheduling, max-cut, meeting
scheduling, order picking, pickup and delivery, project-job scheduling,
quadratic assignment, school timetabling, semiconductor scheduling, sports
league scheduling, task assigning, tournament scheduling and vehicle routing.
Each package builds and tests on its own from
use-cases/<slug>/python. - Constraint contract, the same in every use case:
- every constraint is one named component (
<Subject>Cost, Python name<subject>_cost) whose raw cost is 0 when nothing is violated; constraint_info()lists the constraints with their default weight and level;constraint_costs()returns the raw per-unit costs of a solution, and theconstraints.score()helper re-prices them under any selection without solving again;- each pick takes five knobs:
weight,level("hard","medium"where the use case has a medium level, or"soft"),exponent, andoffset/clip, which shift the shaping per unit as a threshold (max(0, x - offset) ** exponent) or as the literal(x - offset) ** exponent; - a constraint may be picked several times, each instance with its own knobs and parameters; the instances add up;
- guards keep scores meaningful: rewards never go hard, the literal offset formula and raw costs that can be negative stay off the levels that count toward the hard score, structural constraints keep their level, and the hard total saturates instead of wrapping.
- Examples. One Jupyter notebook per use case in
examples/, with visualizations. - Benchmarks. Every use case but vehicle routing is compared with OR-Tools
CP-SAT on the same instances and rescored by the use case's own evaluator;
vehicle routing is compared with the OR-Tools Routing solver on CVRPLIB Set X.
The CP-SAT models come from the separate
external-solver repository,
except school timetabling's, which stays in
benchmarks/. Pickup and delivery, project-job scheduling, bin packing, quadratic assignment, assembly-line balancing and vehicle routing also run on public instance sets (Li & Lim, RG30, Falkenauer, QAPLIB, SALBP, Augerat), downloaded on demand as SHA-256 pinned files. - License. Apache License 2.0. NOTICE states that the engine is a modified derivative of Timefold Solver (itself derived from OptaPlanner and OptaPy), lists the use cases and benchmark harnesses derived from Timefold Quickstarts, and includes pybind11's BSD-3-Clause license, which the compiled extensions embed.