Skip to content

[WIP] Wrapper for OT barycenter solvers with free support #730

Open
cedricvincentcuaz wants to merge 41 commits into
PythonOT:masterfrom
cedricvincentcuaz:solvers
Open

[WIP] Wrapper for OT barycenter solvers with free support #730
cedricvincentcuaz wants to merge 41 commits into
PythonOT:masterfrom
cedricvincentcuaz:solvers

Conversation

@cedricvincentcuaz

@cedricvincentcuaz cedricvincentcuaz commented Apr 21, 2025

Copy link
Copy Markdown
Collaborator

Types of changes

  • creation of the class ot.utils.BaryResult extending OTResult

  • Long term objectives: Wrap all barycenter solvers available in POT and more, ideally establishing links between these wrappers and those for inner OT solvers ot.solve_sample, ot.solve, and ot.solve_gromov - respectively associated with their barycenter solver ot.solve_bary_sample (free support); ot.solve_bary (free masses); ot.solve_bary_gromov (free joint support)

  • a) ot.solvers.solve_bary_sample systematically optimizes the support of the barycenter using BCD with closed forms if the parameter metric is in ('sqeuclidean', 'euclidean') calling an hidden function _bary_sample_bcd which works with most OT problems in ot.solve_sample. metric can also be a callable or a list of callable function following the API of lp.free_support_barycenter_generic_costs for balanced OT only.

  • b) handle variations in masses across OT problems only for unbalanced problems - keeping masses unchanged for exact and inexact sinkhorn like solvers - via parameter update_masses in ot.solvers._bary_sample_bcd.

  • c) Handle given initialization of transport plans & potentials + warmstart strategies : added parameter warmstart to solve_bary_sample, and based on the requested inner OT solver, we pick the adequate strategy warmstart_plan or warmstart_potentials passed to _bary_sample_bcd .

  • d) Options for stopping criterion between losses and barycenter variations: added parameter stopping_criterion in ('loss', 'bary') passed to _bary_sample_bcd.

Extensions let for future works:

  • a) include lazy inner OT solvers referenced in the list lst_method_lazy (in ot.solvers)

How has this been tested (if it applies)

  • a) test.test_solvers.assert_allclose_bary_sol method to compare solutions as BaryResult objects.
  • b) test_solve_bary_sample grid across all available barycenter solvers depending on those available in ot.solvers.solve_sample.
  • c) test_solve_bary_sample_NotImplemented test error messages for methods not implemented yet.
  • d) test_solve_bary_sample_ValueError Test ValueError cases including stopping_criterion and X_b_init shape.
  • e) test_solve_bary_sample_callable_metric test barycenter solvers for balanced OT with callable metrics.

PR checklist

  • I have read the CONTRIBUTING document.
  • The documentation is up-to-date with the changes I made (check build artifacts).
  • All tests passed, and additional code has been covered with new tests.
  • I have added the PR and Issue fix to the RELEASES.md file.

@codecov

codecov Bot commented Apr 22, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.05594% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.78%. Comparing base (aed0120) to head (82d2ff8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #730      +/-   ##
==========================================
- Coverage   96.81%   96.78%   -0.04%     
==========================================
  Files         124      124              
  Lines       24263    24546     +283     
==========================================
+ Hits        23490    23756     +266     
- Misses        773      790      +17     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cedricvincentcuaz cedricvincentcuaz changed the title [WIP] Wrappers for OT barycenter solvers [WIP] Wrapper for OT barycenter solvers with free support Mar 9, 2026
@github-actions github-actions Bot added the ot.lp label Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants