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

Commit a409190

Browse files
authored
Merge pull request #40 from JuliaOpt/bl/moi0.4
Updates to MOI 0.4
2 parents a3d2a6b + 1ca0753 commit a409190

File tree

3 files changed

+40
-40
lines changed

3 files changed

+40
-40
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
julia 0.6
2-
MathOptInterface 0.3 0.4
2+
MathOptInterface 0.4 0.5
33
Mosek 0.8.3

src/constraint.jl

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -537,21 +537,20 @@ end
537537
## MODIFY #####################################################################
538538
################################################################################
539539

540-
MOI.canmodifyconstraint(m::MosekModel, c::MOI.ConstraintIndex{F,D}, dom) where { F <: LinearFunction, D <: VectorCone } = false
541-
MOI.canmodifyconstraint(m::MosekModel, c::MOI.ConstraintIndex{F,D}, dom) where { F <: LinearFunction, D <: PositiveSemidefiniteCone } = false
542-
MOI.canmodifyconstraint(m::MosekModel, c::MOI.ConstraintIndex{F,D}, ::Type{D}) where { F <: LinearFunction, D <: LinearDomain } = haskey(select(m.constrmap,F,D),c.value)
543-
MOI.canmodifyconstraint(m::MosekModel, c::MOI.ConstraintIndex{F,D}, ::Type{F}) where { F <: Union{MOI.SingleVariable,MOI.ScalarAffineFunction}, D <: ScalarLinearDomain } = haskey(select(m.constrmap,F,D),c.value)
544-
MOI.canmodifyconstraint(m::MosekModel, c::MOI.ConstraintIndex{F,D}, ::Type{<:MOI.AbstractFunctionModification}) where { F <: AffineFunction, D <: MOI.AbstractSet } = haskey(select(m.constrmap,F,D),c.value)
540+
MOI.canset(m::MosekModel, ::MOI.ConstraintSet, ::Type{MOI.ConstraintIndex{F,D}}) where { F <: LinearFunction, D <: LinearDomain } = true
541+
MOI.canset(m::MosekModel, ::MOI.ConstraintFunction, ::Type{MOI.ConstraintIndex{F,D}}) where { F <: Union{MOI.SingleVariable,MOI.ScalarAffineFunction}, D <: ScalarLinearDomain } = true
542+
MOI.canmodify(m::MosekModel, ::Type{MOI.ConstraintIndex{F,D}}, ::Type{<:MOI.AbstractFunctionModification}) where { F <: AffineFunction, D <: MOI.AbstractSet } = true
545543

546544
chgbound(bl::Float64,bu::Float64,k::Float64,dom :: MOI.LessThan{Float64}) = bl,dom.upper-k
547545
chgbound(bl::Float64,bu::Float64,k::Float64,dom :: MOI.GreaterThan{Float64}) = dom.lower-k,bu
548546
chgbound(bl::Float64,bu::Float64,k::Float64,dom :: MOI.EqualTo{Float64}) = dom.value-k,dom.value-k
549547
chgbound(bl::Float64,bu::Float64,k::Float64,dom :: MOI.Interval{Float64}) = dom.lower-k,dom.upper-k
550548

