Skip to content

Memory consumption and time of @constraint #969

@Thuener

Description

@Thuener

I'm having some issues with memory consumption on JuMP. I have a problem that has too many constraints and the JuMP structures for macro @constraint is consuming too much memory.

Example:

using JuMP,CPLEX

function memuse()
 pid = getpid()
 return round(Int,parse(Int,readstring(`ps -p $pid -o rss=`))/1024)
end

memuse()
C = 300000
m = Model(solver=CplexSolver())
N = 100
@variable(m, x[1:N] >= 0)
@variable(m, Θ >= 0)

@objective(m, Max, Θ )
solve(m)

coef = rand(C,N)
m1= memuse()
tic()
@constraint(m, Θ .<= coef*x  )
time = toq()
gc()
m2 = memuse()
print("Memory consumption $(m2-m1) Mb and Time $(time)")

Memory consumption 1022 Mb and Time 11.076951813

Changing the @constraint to CPLEX.add_constrs.

m1= memuse()
tic()
rhs = zeros(C)
coef = hcat(-coef,ones(C));
CPLEX.add_constrs!(m.internalModel.inner, coef, '<', rhs)
time = toq()
gc()
m2 = memuse()

Memory consumption 447 Mb and Time 1.975631208

With JuMP this constraint consumes 2.28x more memory and become 5.6x more slower. Maybe JuMP should have some macro to add constraints direct to the model without storing any information about it.

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