@@ -578,6 +578,59 @@ getshift(x::Symbolic) = Symbolics.getmetadata(x, VariableShift, 0)
578578# ##################
579579# ## Evaluate at ###
580580# ##################
581+ """
582+ EvalAt(t)
583+
584+ An operator that evaluates time-dependent variables at a specific absolute time point `t`.
585+
586+ # Fields
587+ - `t::Union{Symbolic, Number}`: The absolute time at which to evaluate the variable.
588+
589+ # Description
590+ `EvalAt` is used to evaluate time-dependent variables at a specific time point. This is particularly
591+ useful in optimization problems where you need to specify constraints or costs at particular moments
592+ in time, or delay differential equations for setting a delay time.
593+
594+ The operator works by replacing the time argument of time-dependent variables with the specified
595+ time `t`. For variables that don't depend on time, `EvalAt` returns them unchanged.
596+
597+ # Behavior
598+ - For time-dependent variables like `x(t)`, `EvalAt(τ)(x)` returns `x(τ)`
599+ - For time-independent parameters, `EvalAt` returns them unchanged
600+ - For derivatives, `EvalAt` evaluates the derivative at the specified time
601+ - For arrays of variables, `EvalAt` is applied element-wise
602+
603+
604+ # Examples
605+ ```julia
606+ using ModelingToolkit
607+
608+ @variables t x(t) y(t)
609+ @parameters p
610+
611+ # Evaluate x at time t=1.0
612+ EvalAt(1.0)(x) # Returns x(1.0)
613+
614+ # Works with parameters (returns unchanged)
615+ EvalAt(1.0)(p) # Returns p
616+
617+ # Works with derivatives
618+ D = Differential(t)
619+ EvalAt(1.0)(D(x)) # Returns D(x) evaluated at t=1.0
620+
621+ # Use in optimization constraints
622+ @optimization_model model begin
623+ @constraints begin
624+ EvalAt(0.5)(x) ~ 2.0 # x must equal 2.0 at t=0.5
625+ end
626+ end
627+ ```
628+
629+ # Errors
630+ - Throws an error when applied to variables with more than one argument (e.g., `z(u, t)`)
631+
632+ See also: [`Differential`](@ref)
633+ """
581634struct EvalAt <: Symbolics.Operator
582635 t:: Union{Symbolic, Number}
583636end
0 commit comments