AlgebraicJulia / Catlab.jl

A framework for applied category theory in the Julia language
https://www.algebraicjulia.org
MIT License
599 stars 56 forks source link

Interfacing AlgebraicJulia ecosystem with constraint solving and optimization tools #767

Open mhlr opened 1 year ago

mhlr commented 1 year ago

Are there (plans for) tool to interface to tools like JuMP, MathOptInterface and ConstraintExtensions? There seem to be healthy ecosystems around these and I can imagine a world where domains are defined usin Catlab, problem instances are extracted from databases using AlgebraicRelations and then transformed into formulations appropriate for various solvers.

epatters commented 1 year ago

Good question. I agree that this is a natural direction. So far we're just getting started integrating AlgebraicJulia with optimization tools---this requires math work as well as the software engineering---but @tylerhanks has preliminary work on optimal control in AlgebraicControl.jl.

mhlr commented 11 months ago

A MiniZinc backend would be awesome

slwu89 commented 10 months ago

I'll just point out that the Tables interface for ACSets (https://github.com/AlgebraicJulia/ACSets.jl/blob/ba49dd5539267101900c0d42cb2559ca7f02bd7c/test/ACSets.jl#L278) is already quite nice for structuring JuMP problems because the resulting columns can be used as indexing sets (https://jump.dev/JuMP.jl/stable/tutorials/getting_started/getting_started_with_sets_and_indexing/) for decision variables or constraints, making it easy to go from an ACSet that stores the problem description and data to a JuMP model to optimize.

mhlr commented 10 months ago

An approach I am thinking about is to reflect JuMP in CatLab as a theory of variables, constraints, and objectives. Then given a theory representing a problem domain, implement a theory mapping from the domain theory to the JuMP theory. Now given a some instance data or a presentation the mapping should generate a concrete problem instance in JuMP.

Does that sound feasible? Is it a good approach?

mhlr commented 10 months ago

Thinking about it more, I maybe there would be a general optimization theory and JuMP would be apresenteation of it (really asking ... new to CatLab & Julia).

My real goal is to separate domain modelling from mathematical modelling of optimization problems. Optimizatiom modelling tools like AMPL, MiniZinc, Pyomo, JuMP, ... all force users to dive directly into the mathematical modelling at a rather low concrete level, causing users to skimp on domain diascovery / problem analysis/ (more buzzwords for a simple idea). The clients of these models are often not very technical and just glaze over when presented with a typical MILP formulation of their problem without being able to provide any feedback. They would be more likely to be able to critique something like an ERD or a UML diagram, which would provide at least some constraints on the final mathematical formulation

CatLab feels like a natural tool to do this decoupling.