Two Circuit Constraints

· Source: Blog on Activimetrics LLC · Field: Technology & Digital — Software Development & Engineering, Artificial Intelligence & Machine Learning, Mathematics & Computational Sciences · Depth: Advanced, long

Summary

An analysis of OR-Tools' CP-SAT solver, specifically the `bus_driver_scheduling_sat` example, investigates whether replacing custom circuit logic with the official `model.add_circuit(arcs)` API improves performance. Initial attempts to integrate `add_circuit` for individual drivers yielded similar results but were slightly slower, with tiny instances taking over 2 seconds compared to under 2 seconds, and small instances averaging around 45 seconds versus under 45 seconds. A more invasive change to use a single `model.add_multiple_circuit(arcs)` for all drivers initially resulted in an infeasible solution due to the constraint's nature, then worked but was consistently slower, with small instances running at approximately 60 seconds instead of 40 seconds. Subsequent attempts to reintroduce redundant constraints or nest circuit calls also failed to improve solver speed.

Key takeaway

For optimization engineers developing scheduling solutions with OR-Tools' CP-SAT solver, if you are considering replacing custom circuit logic with `add_circuit` or `add_multiple_circuit` for performance gains, this analysis suggests it may not yield speed improvements and could even slow down solutions like bus driver scheduling. Prioritize alternative problem formulations, such as those focusing on break placements, for potential performance benefits rather than direct API replacements.

Key insights

Directly replacing custom circuit logic with OR-Tools' CP-SAT `add_circuit` or `add_multiple_circuit` did not improve solver performance for bus driver scheduling.

Principles

Method

The author modified an existing `bus_driver_scheduling_sat` program by replacing custom circuit logic with `model.add_circuit` and later `model.add_multiple_circuit`, populating `arcs` with (source, destination, literal) tuples and linking arc literals to `performed` variables.

In practice

Topics

Code references

Best for: Software Engineer, AI Engineer, Research Scientist

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Blog on Activimetrics LLC.