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

Commit 11fb079

Browse files
authored
Mocksolver improvements (#27)
* 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
1 parent 37bdd17 commit 11fb079

File tree

7 files changed

+436
-170
lines changed

7 files changed

+436
-170
lines changed

src/constraints/scalaraffine.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function MOI.get(m::LinQuadOptimizer, ::MOI.ConstraintFunction, c::LCI{<: LinSet
153153
colidx, coefs = get_linear_constraint(m, m[c])
154154
terms = map(
155155
(v,c)->MOI.ScalarAffineTerm{Float64}(c,v),
156-
m.variable_references[colidx+1],
156+
m.variable_references[colidx],
157157
coefs
158158
)
159159
Linear(terms, -m.constraint_constant[m[c]])

src/constraints/scalarquadratic.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ function MOI.addconstraint!(m::LinQuadOptimizer, func::Quad, set::S) where S <:
1919
dict = constrdict(m, ref)
2020
push!(m.qconstraint_primal_solution, NaN)
2121
push!(m.qconstraint_dual_solution, NaN)
22-
# dict[ref] = get_number_quadratic_constraints(m)
23-
dict[ref] = length(m.qconstraint_primal_solution)
22+
dict[ref] = get_number_quadratic_constraints(m)
23+
# dict[ref] = length(m.qconstraint_primal_solution)
2424
return ref
2525
end
2626

src/constraints/vectoraffine.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function MOI.get(m::LinQuadOptimizer, ::MOI.ConstraintFunction, c::VLCI{<: VecLi
107107
push!(terms, MOI.VectorAffineTerm{Float64}(
108108
i,
109109
MOI.ScalarAffineTerm{Float64}(
110-
coefficient, m.variable_references[column+1]
110+
coefficient, m.variable_references[column]
111111
)
112112
)
113113
)

src/constraints/vectorofvariables.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function MOI.get(m::LinQuadOptimizer, ::MOI.ConstraintFunction, c::VVCI{<: VecLi
7575
if length(colidx) != 1
7676
error("Unexpected constraint")
7777
end
78-
push!(out,m.variable_references[colidx[1]+1])
78+
push!(out,m.variable_references[colidx[1]])
7979
end
8080
return VecVar(out)
8181
end

0 commit comments

Comments
 (0)