Skip to content

[Feature]: Parametric names for components #38

@makzator

Description

@makzator

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions