Skip to content

Accessing parameter values in a finalize_solution function #6

Description

@rseydam

Hi,

I am trying to use a finalize_solution inside MPC.continuation(...) .

I assume that whenever the function put in for finalize_solution returns true, it is accepted and the solution will be calculated; if it returns false, it is rejected.

In my function, I want to check several things. First, I am checking if all variables are positive. Secondly, I want to constrain the calculation to certain parameter ranges.

function boundary_finalizer(u, p)
    # Check dynamical variables > 0
    if any(x -> x <= 0, u)
        return false
    end

    # Read parameters from p
    γ = getproperty(p, :γ)
    n = getproperty(p, :n)
    ε_glu = getproperty(p, :ε_glu)

	@info "Called finalizer (accept) γ=$(γ), n=$(n), ε_glu=$(ε_glu)"

    # Check parameter ranges
    if !(0.01 <= γ <= 3.5) || !(0.01 <= n <= 1.0) || !(1e-7 <= ε_glu <= 0.2)
        return false
    end

    return true  # all conditions met
end

When I access the parameters in this manner, they remain constant during the calculation of all charts. How can I access the actual parameters on the current chart?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions