Skip to content

Feature/componentarray input output#21

Open
samuelcohen1 wants to merge 16 commits into
AlgebraicJulia:mainfrom
samuelcohen1:feature/componentarray-input-output
Open

Feature/componentarray input output#21
samuelcohen1 wants to merge 16 commits into
AlgebraicJulia:mainfrom
samuelcohen1:feature/componentarray-input-output

Conversation

@samuelcohen1

Copy link
Copy Markdown
Contributor

This includes the changes from my other PR, plus:

  • Support for vector variables in ComponentArray input/output
  • A new test case using vector variables with ComponentArray input/output
  • Bug fix in ComponentArray input/output

@tylerhanks tylerhanks left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall a very nice PR. I think there are some small specifics to clean up that I left comments on.

Comment thread src/Optimizers.jl
# Implement the cospan-algebra of dynamical systems.
module Optimizers

export pullback_matrix, pushforward_matrix, Optimizer, OpenContinuousOpt, OpenDiscreteOpt, Euler,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should still support the matrix versions of these functions.

Comment thread src/Optimizers.jl Outdated
export pullback_matrix, pushforward_matrix, Optimizer, OpenContinuousOpt, OpenDiscreteOpt, Euler,
simulate
export Optimizer, OpenContinuousOpt, OpenDiscreteOpt, Euler,
simulate, pullback_function, pushforward_function, isapprox

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's bad practice to export functions from Base. We should just define the version of isapprox we need in the relevant test file (it's not critical to the function of this package).

Comment thread src/Optimizers.jl



""" pullback_function(f::FinFunction, v::Vector)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want pullback and pushforward functions to return the functions that do the pushforward and pullback when applied to a vector (similar to the matrix versions). This is because usually we will be calling pushforward and pullback with the same finfunction but different vectors over and over. So it would be nice to generate the function for a single finfunction once and then be able to call that multiple times on different inputs. This also maintains consistency with the matrix version.

Comment thread src/Optimizers.jl

end No newline at end of file
# Run a discrete optimizer the designated number of time-steps.
function simulate(f::Open{Optimizer}, d::AbstractUWD, x0::ComponentArray, tsteps::Int)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't fight the feeling that there is a simpler/cleaner way to do this. I'm not sure what it is, but I will think about it.

Comment thread test/Objectives.jl Outdated


# Test ComponentArray version of input/output on scalar variables
# Note that all variables must be exposed to use this i/o system

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do all variables have to be exposed?

Comment thread test/Objectives.jl Outdated
dc2 = composite_of_optimizers


x2 = ComponentArray(a=11.0, b=22, c=33, d=44, e=55, f=66, g=77, h=88, i=99)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there an i component here when there is no i variable in the UWD?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants