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

[Feature]: Parametric names for components #38

Open
3 of 6 tasks
makzator opened this issue May 16, 2024 · 1 comment
Open
3 of 6 tasks

[Feature]: Parametric names for components #38

makzator opened this issue May 16, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@makzator
Copy link
Contributor

Feature Description

A NamedTrajectory is created by passing a NamedTuple of components that combines component names with initial data. I recently encountered the scenario that during optimization I wanted to access trajectory data stored under multiple different names using a single reference, e.g.:

# define components
components = (
  psi0_iso = rand(2d, T),
  psi1_iso = rand(2d, T),
  a = rand(2, T),
  dts = rand(1, T)
)

# build trajectory
traj = NamedTrajectory(components; timestep=:dts, controls=:a)

# now wishing to access a concatenation of psi0_iso and psi1_iso
# under a virtual reference psi_iso
traj.psi_iso == vcat(traj.psi0_iso, traj.psi1_iso)

An alternative example would be to only access part of a component, e.g.:

traj.psi0_im == traj.psi0_iso[(d+1):end,:]

Such virtual names / references would be helpful for convenience and maybe other purposes. In my case I wanted to use predefined infidelity objectives but on concatenated statevectors.

One way to implement this could be:

# define virtual names and what components + indices they correspond to
vnames = (
  psi_iso = [
      (:psi0_iso, 1:2d),
      (:psi1_iso, 1:2d)
    ],
  psi0_im = [
    (:psi0_iso, (d+1):2d)
  ]
)

# build trajectory with optional arg
traj = NamedTrajectory(components; timestep=:dts, controls=:a, vnames=vnames)

Importance

1 (lowest)

What does this feature affect?

  • construction
  • methods
  • plotting
  • documentation
  • tests
  • other (please specify below)

Other information

No response

@makzator makzator added the enhancement New feature or request label May 16, 2024
@aarontrowbridge
Copy link
Member

i like this idea, it seems like it should be pretty easy to implement too

@andgoldschmidt andgoldschmidt changed the title [Feature]: Virtual names [Feature]: Parametric names for components Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants