Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printing of MCPModel #38

Closed
hhoeschle opened this issue Apr 18, 2019 · 1 comment
Closed

Printing of MCPModel #38

hhoeschle opened this issue Apr 18, 2019 · 1 comment

Comments

@hhoeschle
Copy link

Hi all,

I discovered that the printing of a MCPModel did not provide the complementarity constraints. Here is a first test to fix that:

function printMCP(m)
    mcp_data  = Complementarity.get_MCP_data(m)
    res = "$(m)Complementarity constraints\n"

    # replace all subexpression
    dict_s = Dict{Int,String}(
        i => nl_expr_string(m, REPLMode , expr)
        for (i,expr) in enumerate(m.nlp_data.nlexpr)
    )

    sub_reg = r"subexpression\[(?<id>[0-9]+)\]"
    for (i,expr) in dict_s
        m = match(sub_reg, expr)
        try
            dict_s[i] = replace(expr, m.match => dict_s[parse(Int, m[:id])])
        catch
        end
    end
    for c in mcp_data
        expr_id = parse(Int,split("$(c.F)", "#")[end][1:end-1])
        res = res * " $(c.lb)$(c.var) \n$(dict_s[expr_id]) ≧ 0.0\n"
    end
    return res
end

For the example on the start page, this is the outcome of println(printMCP(m)):

Feasibility
Subject to
 x >= 0.0
Complementarity constraints
 0.0 ≦ x
   ⟂ x + 2.0 ≧ 0.0
@chkwon
Copy link
Owner

chkwon commented Jan 26, 2021

Closing for the new version of PATHSolver.jl chkwon/PATHSolver.jl#44

@chkwon chkwon closed this as completed Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants