diff --git a/perf/runbench.jl b/perf/runbench.jl index 3ff6c32..828559f 100644 --- a/perf/runbench.jl +++ b/perf/runbench.jl @@ -37,7 +37,7 @@ function generate_moi_problem(model, At, b, c; else for row in 1:rows MOI.add_constraint(model, MOI.VectorAffineFunction( - [MOI.VectorAffineTerm(1, + [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(A_vals[i], x[A_cols[i]]) ) for i in nzrange(At, row)], [-b[row]]), MOI.Nonpositives(1)) @@ -113,7 +113,7 @@ function time_build_and_solve(to_build, to_solve, At, b, c, scalar = true) end MOI.set(to_solve, MOI.TimeLimitSec(), 0.0010) @time @timeit "opt" MOI.optimize!(to_solve) - val = MOI.get(to_solve, MOI.SolveTime()) + val = MOI.get(to_solve, MOI.SolveTimeSec()) println(val) @show MOI.get(to_solve, MOI.ObjectiveValue()) @show MOI.get(to_solve, MOI.TerminationStatus()) @@ -129,19 +129,19 @@ function solve_GLPK(seed, data; time_limit_sec=Inf) GC.gc() bridged_cache, pure_solver = bridged_cache_and_solver() @timeit "bc + s" time_build_and_solve(bridged_cache, pure_solver, At, b, c) - + GC.gc() cache, pure_solver2 = cache_and_solver() @timeit "c + s" time_build_and_solve(cache, pure_solver2, At, b, c) - + GC.gc() full_solver = bridged_cached_solver() @timeit "bcs" time_build_and_solve(full_solver, full_solver, At, b, c) - + GC.gc() full_solver = bridged_cached_solver() @timeit "bcs + v" time_build_and_solve(full_solver, full_solver, At, b, c, false) - + GC.gc() cache_solver = cached_solver() @timeit "cs" time_build_and_solve(cache_solver, cache_solver, At, b, c) @@ -153,4 +153,4 @@ function solve_GLPK(seed, data; time_limit_sec=Inf) end solve_GLPK(2, RandomLP(11, 11, 0.5); time_limit_sec=5) -solve_GLPK(20, RandomLP(10000, 10000, 0.005); time_limit_sec=5) \ No newline at end of file +solve_GLPK(20, RandomLP(10000, 10000, 0.005); time_limit_sec=5) diff --git a/src/MOI_wrapper/MOI_copy.jl b/src/MOI_wrapper/MOI_copy.jl index 4e246f2..38dfa72 100644 --- a/src/MOI_wrapper/MOI_copy.jl +++ b/src/MOI_wrapper/MOI_copy.jl @@ -123,7 +123,7 @@ function _extract_row_data(src, mapping, lb, ub, I, J, V, ::Type{S}) where {S} for term in f.terms non_zeros += 1 I[non_zeros] = row - J[non_zeros] = Cint(mapping[term.variable_index].value::Int64) + J[non_zeros] = Cint(mapping[term.variable].value::Int64) V[non_zeros] = term.coefficient end row += 1 @@ -134,7 +134,7 @@ function _extract_row_data(src, mapping, lb, ub, I, J, V, ::Type{S}) where {S} end function test_data(src, dest) - for (F, S) in MOI.get(src, MOI.ListOfConstraints()) + for (F, S) in MOI.get(src, MOI.ListOfConstraintTypesPresent()) if !MOI.supports_constraint(dest, F, S) throw(MOI.UnsupportedConstraint{F, S}("GLPK.Optimizer does not support constraints of type $F-in-$S.")) end @@ -235,7 +235,7 @@ function MOI.copy_to( end function pass_constraint_attributes(dest, src, copy_names, mapping) - ctr_types = MOI.get(src, MOI.ListOfConstraints()) + ctr_types = MOI.get(src, MOI.ListOfConstraintTypesPresent()) for (F,S) in ctr_types pass_constraint_attributes(dest, src, copy_names, mapping, F, S) end diff --git a/src/MOI_wrapper/MOI_wrapper.jl b/src/MOI_wrapper/MOI_wrapper.jl index 494a7d3..fca429e 100644 --- a/src/MOI_wrapper/MOI_wrapper.jl +++ b/src/MOI_wrapper/MOI_wrapper.jl @@ -420,7 +420,7 @@ function _indices_and_coefficients( ) i = 1 for term in f.terms - indices[i] = Cint(column(model, term.variable_index)) + indices[i] = Cint(column(model, term.variable)) coefficients[i] = term.coefficient i += 1 end @@ -602,7 +602,7 @@ function MOI.set( num_vars = length(model.variable_info) obj = zeros(Float64, num_vars) for term in f.terms - col = column(model, term.variable_index) + col = column(model, term.variable) obj[col] += term.coefficient end for (col, coef) in enumerate(obj) @@ -1598,7 +1598,7 @@ end function MOI.get(model::Optimizer, attr::MOI.PrimalStatus) _throw_if_optimize_in_progress(model, attr) - if attr.N != 1 + if attr.result_index != 1 return MOI.NO_SOLUTION end (status, _) = _get_status(model) @@ -1618,7 +1618,7 @@ end function MOI.get(model::Optimizer, attr::MOI.DualStatus) _throw_if_optimize_in_progress(model, attr) - if attr.N != 1 || model.last_solved_by_mip + if attr.result_index != 1 || model.last_solved_by_mip return MOI.NO_SOLUTION end (status, _) = _get_status(model) @@ -1856,7 +1856,7 @@ function MOI.get(model::Optimizer, attr::MOI.RelativeGap) return model.relative_gap end -function MOI.get(model::Optimizer, attr::MOI.SolveTime) +function MOI.get(model::Optimizer, attr::MOI.SolveTimeSec) _throw_if_optimize_in_progress(model, attr) return model.solve_time end @@ -1942,7 +1942,7 @@ function MOI.get( return sort!(indices, by = x -> x.value) end -function MOI.get(model::Optimizer, ::MOI.ListOfConstraints) +function MOI.get(model::Optimizer, ::MOI.ListOfConstraintTypesPresent) constraints = Set{Tuple{DataType, DataType}}() for info in values(model.variable_info) if info.bound == NONE