Skip to content

Commit

Permalink
Default (zero) objective
Browse files Browse the repository at this point in the history
  • Loading branch information
andgoldschmidt committed Nov 30, 2023
1 parent 42adb95 commit d439ccb
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/objectives.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Objectives

export Objective

export DefaultObjective
export QuantumObjective
export QuantumStateObjective
export QuantumUnitaryObjective
Expand Down Expand Up @@ -85,6 +85,36 @@ function sparse_to_moi(A::SparseMatrixCSC)
vals = [A[i,j] for (i,j) inds]
return (inds, vals)
end

"""
DefaultObjective
"""
function DefaultObjective()
params = Dict()

Check warning on line 95 in src/objectives.jl

View check run for this annotation

Codecov / codecov/patch

src/objectives.jl#L94-L95

Added lines #L94 - L95 were not covered by tests

@views function L(Z⃗::AbstractVector{<:Real}, Z::NamedTrajectory)
return 0.0

Check warning on line 98 in src/objectives.jl

View check run for this annotation

Codecov / codecov/patch

src/objectives.jl#L97-L98

Added lines #L97 - L98 were not covered by tests
end

@views function ∇L(Z⃗::AbstractVector{<:Real}, Z::NamedTrajectory)
= zeros(Z.dim * Z.T)
return

Check warning on line 103 in src/objectives.jl

View check run for this annotation

Codecov / codecov/patch

src/objectives.jl#L101-L103

Added lines #L101 - L103 were not covered by tests
end

function ∂²L_structure(Z::NamedTrajectory)
structure = []
return structure

Check warning on line 108 in src/objectives.jl

View check run for this annotation

Codecov / codecov/patch

src/objectives.jl#L106-L108

Added lines #L106 - L108 were not covered by tests
end

@views function ∂²L(Z⃗::AbstractVector{<:Real}, Z::NamedTrajectory; return_moi_vals=true)
return return_moi_vals ? [] : spzeros(Z.dim * Z.T, Z.dim * Z.T)

Check warning on line 112 in src/objectives.jl

View check run for this annotation

Codecov / codecov/patch

src/objectives.jl#L111-L112

Added lines #L111 - L112 were not covered by tests
end

return Objective(L, ∇L, ∂²L, ∂²L_structure, Dict[params])

Check warning on line 115 in src/objectives.jl

View check run for this annotation

Codecov / codecov/patch

src/objectives.jl#L115

Added line #L115 was not covered by tests
end

"""
QuantumObjective
Expand Down

0 comments on commit d439ccb

Please sign in to comment.