Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 41 additions & 48 deletions benchmark/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ version = "0.5.1"

[[ChainRulesCore]]
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "9950387274246d08af38f6eef8cb5480862a435f"
git-tree-sha1 = "2dd813e5f2f7eec2d1268c57cf2373d3ee91fcea"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "1.14.0"
version = "1.15.1"

[[ChangesOfVariables]]
deps = ["ChainRulesCore", "LinearAlgebra", "Test"]
git-tree-sha1 = "bf98fa45a0a4cee295de98d4c1462be26345b9a1"
git-tree-sha1 = "1e315e3f4b0b7ce40feded39c73049692126cf53"
uuid = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
version = "0.1.2"
version = "0.1.3"

[[CodecBzip2]]
deps = ["Bzip2_jll", "Libdl", "TranscodingStreams"]
Expand All @@ -58,29 +58,25 @@ uuid = "bbf7d656-a473-5ed7-a52c-81e309532950"
version = "0.3.0"

[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "b153278a25dd42c65abbf4e62344f9d22e59191b"
deps = ["Dates", "LinearAlgebra", "UUIDs"]
git-tree-sha1 = "924cdca592bc16f14d2f7006754a621735280b74"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "3.43.0"
version = "4.1.0"

[[CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"

[[DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
git-tree-sha1 = "3daef5523dd2e769dad2365274f760ff5f282c7d"
git-tree-sha1 = "d1fff3a548102f48987a52a2e0d114fa97d730f0"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.18.11"
version = "0.18.13"

[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[DelimitedFiles]]
deps = ["Mmap"]
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"

[[DiffResults]]
deps = ["StaticArrays"]
git-tree-sha1 = "c18e98cba888c6c25d1c3b048e4b3380ca956805"
Expand All @@ -89,13 +85,9 @@ version = "1.0.3"

[[DiffRules]]
deps = ["IrrationalConstants", "LogExpFunctions", "NaNMath", "Random", "SpecialFunctions"]
git-tree-sha1 = "dd933c4ef7b4c270aacd4eb88fa64c147492acf0"
git-tree-sha1 = "28d605d9a0ac17118fe2c5e9ce0fbb76c3ceb120"
uuid = "b552c78f-8df3-52c6-915a-8e097449b14b"
version = "1.10.0"

[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
version = "1.11.0"

[[DocStringExtensions]]
deps = ["LibGit2"]
Expand All @@ -109,19 +101,19 @@ uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"

[[ForwardDiff]]
deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions", "StaticArrays"]
git-tree-sha1 = "1bd6fc0c344fc0cbee1f42f8d2e7ec8253dda2d2"
git-tree-sha1 = "2f18915445b248731ec5db4e4a17e451020bf21e"
uuid = "f6369f11-7733-5829-9624-2563aa707210"
version = "0.10.25"
version = "0.10.30"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[InverseFunctions]]
deps = ["Test"]
git-tree-sha1 = "91b5dcf362c5add98049e6c29ee756910b03051d"
git-tree-sha1 = "b3364212fb5d870f724876ffcd34dd8ec6d98918"
uuid = "3587e190-3f89-42d0-90ee-14403ec27112"
version = "0.1.3"
version = "0.1.7"

[[IrrationalConstants]]
git-tree-sha1 = "7fd44fd4ff43fc60815f8e764c0f352b83c49151"
Expand Down Expand Up @@ -171,9 +163,9 @@ uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[LogExpFunctions]]
deps = ["ChainRulesCore", "ChangesOfVariables", "DocStringExtensions", "InverseFunctions", "IrrationalConstants", "LinearAlgebra"]
git-tree-sha1 = "a970d55c2ad8084ca317a4658ba6ce99b7523571"
git-tree-sha1 = "09e4b894ce6a976c354a69041a04748180d43637"
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
version = "0.3.12"
version = "0.3.15"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
Expand All @@ -189,10 +181,10 @@ deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[MathOptInterface]]
deps = ["BenchmarkTools", "CodecBzip2", "CodecZlib", "JSON", "LinearAlgebra", "MutableArithmetics", "OrderedCollections", "Printf", "SparseArrays", "Test", "Unicode"]
git-tree-sha1 = "779ad2ee78c4a24383887fdba177e9e5034ce207"
deps = ["BenchmarkTools", "CodecBzip2", "CodecZlib", "DataStructures", "ForwardDiff", "JSON", "LinearAlgebra", "MutableArithmetics", "NaNMath", "OrderedCollections", "Printf", "SparseArrays", "SpecialFunctions", "Test", "Unicode"]
git-tree-sha1 = "10d26d62dab815306bbd2c46eb52460e98f01e46"
uuid = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
version = "1.1.2"
version = "1.6.0"

[[MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
Expand All @@ -206,14 +198,14 @@ uuid = "14a3606d-f60d-562e-9121-12d972cd8159"

[[MutableArithmetics]]
deps = ["LinearAlgebra", "SparseArrays", "Test"]
git-tree-sha1 = "ba8c0f8732a24facba709388c74ba99dcbfdda1e"
git-tree-sha1 = "4e675d6e9ec02061800d6cfb695812becbd03cdf"
uuid = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
version = "1.0.0"
version = "1.0.4"

[[NaNMath]]
git-tree-sha1 = "b086b7ea07f8e38cf122f5016af580881ac914fe"
git-tree-sha1 = "737a5957f387b17e74d4ad2f440eb330b39a62c5"
uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
version = "0.3.7"
version = "1.0.0"

[[NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
Expand All @@ -234,26 +226,26 @@ uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.4.1"

[[ParametricOptInterface]]
deps = ["DataStructures", "MathOptInterface"]
git-tree-sha1 = "a5a7d207546a5148d59f0ec43b7475f586146e29"
deps = ["MathOptInterface"]
git-tree-sha1 = "4f0dfcc0c4f42c1baf4774ba9c0a397ae309c625"
uuid = "0ce4ce61-57bf-432b-a095-efac525d185e"
version = "0.3.2"
version = "0.4.1"

[[Parsers]]
deps = ["Dates"]
git-tree-sha1 = "621f4f3b4977325b9128d5fae7a8b4829a0c2222"
git-tree-sha1 = "0044b23da09b5608b4ecacb4e5e6c6332f833a7e"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.2.4"
version = "2.3.2"

[[Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[Preferences]]
deps = ["TOML"]
git-tree-sha1 = "d3538e7f8a790dc8903519090857ef8e1283eecd"
git-tree-sha1 = "47e5f437cc0e7ef2ce8406ce1e7e24d44915f88d"
uuid = "21216c6a-2e73-6563-6e65-726566657250"
version = "1.2.5"
version = "1.3.0"

[[Printf]]
deps = ["Unicode"]
Expand All @@ -277,10 +269,6 @@ uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[SharedArrays]]
deps = ["Distributed", "Mmap", "Random", "Serialization"]
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"

[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

Expand All @@ -290,15 +278,20 @@ uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[SpecialFunctions]]
deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"]
git-tree-sha1 = "5ba658aeecaaf96923dce0da9e703bd1fe7666f9"
git-tree-sha1 = "d75bda01f8c31ebb72df80a46c88b25d1c79c56d"
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
version = "2.1.4"
version = "2.1.7"

[[StaticArrays]]
deps = ["LinearAlgebra", "Random", "Statistics"]
git-tree-sha1 = "4f6ec5d99a28e1a749559ef7dd518663c5eca3d5"
deps = ["LinearAlgebra", "Random", "StaticArraysCore", "Statistics"]
git-tree-sha1 = "e972716025466461a3dc1588d9168334b71aafff"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.4.3"
version = "1.5.1"

[[StaticArraysCore]]
git-tree-sha1 = "66fe9eb253f910fe8cf161953880cfdaef01cdf0"
uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
version = "1.0.1"

[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
Expand Down
24 changes: 24 additions & 0 deletions src/ParametricOptInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ mutable struct Optimizer{T,OT<:MOI.ModelLike} <: MOI.AbstractOptimizer
affine_constraint_cache::MOI.Utilities.DoubleDicts.DoubleDict{
Vector{MOI.ScalarAffineTerm{Float64}},
}
# Store constraint set
affine_constraint_cache_set::MOI.Utilities.DoubleDicts.DoubleDict{
MOI.AbstractScalarSet,
}
# Store reference quadratic constraints with parameter * variable constraints: p * v
quadratic_constraint_cache_pv::MOI.Utilities.DoubleDicts.DoubleDict{
Vector{MOI.ScalarQuadraticTerm{Float64}},
Expand All @@ -119,10 +123,18 @@ mutable struct Optimizer{T,OT<:MOI.ModelLike} <: MOI.AbstractOptimizer
quadratic_constraint_cache_pp::MOI.Utilities.DoubleDicts.DoubleDict{
Vector{MOI.ScalarQuadraticTerm{Float64}},
}
# Store constraint set
quadratic_constraint_cache_pp_set::MOI.Utilities.DoubleDicts.DoubleDict{
MOI.AbstractScalarSet,
}
# Store reference to constraints with quad_variable_term + affine_with_parameters: v * v + p
quadratic_constraint_cache_pc::MOI.Utilities.DoubleDicts.DoubleDict{
Vector{MOI.ScalarAffineTerm{Float64}},
}
# Store constraint set
quadratic_constraint_cache_pc_set::MOI.Utilities.DoubleDicts.DoubleDict{
MOI.AbstractScalarSet,
}
# Store the reference to variables in the scalar affine part that are
# multiplied by parameters in the scalar quadratic terms.
# i.e.
Expand Down Expand Up @@ -195,15 +207,18 @@ mutable struct Optimizer{T,OT<:MOI.ModelLike} <: MOI.AbstractOptimizer
MOI.Utilities.DoubleDicts.DoubleDict{
Vector{MOI.ScalarAffineTerm{Float64}},
}(),
MOI.Utilities.DoubleDicts.DoubleDict{MOI.AbstractScalarSet}(),
MOI.Utilities.DoubleDicts.DoubleDict{
Vector{MOI.ScalarQuadraticTerm{Float64}},
}(),
MOI.Utilities.DoubleDicts.DoubleDict{
Vector{MOI.ScalarQuadraticTerm{Float64}},
}(),
MOI.Utilities.DoubleDicts.DoubleDict{MOI.AbstractScalarSet}(),
MOI.Utilities.DoubleDicts.DoubleDict{
Vector{MOI.ScalarAffineTerm{Float64}},
}(),
MOI.Utilities.DoubleDicts.DoubleDict{MOI.AbstractScalarSet}(),
MOI.Utilities.DoubleDicts.DoubleDict{
Vector{MOI.ScalarAffineTerm{Float64}},
}(),
Expand Down Expand Up @@ -249,9 +264,12 @@ function MOI.is_empty(model::Optimizer)
isempty(model.affine_added_cache) &&
model.last_affine_added == 0 &&
isempty(model.affine_constraint_cache) &&
isempty(model.affine_constraint_cache_set) &&
isempty(model.quadratic_constraint_cache_pv) &&
isempty(model.quadratic_constraint_cache_pp) &&
isempty(model.quadratic_constraint_cache_pp_set) &&
isempty(model.quadratic_constraint_cache_pc) &&
isempty(model.quadratic_constraint_cache_pc_set) &&
isempty(
model.quadratic_constraint_variables_associated_to_parameters_cache,
) &&
Expand Down Expand Up @@ -421,9 +439,12 @@ function MOI.empty!(model::Optimizer{T}) where {T}
empty!(model.affine_added_cache)
model.last_affine_added = 0
empty!(model.affine_constraint_cache)
empty!(model.affine_constraint_cache_set)
empty!(model.quadratic_constraint_cache_pv)
empty!(model.quadratic_constraint_cache_pp)
empty!(model.quadratic_constraint_cache_pp_set)
empty!(model.quadratic_constraint_cache_pc)
empty!(model.quadratic_constraint_cache_pc_set)
empty!(model.quadratic_constraint_variables_associated_to_parameters_cache)
empty!(model.quadratic_added_cache)
empty!(model.quadratic_objective_cache_product)
Expand Down Expand Up @@ -841,6 +862,8 @@ function create_new_poi_ci_and_save_affine_caches(
model.last_affine_added,
)
model.affine_constraint_cache[poi_ci] = params
model.affine_constraint_cache_set[poi_ci] =
MOI.get(model.optimizer, MOI.ConstraintSet(), moi_ci)
model.affine_added_cache[poi_ci] = moi_ci
return poi_ci
end
Expand Down Expand Up @@ -1219,6 +1242,7 @@ function add_constraint_with_parameters_on_function(
quad_params,
aff_params,
terms_with_variables_associated_to_parameters,
ci,
)
return new_ci
end
Expand Down
Loading