Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Redundant Definition #153

Merged
merged 6 commits into from
Jun 23, 2021
Merged

Prevent Redundant Definition #153

merged 6 commits into from
Jun 23, 2021

Conversation

pulsipher
Copy link
Collaborator

@pulsipher pulsipher commented Jun 23, 2021

This closes #146. It also allows us to use macro defined derivatives repeatedly without erroring unlike before.

With v0.4.0:

function test()
       m=InfiniteModel()
       @infinite_parameter(m, t in [0, 10], derivative_method = OrthogonalCollocation(4), num_supports = 100)
       @infinite_parameter(m, x[1:2] in [0, 1], num_supports = 20)
       @variable(m, y >= 0, Infinite(t))
       @variable(m, q, Infinite(t, x))
       @objective(m, Min, integral(y + integral(q^2, x), t))
       @constraint(m, deriv(y, t) == 2y + 2)
       @constraint(m, deriv(q, t) == q + y)
       @constraint(m, y * q - 2 <= 2)
       build_optimizer_model!(m)
end
@time test()
1.228544 seconds (6.01 M allocations: 388.745 MiB, 7.29% gc time)

With this branch:

@time test()
0.939251 seconds (4.64 M allocations: 311.325 MiB, 11.42% gc time)

Hence, we have a significant decrease in the amount of memory and allocations. However, there isn't really a speed up since redundant definition wasn't a rate determining step.

@pulsipher pulsipher added the bug Something isn't working label Jun 23, 2021
@pulsipher pulsipher added this to the v0.4.1 milestone Jun 23, 2021
@codecov
Copy link

codecov bot commented Jun 23, 2021

Codecov Report

Merging #153 (6cab6a6) into master (a275ada) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master     #153    +/-   ##
========================================
  Coverage   99.96%   99.96%            
========================================
  Files          32       32            
  Lines        6185     6286   +101     
========================================
+ Hits         6183     6284   +101     
  Misses          2        2            
Impacted Files Coverage Δ
src/TranscriptionOpt/model.jl 100.00% <ø> (ø)
src/TranscriptionOpt/transcribe.jl 99.69% <ø> (-0.01%) ⬇️
src/TranscriptionOpt/measures.jl 100.00% <100.00%> (ø)
src/datatypes.jl 100.00% <100.00%> (ø)
src/derivative_evaluations.jl 100.00% <100.00%> (ø)
src/derivatives.jl 100.00% <100.00%> (ø)
src/finite_variables.jl 100.00% <100.00%> (ø)
src/infinite_variables.jl 100.00% <100.00%> (ø)
src/measure_expansions.jl 100.00% <100.00%> (ø)
src/point_variables.jl 100.00% <100.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a275ada...6cab6a6. Read the comment docs.

@pulsipher pulsipher merged commit add2e82 into master Jun 23, 2021
@pulsipher pulsipher deleted the remove_redundancy branch June 23, 2021 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent Redundant Point/Semi-Infinite Variable Definition
1 participant