1 core.parameters.Parameter

core.parameters.Parameter(name, value=0.0)

An updatable constant for optimization problems.

Unlike Constant, a Parameter’s value can be changed between solves without rebuilding the problem structure. This enables fast re-solves when only numerical values change (not problem structure).

Parameters participate in expression building just like variables, but their values are fixed during each solve. Changing a parameter value and re-solving uses cached problem structure.

1.1 Parameters

Name Type Description Default
name str Unique identifier for this parameter. required
value float | int | ArrayLike Initial value (scalar or array). 0.0

1.2 Example

from optyx import Variable, Parameter, Problem

x = Variable(“x”, lb=0) price = Parameter(“price”, value=100)

prob = Problem().maximize(price * x - x**2).subject_to(x <= 10)

2 Initial solve

sol1 = prob.solve()

3 Price changes - fast re-solve

price.set(120) sol2 = prob.solve() # Uses cached structure

3.1 Attributes

Name Description
value Get the current parameter value.

3.2 Methods

Name Description
evaluate Evaluate the parameter (returns current value).
get_variables Return all variables this expression depends on.
set Update the parameter value.

3.2.1 evaluate

core.parameters.Parameter.evaluate(values)

Evaluate the parameter (returns current value).

Parameters evaluate to their stored value, not from the values dict. This allows parameters to be updated independently of solve calls.

3.2.1.1 Parameters

Name Type Description Default
values Mapping[str, ArrayLike | float] Variable values (not used for parameters). required

3.2.1.2 Returns

Name Type Description
NDArray[np.floating] | float The current parameter value.

3.2.2 get_variables

core.parameters.Parameter.get_variables()

Return all variables this expression depends on.

Parameters are not variables - they return an empty set.

3.2.3 set

core.parameters.Parameter.set(value)

Update the parameter value.

This can be called between solves to change the parameter value without rebuilding the problem structure.

3.2.3.1 Parameters

Name Type Description Default
value float | int | ArrayLike New value (scalar or array, must match original shape). required

3.2.3.2 Raises

Name Type Description
ValueError If array shape doesn’t match original.

3.2.3.3 Example

price = Parameter(“price”, value=100) price.set(120) # Update for next solve price.value 120.0