551-
function MOI.modifyconstraint!(m::MosekModel,
552-
xcref::MOI.ConstraintIndex{F,D},
553-
dom::D) where { F <: MOI.SingleVariable,
554-
D <: ScalarLinearDomain }
549+
function MOI.set!(m::MosekModel,
550+
::MOI.ConstraintSet,
551+
xcref::MOI.ConstraintIndex{F,D},
552+
dom::D) where { F <: MOI.SingleVariable,
553+
D <: ScalarLinearDomain }
555554
xcid = ref2id(xcref)
556555
j = m.xc_idxs[getindexes(m.xc_block,xcid)[1]]
557556
bk,bl,bu = getvarbound(m.task,j)
@@ -560,20 +559,21 @@ function MOI.modifyconstraint!(m::MosekModel,
560559
end
561560

562561

563-
function MOI.modifyconstraint!(m::MosekModel,
564-
cref::MOI.ConstraintIndex{F,D},
565-
dom::D) where { F <: MOI.ScalarAffineFunction,
566-
D <: ScalarLinearDomain }
562+
function MOI.set!(m::MosekModel,
563+
::MOI.ConstraintSet,
564+
cref::MOI.ConstraintIndex{F,D},
565+
dom::D) where { F <: MOI.ScalarAffineFunction,
566+
D <: ScalarLinearDomain }
567567
cid = ref2id(cref)
568568
i = getindexes(m.c_block,cid)[1] # since we are in a scalar domain
569569
bk,bl,bu = getconbound(m.task,i)
570570
bl,bu = chgbound(bl,bu,0.0,dom)
571571
putconbound(m.task,i,bk,bl,bu)
572572
end
573573

574-
function MOI.modifyconstraint!(m ::MosekModel,
575-
c ::MOI.ConstraintIndex{MOI.ScalarAffineFunction{Float64},D},
576-
func::MOI.ScalarConstantChange{Float64}) where {D <: MOI.AbstractSet}
574+
function MOI.modify!(m ::MosekModel,
575+
c ::MOI.ConstraintIndex{MOI.ScalarAffineFunction{Float64},D},
576+
func::MOI.ScalarConstantChange{Float64}) where {D <: MOI.AbstractSet}
577577

578578
cid = ref2id(c)
579579

@@ -585,9 +585,9 @@ function MOI.modifyconstraint!(m ::MosekModel,
585585
putconbound(m.task,i,bk,bl,bu)
586586
end
587587

588-
function MOI.modifyconstraint!(m ::MosekModel,
589-
c ::MOI.ConstraintIndex{MOI.ScalarAffineFunction{Float64},D},
590-
func::MOI.ScalarCoefficientChange{Float64}) where {D <: MOI.AbstractSet}
588+
function MOI.modify!(m ::MosekModel,
589+
c ::MOI.ConstraintIndex{MOI.ScalarAffineFunction{Float64},D},
590+
func::MOI.ScalarCoefficientChange{Float64}) where {D <: MOI.AbstractSet}
591591
cid = ref2id(c)
592592
xid = ref2id(func.variable)
593593

@@ -597,9 +597,9 @@ function MOI.modifyconstraint!(m ::MosekModel,
597597
putaij(m.task,i,j,func.new_coefficient)
598598
end
599599

600-
function MOI.modifyconstraint!(m::MosekModel,
601-
c::MOI.ConstraintIndex{MOI.VectorAffineFunction{Float64},D},
602-
func::MOI.VectorConstantChange{Float64}) where {D <: MOI.AbstractSet}
600+
function MOI.modify!(m::MosekModel,
601+
c::MOI.ConstraintIndex{MOI.VectorAffineFunction{Float64},D},
602+
func::MOI.VectorConstantChange{Float64}) where {D <: MOI.AbstractSet}
603603
cid = ref2id(c)
604604
assert(cid > 0)
605605

@@ -616,9 +616,9 @@ function MOI.modifyconstraint!(m::MosekModel,
616616
putconboundlist(m.task,convert(Vector{Int32},subi),bk,bl,bu)
617617
end
618618

619-
function MOI.modifyconstraint!(m::MosekModel,
620-
c::MOI.ConstraintIndex{MOI.VectorAffineFunction{Float64},D},
621-
func::MOI.MultirowChange{Float64}) where {D <: MOI.AbstractSet}
619+
function MOI.modify!(m::MosekModel,
620+
c::MOI.ConstraintIndex{MOI.VectorAffineFunction{Float64},D},
621+
func::MOI.MultirowChange{Float64}) where {D <: MOI.AbstractSet}
622622
cid = ref2id(c)
623623
assert(cid > 0)
624624

@@ -631,23 +631,23 @@ end
631631

632632

633633

634-
MOI.cantransformconstraint(m::MosekModel, c::MOI.ConstraintIndex{F,D1}, newdom::D2) where {F <: VariableFunction, D1, D2 } = false
635-
MOI.cantransformconstraint(m::MosekModel, c::MOI.ConstraintIndex{MOI.VectorAffineFunction,D1}, newdom::D2) where {D1 <: VectorLinearDomain, D2 <: VectorLinearDomain} = false
636-
function MOI.cantransformconstraint(m::MosekModel,
634+
MOI.cantransform(m::MosekModel, c::MOI.ConstraintIndex{F,D1}, newdom::D2) where {F <: VariableFunction, D1, D2 } = false
635+
MOI.cantransform(m::MosekModel, c::MOI.ConstraintIndex{MOI.VectorAffineFunction,D1}, newdom::D2) where {D1 <: VectorLinearDomain, D2 <: VectorLinearDomain} = false
636+
function MOI.cantransform(m::MosekModel,
637637
cref::MOI.ConstraintIndex{MOI.ScalarAffineFunction{Float64},D1},
638638
newdom::D2) where {D1 <: ScalarLinearDomain,
639639
D2 <: ScalarLinearDomain}
640640
haskey(select(m.constrmap,MOI.ScalarAffineFunction{Float64},D1),cref.value)
641641
end
642642

643-
function MOI.transformconstraint!(m::MosekModel,
644-
cref::MOI.ConstraintIndex{F,D},
645-
newdom::D) where {F <: MOI.AbstractFunction, D <: MOI.AbstractSet}
646-
MOI.modifyconstraint(m,cref,newdom)
643+
function MOI.transform!(m::MosekModel,
644+
cref::MOI.ConstraintIndex{F,D},
645+
newdom::D) where {F <: MOI.AbstractFunction, D <: MOI.AbstractSet}
646+
MOI.modify!(m,cref,newdom)
647647
cref
648648
end
649649

650-
function MOI.transformconstraint!(m::MosekModel,
650+
function MOI.transform!(m::MosekModel,
651651
cref::MOI.ConstraintIndex{MOI.ScalarAffineFunction{Float64},D1},
652652
newdom::D2) where {D1 <: ScalarLinearDomain,
653653
D2 <: ScalarLinearDomain}
@@ -665,7 +665,7 @@ function MOI.transformconstraint!(m::MosekModel,
665665
newcref
666666
end
667667

668-
function MOI.transformconstraint!(m::MosekModel,
668+
function MOI.transform!(m::MosekModel,
669669
cref::MOI.ConstraintIndex{MOI.VectorAffineFunction{Float64},D1},
670670
newdom::D2) where {D1 <: VectorLinearDomain,
671671
D2 <: VectorLinearDomain}
@@ -683,7 +683,7 @@ function MOI.transformconstraint!(m::MosekModel,
683683
newcref
684684
end
685685

686-
#MOI.transformconstraint!(m::MosekModel, c::MOI.ConstraintIndex{F,D1}, newdom::D2) where {F <: MOI.VectorAffineFunction , D1 <: VectorLinearDomain, D2 <: VectorLinearDomain} = false
686+
#MOI.transform!(m::MosekModel, c::MOI.ConstraintIndex{F,D1}, newdom::D2) where {F <: MOI.VectorAffineFunction , D1 <: VectorLinearDomain, D2 <: VectorLinearDomain} = false
687687

688688
################################################################################
689689
## DELETE #####################################################################

src/objective.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ function MOI.set!(m::MosekModel, ::MOI.ObjectiveFunction, func::MOI.ScalarAffine
3838
putcfix(m.task,func.constant)
3939
end
4040

41-
MOI.canmodifyobjective(m::MosekModel, change :: MOI.ScalarConstantChange) = true
42-
MOI.canmodifyobjective(m::MosekModel, change :: MOI.ScalarCoefficientChange) = true
41+
MOI.canmodify(m::MosekModel, ::MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}, change :: MOI.ScalarConstantChange) = true
42+
MOI.canmodify(m::MosekModel, ::MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}, change :: MOI.ScalarCoefficientChange) = true
4343

44-
function MOI.modifyobjective!(m::MosekModel, change :: MOI.ScalarConstantChange)
44+
function MOI.modify!(m::MosekModel, ::MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}, change :: MOI.ScalarConstantChange)
4545
putcfix(m.task,change.new_constant)
4646
end
4747

48-
function MOI.modifyobjective!(m::MosekModel, change :: MOI.ScalarCoefficientChange)
48+
function MOI.modify!(m::MosekModel, ::MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}, change :: MOI.ScalarCoefficientChange)
4949
vid = ref2id(change.variable)
5050
subj = getindexes(m.x_block,vid)
5151
putcj(m.task,Int32(subj[1]),change.new_coefficient)

0 commit comments

Comments
 (0)