Skip to content

Option to assign numerical value to parameter_variables #75

Description

@jtheinen

For the sake of writing the code logically within pycollo, would it be possible to assign numerical values to parameter_variables? Such that the user throw in all single value parameters (optimized or not) in the description of the OCP.

Whenever the bound would be set to a single value, the parameter variable should be treated as a variable that has a numerical value assigned through aux data.

Whenever the bound is set to a range [0,1], the parameter variable will be optimized. Just like how an initial value would be handled (either bound or single value)

Whenever auxiliary data is assigned, parameter variables will be treated as a constant numerical value.

What happens now when parameter variable is assigned with aux data:

Minimal Reproduction

problem = pycollo.OptimalControlProblem(
name="Simple Block Slide",
parameter_variables= (m,mu,g)
)

problem.auxiliary_data = {
m: 1,
mu: 1,
g: 1
}

(same error output when removing following two lines)
problem.bounds.parameter_variables = [[1,1.1], [1,1.1], [1,1.1]]
problem.guess.parameter_variables = [1, 1, 1]

Solution

remove "parameter_variables= (m,mu,g)"

Error msg

self._initialise_backend()

self.preprocess_user_problem_aux_data()

self.preprocess_user_phase_independent_aux_data()

self.add_aux_data_mapping((backend_sym, ), (backend_eqn, ))

UnboundLocalError: cannot access local variable 'backend_sym' where it is not associated with a value

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions