How to link a JuMP model and a general algorithm together?

Suppose there is a general algorithm for some kind of optimization problem in a standard form, and then there is an instance of this kind of problem which is however not written in the standard form. Both of the algorithm and the instance are written with JuMP. Obviously, now there is a need for us to convert the naturally written instance into the standard form for solving. Then what is the next step that we should do?

This question is too general to provide an answer for.

What is the algorithm? What is the standard form? What sub solvers? etc.

In general, if your algorithm operates on a fixed input data that is representable using the MathOptInterface standard form (i.e., function -in- set), then the suggested approach is to implement an interface to MathOptInterface.jl. Look at the various existing packages for inspiration. The fact that you use JuMP internally in your algorithm is an implementation detail.

But if your algorithm operates as a JuMP extension on an existing JuMP model, then it depends. You’ll need to provide more information.

1 Like

Thank you @odow !

I know MathOptInterface.jl may help but I don’t get familiar with it for now. Maybe I should write an algorithm directly with MathOptInterface.jl instead of JuMP.jl. But now the algorithm is given by a function like for example

function myLP(A, b, c)
    # Here is a JuMP model for the LP: min c'x s.t. Ax ≤ b.
end

Now if I have an arbitrary LP problem written with JuMP, how should I extract from it the A, b and c automatically?

If your problem is an LP, then you can use: Models · JuMP

See also Connecting a simple first-order solver to solve standard form linear program to JuMP

and GitHub - Shuvomoy/SimplePDHG.jl: Implements vanilla PDHG algorithm

1 Like

Thanks. I’ll try to understand the things. :handshake::handshake:

1 Like