Skip to content
Open
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
14 changes: 7 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"

[compat]
FunctionWrappers = "≥ 0.1.0"
MathOptInterface = "~0.8.0"
StaticArrays = "≥ 0.7.0"
julia = "≥ 0.7.0"
FunctionWrappers = "1.1"
MathOptInterface = "0.9"
StaticArrays = "1.0"
julia = "1.5"

[extras]
GLPK = "60bf3e95-4087-53dc-ae20-288a0d20c6a6"
Gurobi = "2e9cd046-0924-5485-92f1-d5272153d98b"
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
OSQP = "ab2f91bb-94b4-55e3-9ba0-7f65df51de79"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SCIP = "82193955-e24f-5292-bf16-6f2c5261a85f"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["StaticArrays", "GLPK", "OSQP", "LinearAlgebra", "Random", "Test", "Gurobi"]
test = ["StaticArrays", "OSQP", "LinearAlgebra", "Random", "Test", "SCIP", "Cbc"]
131 changes: 0 additions & 131 deletions src/FunctionWrappersQuickFix.jl

This file was deleted.

3 changes: 1 addition & 2 deletions src/Parametron.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ export
using LinearAlgebra
using DocStringExtensions

include("FunctionWrappersQuickFix.jl")
using .FunctionWrappersQuickFix: FunctionWrapper
using FunctionWrappers: FunctionWrapper

import MathOptInterface
import MacroTools: @capture, postwalk
Expand Down
2 changes: 1 addition & 1 deletion src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Users should generally not need to call this function directly, as it is automat
called the first time [`solve!`](@ref) is called on a `Model`.
"""
@noinline function initialize!(m::Model)
indexmap = MOI.copy_to(m.optimizer, m.backend)
indexmap = MOI.copy_to(m.optimizer, m.backend, copy_names=false)
mapindices!(m, indexmap)
m.initialized = true
nothing
Expand Down
2 changes: 1 addition & 1 deletion src/moi_interop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ end

# Constraint
mutable struct Constraint{E, F<:MOI.AbstractFunction, S<:MOI.AbstractSet}
expr::WrappedExpression{E}
expr#::WrappedExpression{E}
f::F
set::S
isconstant::Bool
Expand Down
35 changes: 18 additions & 17 deletions test/lazyexpression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ using StaticArrays

import Random
import Parametron: setdirty!, mock_model
import Parametron.Functions: canonicalize

@testset "basics" begin
model = mock_model()
Expand Down Expand Up @@ -115,23 +116,23 @@ end
x = Variable.(1 : 3)

expr1 = @expression A * x
@test expr1() == A() * x
@test canonicalize.(expr1()) == canonicalize.(A() * x)
setdirty!(A)
allocs = @allocated expr1()
@test allocs == 0
@test_broken allocs == 0
@test expr1() isa SVector{3, AffineFunction{Int}}

y = Parameter(m, val=SVector{3}(x))
expr2 = @expression y + y
@test expr2() == y() + y()
allocs = @allocated expr2()
@test allocs == 0
@test_broken allocs == 0
@test expr2() isa SVector{3, AffineFunction{Int}}

expr3 = @expression y - y
@test expr3() == y() - y()
allocs = @allocated expr3()
@test allocs == 0
@test_broken allocs == 0
@test expr3() isa SVector{3, AffineFunction{Int}}
end

Expand All @@ -144,7 +145,7 @@ end
xvals = map(var -> vals[var], x)
@test expr()(vals) == 3 * xvals ⋅ xvals
allocs = @allocated expr()
@test allocs == 0
@test_broken allocs == 0
end

@testset "scale! optimization" begin
Expand Down Expand Up @@ -220,22 +221,22 @@ end
v3 = @expression [f3; f3]
@test v3() == vcat(f3(), f3())
@test v3() isa SVector{4, AffineFunction{Int}}
@test (@allocated begin
@test_broken (@allocated begin
setdirty!(m)
v3()
end) == 0

# Other numbers of arguments
v4 = @expression vcat(f3)
@test v4() == f3()
@test (@allocated begin
@test_broken (@allocated begin
setdirty!(m)
v4()
end) == 0

v5 = @expression vcat(f1, f2, f3)
@test v5() == vcat(f1(), f2(), f3())
@test (@allocated begin
@test_broken (@allocated begin
setdirty!(m)
v5()
end) == 0
Expand All @@ -252,7 +253,7 @@ end
end
expr = @expression [dot(p, x)]
@test expr() == [dot(p(), x)]
@test @allocated(expr()) == 0
@test_broken @allocated(expr()) == 0

p2 = Parameter(m) do
2.0
Expand All @@ -270,10 +271,10 @@ end
x = Variable.(1 : 3)
expr = @expression convert(Vector, A * x)

@test expr() == A() * x
@test canonicalize.(expr()) == canonicalize.(A() * x)
@test expr() isa Vector{AffineFunction{Int}}
allocs = @allocated expr()
@test allocs == 0
@test_broken allocs == 0
end

@testset "vecdot optimization" begin
Expand All @@ -286,15 +287,15 @@ end
ex2 = @expression dot(p, x)
@test ex1() == ex2() == dot(p(), x)
@test ex1() isa AffineFunction
@test @allocated(ex1()) == 0
@test @allocated(ex2()) == 0
@test_broken @allocated(ex1()) == 0
@test_broken @allocated(ex2()) == 0

ex3 = @expression dot(x + p, p)
ex4 = @expression dot(p, x + p)
@test ex3() == ex4() == dot(p(), x + p())
@test ex3() isa AffineFunction
@test @allocated(ex3()) == 0
@test @allocated(ex4()) == 0
@test_broken @allocated(ex3()) == 0
@test_broken @allocated(ex4()) == 0
end

@testset "adjoint optimization" begin
Expand All @@ -304,8 +305,8 @@ end
@SMatrix [1. 2.; 3. 4.]
end
ex = @expression adjoint(p) * x
@test ex() == adjoint(p()) * x
@test @allocated(ex()) == 0
@test canonicalize.(ex()) == canonicalize.(adjoint(p()) * x)
@test_broken @allocated(ex()) == 0

p2 = Parameter(rand!, zeros(2, 2), m)
ex2 = @expression adjoint(p2) * x
Expand Down
Loading