Skip to content

Allow printing of OptiNodes and OptiGraphs #38

@trulsf

Description

@trulsf

During development, I often find it useful to print the model in the REPL, When developing a Plasmo model incrementally, I got errors when doing this for specific OptiNodes and OptiGraphs. It seems just to be some missing pieces of the JuMP interface that is missing.

For e.g. getting OptiNodes printed, I needed to add the following two missing functions:

# Ensure that nodes can be printed as a normal JuMP problem
function JuMP.objective_function_string(mode, model::OptiNode)
   return JuMP.function_string(mode, objective_function(model))
end

function JuMP.constraints_string(mode, model::OptiNode)
   strings = String[
       constraint_string(mode, cref; in_math_mode = true) for
       (F, S) in list_of_constraint_types(model) for
       cref in all_constraints(model, F, S)
   ]
   return strings
end

Is this something worth including? I could probably find time to do a PR if you like.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions