Query: Parameter Expressions in Circuits

Hi,

I’m wondering if there is a way to include parameterised expressions in circuit components in Perceval.

For example, let’s say I have two circuit components and a single parameter x1. One component has value 0.5 * x1, and another has 2 * pi * x1.
I’m wondering if I could do something like x1.set_value(1), and the components are automatically assigned 0.5, and 2 * pi respectively.

I’m aware I can manually assign each component in this way, but for the code I am working with, it would be significantly easier to have these expressions built into each component.

Thanks,

Hi,

Perceval variable parameters are only able to take a floating point real value for the moment. With the current code, there’s no way to inject an expression (such as 2 * pi * x1) as the value of a Perceval parameter. We’re also not working on this feature at the moment.

So, for now, you need to manually write code dealing with these expressions by yourself.

def custom_set_parameter(x1_value: float):
    x1_2_pi = 2*math.pi*x1_value
    x1_over_2 = x1_value / 2
    parameter_A.set_value(x1_2_pi)
    parameter_B.set_value(x1_over_2)

Best,
Eric

Thanks for your help, Eric!