Skip to content
This repository has been archived by the owner on Jun 14, 2020. It is now read-only.

Commit

Permalink
Mocksolver improvements (#27)
Browse files Browse the repository at this point in the history
* Add quadratics and interval features

* WIP update mock opt

* Fix quadratic indexing in Xpress:
- get last constraint index instead of number of constraints
- abstract 1 level shift after delete

* add quadratic tests

* update mock optimizer to pass quad

* revert last index

* revert shift base

* improve mocksolver and add tests

* Fix one indexing

* remove TODO
  • Loading branch information
joaquimg authored Jun 13, 2018
1 parent 37bdd17 commit 11fb079
Show file tree
Hide file tree
Showing 7 changed files with 436 additions and 170 deletions.
2 changes: 1 addition & 1 deletion src/constraints/scalaraffine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function MOI.get(m::LinQuadOptimizer, ::MOI.ConstraintFunction, c::LCI{<: LinSet
colidx, coefs = get_linear_constraint(m, m[c])
terms = map(
(v,c)->MOI.ScalarAffineTerm{Float64}(c,v),
m.variable_references[colidx+1],
m.variable_references[colidx],
coefs
)
Linear(terms, -m.constraint_constant[m[c]])
Expand Down
4 changes: 2 additions & 2 deletions src/constraints/scalarquadratic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ function MOI.addconstraint!(m::LinQuadOptimizer, func::Quad, set::S) where S <:
dict = constrdict(m, ref)
push!(m.qconstraint_primal_solution, NaN)
push!(m.qconstraint_dual_solution, NaN)
# dict[ref] = get_number_quadratic_constraints(m)
dict[ref] = length(m.qconstraint_primal_solution)
dict[ref] = get_number_quadratic_constraints(m)
# dict[ref] = length(m.qconstraint_primal_solution)
return ref
end

Expand Down
2 changes: 1 addition & 1 deletion src/constraints/vectoraffine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function MOI.get(m::LinQuadOptimizer, ::MOI.ConstraintFunction, c::VLCI{<: VecLi
push!(terms, MOI.VectorAffineTerm{Float64}(
i,
MOI.ScalarAffineTerm{Float64}(
coefficient, m.variable_references[column+1]
coefficient, m.variable_references[column]
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion src/constraints/vectorofvariables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function MOI.get(m::LinQuadOptimizer, ::MOI.ConstraintFunction, c::VVCI{<: VecLi
if length(colidx) != 1
error("Unexpected constraint")
end
push!(out,m.variable_references[colidx[1]+1])
push!(out,m.variable_references[colidx[1]])
end
return VecVar(out)
end
Expand Down
Loading

0 comments on commit 11fb079

Please sign in to comment.