Changelog¶
0.12.0¶
From 0.11.0. Vehicle routing gains several time windows per visit, driver breaks
(vehicle_break_cost) and extra capacity dimensions such as weight and volume
(vehicle_capacities_cost). Nothing is renamed or removed: a plan without the new fields is
solved as before.
- Vehicle routing: several time windows per visit.
VisitModel.time_windows(Visit.time_windowson a plan):[start, end]pairs in time order, given instead ofmin_start_time/max_end_time. A vehicle is served in the first window whose end it can still meet, waiting for it to open; a visit that meets none is late against the last (max_end_time_cost). - Vehicle routing: driver breaks.
VehicleModel.breaks(vrp.Break(earliest_start, latest_start, duration)inVehicle.breaks): each break goes on a leg of the route, while waiting at a visit when it fits there whole, otherwise before driving on, which moves the later arrivals, the route end and every limit on it. New hard constraintvehicle_break_cost(weight 1): the minutes a break starts after itslatest_start.RouteSolution.breaksreports the breaks each route takes (BreakStop:break_index,start_time,duration,position),VehicleMetrics.break_secondstheir total;Vehicle.break_start_timesandVehicle.break_positionson a solved plan. - Vehicle routing: capacity dimensions.
VehicleModel.capacitiesandVisitModel.demands(Vehicle.capacities,Visit.demands): extra dimensions such as weight and volume besidecapacity/demand. New hard constraintvehicle_capacities_cost(weight 1): the demand above each capacity, added over the dimensions. Every vehicle lists the same number of capacities. - A plan with a visit of two windows or more, a break or a capacity dimension is scored on the
default constraints by every entry point, as a plan with visit groups is; a plan without them is solved as before. Vehicle routing now has 21
constraints;
vehicle_capacities_costandvehicle_break_costare engine-only (no CP-SAT plugin).models.vehicle_metricstakes the breaks as a third argument (None reads them off the plan) and counts the wait for a later window inwaiting_seconds(a break taken during the wait counts inbreak_secondsinstead).
0.11.0¶
From 0.10.1. Breaking: the SolverConfig groups alns_trigger and alns are renamed
perturbation and ruin_recreate (a request's solver_parameters follows). The engine headers
moved into folders by role (insert/, search/strategies/, search/ruin/,
search/perturbation/, search/move_mix/). Container loading gains an opt-in shipping cost by
billed weight.
- Breaking:
SolverConfiggroupsalns_triggerandalnsare nowperturbationandruin_recreate.perturbationholds when a stalled search is kicked and how large the kick is (enabled,unimproved_steps,min_ruin_fraction,max_ruin_fraction,max_ruin_count,polish_steps);ruin_recreateholds what every ruin & recreate shares, the kick and the strategies that ruin alike (operator_decay,rewards,selection_type, the ruin switches such assisr_ruin/route_ruin/request_ruin,regret_k,blink_rate, ...). A request'ssolver_parametersand a JSON config use the new group names; the old ones are refused. In C++,AlnsTriggerSettingsandAlnsSettingsarePerturbationSettings(Settings::perturbation) andRuinRecreateSettings(Settings::ruin_recreate). Measured before the rename: switching the kick off loses in eight use cases (school timetabling, flight crew, meeting, sports league, conference, task assigning, maintenance, pickup & delivery), so it stays, under its own name. - Engine layout, by what each part does. The engine headers moved into folders that follow a
solve (includes change, behaviour does not):
insert/(what building and rebuilding a solution share:placement.hpp, one element at its best place, andrepair.hpp, the formersearch/ruin_recreate/greedy_repair.hpp),search/moves/(the small moves only),search/move_mix/(move_mix.hpp,move_draw.hpp),search/strategies/(strategies.hppand the built-in strategies: descent, ejection chain, iterated local search, granular local search, route elimination, ruin & recreate as a move),search/ruin/(the ruin operators,pool.hpp,count.hpp,removal_gain.hpp; the_ruinsuffix is dropped) andsearch/perturbation/(stagnation_kick.hpp, the formersearch/ruin_recreate/kick.hpp).search/moves/preview_evaluation.hppis nowsolution/preview_evaluation.hpp. A C++ caller that includes one of the moved headers changes the path. - Container loading: shipping cost by billed weight. A new opt-in soft constraint,
shipping_cost(ShippingCost, weight 0 by default, so every request that was valid before solves exactly as before): per container holding a placed item, the price in the rate table of its zone of its billed weight, max(placed weight +tare_weight, ceil(volume /dim_divisor)). The search sees it like the other per-container costs (from the shared decode, per container changed), so packing cartons optimises the exact freight of what is packed, not an estimate. - New inputs: container
dim_divisorandzone(also on a type with aquantity), and the problem'srate_tables, the shape of box sizing's ([{zone, breaks: [{max_weight, price}]}], one table per zone, breaks strictly ascending; zone None = the table for the containers without one). Every container's zone needs its table. - Above the top break: refused before the solve. A container whose billed weight could pass
its table's top break (its dimensional weight, or the weight of the items allowed in it,
at most its
max_weight, plus its tare) raisesValueErrornaming themax_weightthat would do. Only a load above itsmax_weight(already acontainer_weight_cost) can then pass it, and is priced at the top break. - New outputs:
billed_weightandshipping_coston every container and on every instance of a type (billed_weightwhen it has adim_divisoror there are rate tables,shipping_costwith rate tables), and the problem's totalshipping_cost. Compiled objects:RateTable,RateBreak,Container.dim_divisor,zone,billed_weight,shipping_cost,ContainerLoadingProblem.rate_tables. - With
shipping_costpicked with a weight and rate tables,SwitchContainerMoveand the construction's order of the empty containers compare containers by theircostplus the weighted shipping price of the load in them (a carton that costs more but bills less is a target); otherwise bycostalone, as before. - The parameter check asks for
shipping_costwhenrate_tables, adim_divisoror azoneis set (atare_weightwith rate tables: it oraxle_load_cost). The CP-SAT model and evaluator ofbenchmarks/container-loadingrefuse those inputs.
0.10.1¶
From 0.10.0. Container loading's unloading options for vehicle loads, all off by default:
items unloaded by hand, a reach policy, stop zones (the new hard constraint stop_zone_cost), and
the pairs left reported per container as unloading_violations. A request that sets none of the
new inputs solves and scores as on 0.10.0.
- Container loading: unloading options. New inputs for vehicle loads, all off by default (a request that sets none of them solves and scores exactly as before):
- item
manual_unload: a parcel light enough to be lifted off by hand is not counted in the way of an earlier stop's item it stands on; - the problem's
unloading_policy("strict", the default, or"reach") withreach_length: under"reach", a later stop's item that lies wholly withinreach_lengthof an earlier item's door-side face is not counted in its way; - the problem's
stop_zones([{"unload_order": 1, "length": 1200}, ...], door side first; the last zone reaches back to the closed end), scored by the new hard constraintstop_zone_cost(the placed items that reach outside their stop's zone; the 16th of this use case). The decoder treats a place outside the zone like one that blocks. - Every container (and each of a type's
instances) reports the pairs left asunloading_violations({"item", "blocks", "kind": "door" | "top"}), the pairsunloading_order_costcounts, so a worker app can warn about them. The CP-SAT comparison refuses instances that set the new inputs.
0.10.0¶
From 0.9.0. Container loading takes the rules of real loads, every one optional and off by
default: vehicle loads in stop order (a decoder that weighs what it breaks, StopOrderMove,
nearby selection by stop), stacking rules and a centre of gravity limit, priorities, optional
items and group rules, allowed containers and segregation, axle loads, and container types with
a quantity (a solved model reports the copies used in the type's instances). Box sizing gains
two opt-in soft costs, board area and shipping cost by billed weight. The documentation site has
a version menu. A request that sets none of the new inputs solves as it did on 0.9.0, except
that container loading's vehicle loads now decode differently when items set unload_order or
max_load_on_top.
- Container loading: container types with a quantity. A
ContainerModeltakesquantity(1 by default, as before; n = up to n alike; None = as many as needed, by a rule of thumb), so a carton catalog or a fleet lists each type once; the engine gets the copies (id#1,id#2, ..., tagged with the type's id) and the solved model reports the used ones in the type'sinstances. A warm start takesinitial_instances;with_initial_solutionand solving a solved model go on from the instances. Listing copies still works. - Container loading: axle loads. Container
tare_weightandaxle_groups(two:id,positionfrom the closed end,max_load, optionalempty_load), the loads by the lever rule at departure and after each stop's items are unloaded, scored by the new hard constraintaxle_load_cost(the worst stage's excess) and reported per container asaxle_loads. - Container loading: allowed containers and segregation. Container
tagsand itemallowed_containers(ids or tags; [] = any, the decoder's: an item finds no place elsewhere), and itemsegregation_classwith the problem'ssegregation_rules({"a", "b", "distance"}: not in one container, or at leastdistanceapart in the floor plane), scored by the new hard constraintsegregation_cost. The decoder steers away from places closer than a distance; the construction tries only the allowed containers. - Container loading: priorities, optional items and group rules. New inputs, off by default:
item
priority(1 to 1,000,000, default 1: an unplaced item counts its priority inunplaced_item_cost), itemoptional(left out at a soft cost, the newoptional_item_cost, its weight out of the load; the decoder leaves it out where it would take the placed weight overmax_weight), and the problem'sgroup_rules({"id", "all_or_none", "single_container"}), scored by the new hard globalsincomplete_group_costandsingle_container_cost. The construction loads optional items after the others and higher priorities first. - Box sizing: board area and shipping cost by billed weight. Two opt-in soft costs, both at weight 0 by default, so every request that was valid before solves exactly as before:
board_area_cost(BoardAreaCost): per box,quantity x 2 (lw + lh + wh), the board of the boxes shipped.shipping_cost(ShippingCost): per box,quantity xthe price of a shipment's billed weight in the rate table of its zone. New input fields: boxdim_divisor(a parcel in the box bills at leastceil(box volume / dim_divisor)), parcelzone, and the problem'srate_tables(one per zone:zone, andbreaksofmax_weightandprice). The parameter check asks forshipping_costin the selection when any of them is set.- New outputs:
board_areaandshipping_coston the problem,billed_weightandshipping_coston every box (where weight is billed). Compiled objects:RateTable,RateBreak,Box.dim_divisor,Parcel.zone,BoxSizingProblem.rate_tables,board_area(),billed_weight_per_box(),shipping_cost_per_box(). - The construction and the moves price the sizes with the picked weights of both. A shipping
price depends on the parcel, so with a weight on
shipping_costthe parcels that pay alike in every box form a group with its own order of the boxes. - The CP-SAT model of
benchmarks/box-sizingtakesboard_area_weightandshipping_weight. - At the default weights the 20 benchmark instances give the published results, and step-limited solves take the same steps as before on both paths. On the same instances, billed (three zones, ten breaks), the search at 2 s ties CP-SAT's 30 s result (same objective, 4 workers) on 10 and 11 of 20 instances for two weightings and is ahead on the others; the plan of the least air pays up to 6.8% more freight (1.6% on average) than the plan the shipping cost picks. A shipping weight costs 8% to 29% of the steps per second.
- Documentation by version. The documentation site has a version menu:
latest/(the newest release),dev/(main) and one copy per release minor since 0.4, each linking to repository files at its own tag. The old addresses redirect tolatest/. - Container loading: stacking rules and a centre of gravity limit. New inputs, all off by default (a request that sets none of them solves exactly as before):
- item
bottom_only(only on the floor) and containermax_stack_height(how high the load may reach): the decoder's, no cost needed; - item
max_stack_layers(at most this many items in a column through it), itemstack_groupand the problem'sstacking_rules({"top": ..., "bottom": ...}: the top group may not stand on the bottom one), scored by the new hard constraintstacking_rule_cost(pairs against a rule plus layers above a limit); the decoder steers away from places that break them, as it does for load limits; -
container
max_offset_length/max_offset_width(how far the load's centre of gravity may lie from the centre, as a share of half the length or width), scored by the new hard constraintbalance_limit_cost(whole percent of the half size beyond the limit). Both constraints are scoped (constraint_costs()names theirunits), so a problem that does not use them pays nothing for them per move. The construction loadsbottom_onlyitems first, and it,EmptyContainerMoveandRepackPairMovekeep the stacking rules as they keep the load limits. The CP-SAT comparison refuses instances that set the new inputs. -
Container loading: the decoder weighs what it breaks, and a stop fills its depth first.
- When every place left for an item breaks an unloading order, a load limit or a stacking
rule, the decoder no longer takes the first one whatever it costs: it weighs the first place
that only blocks (the pairs it adds), the first that breaks a stacking limit (the weight
over each
max_load_on_top, a rule, layer limit or segregation distance, and its pairs) and leaving the item out (itsprioritytimesunplaced_item_cost's weight, oroptional_item_cost's for anoptionalitem), by the weights of the solve's constraints, and takes the cheapest (of equal costs, placing wins). At the default weights an item now stays out rather than block two earlier items or put more than one unit of weight over amax_load_on_top; with a warehouse system's weights (an unplaced item 1,000, a pair 10, 1 per gram) it still blocks up to 100 pairs, or overloads by up to 1 kg, rather than stay out; an optional item stays out rather than break anything hard. The weights are those of the last solve, kept on the problem forcalculate_score(the defaults on a problem never solved). - An item with an
unload_orderprefers, of the places that break nothing, one within the depth its stop's items already reach, so a stop fills the cross-section it has started before it goes deeper. - Faster decoding of vehicle loads and stacking limits: the unloading-order check looks only at the boxes of the cells that can block (each cell knows the lowest and highest stop of its boxes), and the loads passed down to limited boxes are added as each box is placed (and replayed in placement order when a decode resumes) instead of recomputed for every box.
On the generated trucks of container-loading-vehicle-loads (one thread, 30 s), the share
that meets every constraint is unchanged at the default weights (14 of 48 trucks over six
seeds) and about the same at a warehouse system's (15 → 13 of 48), but what is left is much
less: at the default weights no stacking excess and at most a few pairs remain (#174 left
up to 548 pairs per truck), and the unplaced boxes on the 250- and 300-box catalog trucks
and the 20-stop cut trucks fall from 10.8/48.0/50.7 to 7.0/36.7/17.3 per truck; at the warehouse weights the unplaced boxes there fall by
40–75%. The 15-stop catalog trucks reach hard 0 within 0.2 s where they took up to 5 s.
Loads without unloading orders, limits or rules are decoded exactly as before (the
benchmarks give the same results at the same speed). The demo with stacking limits runs at
34,000 steps per second as with #174; 0.9.0 ran it at 46,000 (the decoder now looks past
places that would overload a box). The decoder's weights are not part of the JSON model: a
model solved under other constraints is placed again as that solve placed it by a solve of no
steps with the same constraints.
- Container loading: vehicle loads in stop order. A cargo space with items for many stops often came back with hundreds of unloading-order pairs left. Four changes:
- The decoder judges a place by what it would break when items set
unload_orderormax_load_on_top: an item goes to the first point where it stands in no earlier stop's way, has no later stop in its own way and overloads no item below it (its weight passed down through what it stands on); failing that, to the first point that only breaks an order or a limit, weighed against leaving the item out (the entry above). An item with anunload_ordertakes the shallowest orientation along the length first, so a stop builds a thin wall. Without orders and load limits the decoder places every item where it did. - A new move,
StopOrderMove(custom_moves.stop_order, on by default when at least two items setunload_order, also for a single container): a loading order put back in stop blocks, latest stop first, with one change inside one stop's block. - Nearby selection by stop (
selection.nearby_probability, 0.8, andselection.nearby_size, 20, only when at least half the items have an unloading order): the move mix moves an item next to items of its own and the neighbouring stops, and a ruin-and-recreate kick tries only those places instead of every place of the list. - A faster decode for every use: the placed boxes are indexed along the length and by the height of their tops, and every free corner keeps how far the room reaches from it, so most corners are ruled out without a scan.
On generated trucks of 10 to 25 stops and 110 to 300 boxes (one thread, three seeds per row,
container-loading-vehicle-loads), the trucks that met every order and limit after 30 s went
from none of 24 to 8 of 24, at the default weights and at the weights a warehouse system sends,
and the pairs left at the default weights (the mean of three seeds per kind of truck) from
151–1,729 to 0–255. Loads without unloading orders or stacking limits are decoded exactly as
before (the benchmarks give the same results), at about the same speed, and twice as fast with
hundreds of items per container. With stacking limits the decode now also keeps weight off
them where it can. The guide's "How good, how fast" has the numbers.
0.9.0¶
From 0.8.0. Two new use cases, box sizing (optimaru.box_sizing, the 23rd) and container
loading (optimaru.container_loading, the 24th), and order picking on any warehouse layout (a
grid of any size, or named locations with a distance table). Breaking: some public names of
order picking (OrderPickingSolution takes a warehouse, calculate_distance a third argument,
LocationModel.column is a string; C++ op::Warehouse is an object), several C++ header moves
(model/ is solution/, no umbrella header, accept/ and select/ back at the top,
LocalSearch is Solver::run), and every random draw now goes through the engine's own
functions, so a seeded solve gives a different (equally good) result from 0.8.0's, and the same
draws on every platform.
- New use case: container loading (
optimaru.container_loading). Three-dimensional loading of boxes into containers: pallets and rack bays, a vehicle's cargo space in the order of its stops, an order's items into the cheapest cartons of a catalog. It is the 24th use case, and the first whose decision is not what the answer shows: every container has a loading order (the sequence shape), and a placement decoder derives where each item stands from it (extreme points; an item goes to the first corner, from the closed end, then up, then across, that takes it inside the walls, clear of the others and withmin_support_ratioof its base supported). Eight constraints:unplaced_item_cost,container_weight_cost,stacking_load_costandunloading_order_cost(hard),used_container_costandgroup_split_cost(soft), and the opt-inused_length_costandload_balance_cost(soft, weight 0). Items carryrotations(all,upright,fixed),max_load_on_top,unload_orderandgroup; containersmax_weightandcost. The constraints share one decode per container and list, and a list is decoded again only from where it changes. Search: first fit decreasing by decode, the sequence moves,EmptyContainerMove,RepackPairMoveandSwitchContainerMove(custom_moves.empty_container,custom_moves.empty_container_candidates,custom_moves.repack,custom_moves.switch_container). The JSON model ismodels.ContainerLoadingRequest/ContainerLoadingProblemModel(API slugcontainer-loading); the guide isdocs/use-cases/container-loading/, the notebookexamples/container-loading.ipynb.benchmarks/container-loadingcompares it, on instances whose fewest containers is known, with a CP-SAT model that places items freely; that model is kept in the benchmark project, and both answers are scored from where the items stand. - Engine: one ruin-count helper.
clamp_ruin_countinsearch/ruin/count.hppnow draws the ruin count of the destroy-repair move and the iterated local search;kick_ruin_countmoved there fromkick.hpp, which still includes it. Seeded results unchanged. - New use case: box sizing (
optimaru.box_sizing), the 23rd. Which box sizes should a warehouse stock? Every parcel (the packed content of one shipment, by its bounding size, with the number of shipments that had it) ships in one of the candidate boxes, at mostmax_box_typesdistinct boxes are in use, and the least air is shipped. A parcel fits a box when its sorted sides are each at most the box's (any rotation), and when it is not heavier than the box'smax_weight. Six constraints:parcel_fit_cost,box_weight_costandbox_type_limit_cost(hard),void_volume_costandbox_cost(soft), andbox_type_cost(soft, weight 0: picked with a weight, it is the fixed cost of stocking one more size). A box can berequired(already stocked: it counts as in use), a parcel that fits no candidate is refused by name, and the solved model carriesbox_types_used,void_volume,fill_ratioand the shipments per box. The search works on the set of sizes: a greedy construction (time_limit_seconds=0returns it), the movesCloseBoxMove,OpenBoxMoveandSwapBoxMove(custom_moves.close_box,open_box,swap_box), and late acceptance that starts over from just below its best when it stalls (acceptance.reheat). On the API the use case isbox-sizing. With it come the guide (docs/use-cases/box-sizing/), the notebookexamples/box-sizing.ipynb, andbenchmarks/box-sizing, whose CP-SAT model lives in that directory (box_sizing_cpsat.model) and which does not install external-solver. - Order picking on any warehouse layout. The layout was one fixed grid (columns A..E, shelving rows 1..3, rows 0..10 on a side); it is now input, in one of two kinds, and a request or solution without either solves exactly as before (same seeded results).
- A grid of any size:
warehouseonOrderPickingRequest(WarehouseModel:column_count5,shelving_row_count3,shelving_width2,shelving_height10,shelving_padding3, whole meters),op.Warehouse(...)on the compiled side. A location'scolumnis written as spreadsheet columns are (A..Z,AA, ...ZZZ). - Named locations with a walking-distance table, for a building that is no such grid:
locations(ids) anddistances({from: {to: meters}}) on the request, where thelocationof a trolley or an order item is then an id;op.Warehouse.from_distances(ids, table)andwarehouse.location(id)on the compiled side (a location belongs to the warehouse that made it: a solution of another one refuses it). The table may be asymmetric, a pair given one way only is as long the other way, and a pair given neither way is refused. At most 2048 locations in a request, 4096 in a compiledWarehouse. - One request uses one kind; mixing them is refused.
OrderPickingSolutiontakes a fourth argument,warehouse, and has the property of that name;calculate_distancetakes a third.PickStop.locationis aLocationModelor an id, as the request gave it. - A solve reads its distances from one location-to-location table for both kinds instead of computing each one (a grid: up to 2048 distinct locations in use; parallel starts share it), which makes the default layout faster: about 1.1x the steps per second on the demo and 1.4x on the demo at four times the size, same results.
WarehouseLocation(column, shelving_row, side, row)no longer checks its numbers against the default grid (it cannot know the warehouse): a location outside the grid is refused byOrderPickingSolution(...), bysolveand by what measures (calculate_score,distance_to_travel,constraint_costs,calculate_distance), with aValueErrornaming the trolley or pick task.LocationModel.columnis a string of 1 to 3 capital letters instead of a literalA..E, andshelving_rowandrowhave no upper bound of their own: the request checks them against its grid.- Breaking (C++):
op::Warehouseis an object (OrderPickingSolution::warehouse) and no longer a set of constants (Warehouse::COLUMN_COUNTisWarehouse::DEFAULT_COLUMN_COUNT, and so on);calculateDistance(warehouse, start, end)measures in a layout, the two-argument form in the default grid;calculateDistanceToTravelreturnsstd::int64_t. New:op/model/layout.hpp(makeGridWarehouse,makeNamedWarehouse,checkLayout,ActiveDistances). - On the optimaru API, a request that gives no layout is sent as before (it dumps without the three new fields). One that gives a layout is refused (422, unknown field) by an API that runs an earlier optimaru, until that API follows.
- The CP-SAT reference (external-solver) knows the default grid only, so the comparison in
benchmarks/order-pickingstays on it and another layout is engine-only for now. - Breaking (C++): the engine's
model/issolution/.core/optimaru/model/held how the engine reads and writes a use case's solution (SolutionTraits,Editor,ElementIndex,SolutionSnapshot,Neighborhoods), not a problem model, so it iscore/optimaru/solution/now:#include "optimaru/solution/editor.hpp"and so on, withOPTIMARU_SOLUTION_*include guards. A use case's ownmodel/(its domain and demo data) keeps its name. Nothing changes in the Python package or in what the solvers do. - Source layout: one file per stop criterion; a use case's own.
stop/holds each built-in criterion in a file of its own:max_runtime.hpp(MaxRuntime),no_improvement_time.hpp,max_steps.hpp,no_improvement_steps.hpp,target_score.hppandstop_requested.hpp, all reading theStopStateofstop_state.hpp.StopConditionassembles them fromLimitsin the order it always checked, still samples the clock in batches, and takes the time fraction or the step fraction, whichever is further, along with the progress of any added criterion, as the progress of the solve.Solver::add_stop_criterionadds aStopCriterion(stop/stop_criterion.hpp) of the use case's own, asked after the built-in ones, made fresh for every solve and every start of a multi-start run. Every seeded solve gives the same result as before.StopConditioncan no longer be copied (it may own added criteria). - Source layout: one file per construction heuristic; a use case's own construction.
construct/first_fit.hpp(assignment shape: first fit, first fit decreasing with a difficulty order) andconstruct/cheapest_insertion.hpp(sequence shape) hold the two heuristics,construct/initialization_order.hppthe order they share, andconstruct/construction.hppkeepsConstruction<Solution>::run, which picks by shape, andnothing_placed.Solver::set_constructionregisters a construction in place of the built-in one, for every start of a multi-start run; it gets the solve's seed (each start's own) to draw with. The built-in construction is unchanged: every seeded solve gives the same result. Breaking (C++):Construction<Solution>:: place_best_value,place_cheapest_insertion_full_scanandinitialization_orderare free functions (optimaru::place_best_value, ...). - The random draws are the same on every platform; every seeded result changes once. The
engine and the use cases drew through the
std::distributions andstd::shuffle, which libstdc++ (the Linux wheels, the API) and libc++ (the macOS wheels) implement differently, so the same seed and step limit could end differently on each, and the API's result could differ from a local solve on a Mac. Every draw now goes throughcore/optimaru/utils/random.hpp(random_index,random_int,random_unit,random_real,random_bool,random_normal,random_shuffle), written out by hand;tests/test_layout.pykeeps thestd::ones out and the engine test pins their first outputs. Floating-point arithmetic on top of the draws (std::expin simulated annealing, fused multiply-adds) can still differ in the last bit between architectures.random_indexof an empty range is 0, asPortableRandom::next_int's was, instead of a division by zero. Five calls that drew twice in their arguments, whose order is the compiler's, draw in two statements: the meeting-scheduling room pick, and demo data (vehicle routing, pickup and delivery, employee scheduling, flight crew). The search is the same; its random numbers are not, so a seeded solve gives a different (equally good) result from 0.8.0's, and the vehicle routing and pickup-delivery demo instances are other instances. The engine tests that checked one seed for something about half the seeds reach (LNS from a local optimum, kicks from a warm start) now count over ten seeds, and the vehicle-routing ALNS check over ten. - Breaking (C++):
movable_entity,apply_changeandapply_swaptake no distribution argument. - Source layout: one file per move. The ordinary moves of the move mix each have a file in
search/moves/:change.hpp,swap.hpp(assignment shape),relocate.hpp,element_swap.hpp,two_opt.hpp,or_opt.hpp,two_opt_star.hppandcross_exchange.hpp(sequence shape).move_mix.hppkeepsMoveMixSampler, which draws among them by weight, andmove_draw.hppholds what they draw with (SampledMove, the nearby pick). The granular descent of iterated local search,GranularLocalSearch, moves tosearch/strategies/granular_local_search.hpp. The draws are the same in the same order, so every seeded solve gives the same result;move_mix.hppanditerated_local_search.hppstill include what they used to provide. Nothing changes in the Python package. - Breaking (C++):
utils/holds what the engine's folders share.portable_random.hppmoves tocore/optimaru/utils/random.hppandworker_threads.hpptocore/optimaru/utils/worker_threads.hpp; the include guards follow (OPTIMARU_UTILS_RANDOM_HPP,OPTIMARU_UTILS_WORKER_THREADS_HPP). The top ofcore/optimaru/keeps the solver, its settings and its config. Nothing changes in the Python package or in what the solvers do. - Breaking (C++): no umbrella header.
core/optimaru/optimaru.hppis gone. It included a dozen engine headers for convenience, but only employee scheduling's bindings and the engine test used it; every other use case includes the headers it needs, and those two now do too. C++ that included it includes"optimaru/solver.hpp","optimaru/settings.hpp"and the others it uses. The directory map it carried is the engine tree inREADME.md. Nothing changes in the Python package or in what the solvers do. - Breaking (C++):
accept/andselect/are folders of the engine again. The acceptance rules and the adaptive operator selection are not operators the step loop draws: they decide whether it keeps a move and which operator it draws next, for moves and ruin-and-recreate alike. They move out ofsearch/tocore/optimaru/accept/andcore/optimaru/select/;search/keeps the operators (operators.hpp,strategies.hpp,moves/,ruin_recreate/). C++ that includes them follows the paths ("optimaru/accept/acceptors.hpp","optimaru/select/schemes.hpp"), and the include guards areOPTIMARU_ACCEPT_*andOPTIMARU_SELECT_*. Bin packing's own acceptor moves the same way, tobp/accept/. Nothing changes in the Python package or in what the solvers do. - Breaking (C++): the step loop is the solver's.
optimaru::LocalSearchandsearch/local_search.hppare gone. What the class ran was never one local search: it is the whole iteration of a solve (choose a move, score it, ask the acceptor, tell the selectors, and kick or start the next late-acceptance stage on a stall), so it is nowSolver::run, insolver.hpp, and it holds no move. What the header carried beside the loop moved to the folder it belongs to: the ordinary moves tosearch/move_mix/move_mix.hpp(MoveMixSampler), the stagnation kick tosearch/perturbation/stagnation_kick.hpp(StagnationKick), the ruin operators of a solve and their adaptive selection tosearch/ruin/pool.hpp(RuinPool), the built-in strategies and the draw among them tosearch/strategies/strategies.hpp(BuiltinStrategies), the acceptor factory toaccept/acceptors.hpp(make_acceptor) and the outcome of a candidate toselect/scheme.hpp(classify_outcome).Solver's public interface is unchanged, and so is every solve: the same seed and step limit give the same result. Nothing changes in the Python package. - Fix: a kick on a single entity or element. With one entity (or one element) and kicks on,
the number to ruin was clamped between 1 and
n - 1 = 0, boundsstd::clampdoes not allow. What came out depended on the standard library: 0 on the Linux wheels (libstdc++), a kick that ruined nothing, and 1 on the macOS ones (libc++). Both now ruin one, so a seeded solve of a single entity or element with kicks on can end differently on Linux. The same went for C++ callers that setalns.max_ruin_countbelow 1 (Python refuses that): libstdc++ handed the value itself to the ruin operators, a negative count; it is now 1. - Docs: how a solve runs, in the code.
docs/how-it-solves.mdfollowsSolver::runstep by step, in the order of the flowchart on optimaru.com, with the file, the settings and the way to extend each step;Solver::runmarks the steps. Issue templates (a move or constraint idea, a bug) and a pull request template.
0.8.0¶
From 0.7.0. Breaking: the settings of a SolverConfig are grouped by the stage of the solve
they act in (config.stop.time_limit_seconds, config.alns.min_ruin_fraction,
config.moves.change_weight, ...), and so are a request's solver_parameters and the API's
config ({"alns": {"min_ruin_fraction": 0.05}}); a flat name is refused with its new place.
The C++ optimaru::Settings has the same groups. The search itself is unchanged: every use
case's seeded results are the same as 0.7.0's.
- Breaking (C++): the engine's
Settingshas the same groups.optimaru::Settingsis laid out like the PythonSolverConfig:construction,stop(waslimits),alns_trigger(the kick'senabledandunimproved_step_trigger),strategies(the built-in strategies' weights and knobs, andruin_recreate_weight/ruin_recreate_max_ruin, which wereruin_recreate.as_move_*),custom_moves(share, wassearch.custom_move_probability),moves,selection(nearby,entity_hint,value_hint),acceptance,alns(the rest ofsearch.ruin_recreate),run(seed,score_checks,parallel_starts,on_new_best), andunassigned_list.SearchSettingsandRuinRecreateSettingsare gone. A use case'sSolver::Configis unchanged. Nothing changes in a solve: every use case's seeded results are the same. - Breaking:
SolverConfigsettings are grouped by stage of the solve. Every setting moved under one ofconstruction,stop,cost,alns_trigger,strategies,custom_moves,moves,selection,acceptance,alnsandrun, in the order a solve meets them, and lost the prefix its group now says:config.spent_limit_secondsisconfig.stop.time_limit_seconds,config.ruin_recreate_min_ruin_fractionisconfig.alns.min_ruin_fraction,config.change_move_weightisconfig.moves.change_weight,config.acceptor_typeisconfig.acceptance.rule.optimaru._config.FIELDSis the one table of the moves. A flat name raisesAttributeErrornaming its new place, and a compiled setter's error names the grouped setting.SolverConfig(stop={"time_limit_seconds": 10})sets whole groups;config.to_dict()reads them. A request'ssolver_parametersand the API'sconfigtake settings by group ({"alns": {"min_ruin_fraction": 0.05}}); a flat key is refused with its new place. The JSON mirrors (models.SolveConfig, employee scheduling'sSolverSettingsand itsportfolio) have the same groups; school timetabling'sweightssetting iscost.weights. Employee scheduling'sno_improvement_limit_secondsandno_improvement_step_count_limit, old names ofstop.unimproved_time_limit_secondsandstop.unimproved_step_limit, are gone. The solve keywords (time_limit_seconds,random_seed,parallel_solver_count, ...) and the C++Solver::Configfields are unchanged. - 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.