Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with time-varying edge variables when multiple nodes are used #35

Open
NinaOmejc opened this issue Aug 17, 2023 · 6 comments
Open

Comments

@NinaOmejc
Copy link

Dear Richard,

I've been trying to use your software to do some simulations of coupled Kuramoto oscillators. However, I'm having some issues.

I attach a file, with which I am running three coupled Kuramoto oscillators. As I want to have time varying coupling, I am trying to use
the 'trick' you mention in one of your github issues, that a variable can be given as an input. It seems this works for two oscillators, but for three, something seems weird. In the code, first oscillator is a slow one, trying to be coupled with the other faster two. I coupled 0-1 and 0-2 oscillators at the same time, with the same weights but when I plot the results, the coupling is seen in only 0-1 oscillators, but not between the 0-2 oscillators. I have tried to vary several properties, such as different timing of the second coupling, different frequencies, different edge combinations, either putting the coupling weight to the "weight" or to my time varying coupling variable "Ks" ... nothing worked the way as I would like it to... to have coupling between 0-1 oscillators, and then 0-2 oscillators (either during the same or during different time window).

Can you see the problem? I would really appreaciate your help.

Thank you and kind regards,
Nina
test_kuramoto.zip

@Richert
Copy link
Member

Richert commented Aug 17, 2023

Hi Nina,

Thank you for bringing this to my attention! There indeed seems to be a bug when using edge operators with multiple input variables in combination with the vectorize=True keyword argument of the CircuitTemplate.run method (which is also the default value of that keyword argument).

I will look into this and make sure that this bug is fixed as soon as possible. Until then, you should be able to use vectorize=False as a temporary bugfix.

Best, Richard

@NinaOmejc
Copy link
Author

NinaOmejc commented Aug 17, 2023

Hi,

the setting vectorize=False worked and solve my issue, thank you very much!

@NinaOmejc
Copy link
Author

I have one more question, somehow related to this, if you are willing to discuss.

Currently, my time varying variable of coupling strength is inside the node operator and is thus affecting the coupling strength to all other nodes inside a network. Is there a way to add a time varying parameter to the edge operator? I read that the "weight" can only be a scalar. Also, when I tried to add an "input variable" to the "equation" and "variables" inside edge operator and set it inside the edge dictionary (next to the weigth and other parameters), pyrates didnt like it.

So, since the weights of the edges have to be fixed, there is no way to vary them in time, except to design and run the model again, so a bit more manually? Or is there a way with some internal settings?

A similar topic has already been discussed inside the "Continuous data generation" issue, but it was only discussed in the relation to the variables inside the node operator..

Thank you!

@Richert
Copy link
Member

Richert commented Aug 17, 2023

Hi Nina,

indeed external inputs cannot be placed on edges at the moment. It is a feature to consider for the future, for sure, but currently it's not supported.
What is supported is to define edge operators via differential equations on edges, if it were possible to express the edge dynamics you are interested in via a differential equation.

Another possibility is that you define a node-specific output variable that is scaled by some extrinsic input and that you could use as the source variable of any edge. This way, you could scale all the outputs (rather than the inputs) of a given node in a time-dependent fashion.

Finally, as a work-around, there is always the possibility to define multiple input variables on a node and define separate extrinsic inputs for them (for example in_total = ext_1*in_1 + ext_2*in_2 + in_3). Then you connect the edges to different input variables and achieve a separation like that.

Hope that helps!

Best, Richard

@NinaOmejc
Copy link
Author

Hi,

thanks for the last comments! I've been trying to figure out what exactly you meant by your proposals and somehow came up with the version attached below, which works for me. I post it here in case some one is interested or if you have any comments on it. I guess the downside is that for e.g. 20 couplings, I would have 20 new variables + 20 new inputs, but I guess that is inevitable to some degree.

The approach is also great, because now I can use delays with any issue (as compared to separate runs of simulation).

Thanks again for all the help!

test_kuramoto.zip

@Richert
Copy link
Member

Richert commented Aug 19, 2023

Hi Nina,

well if you really want to control 20 different incoming connections via 20 distinct extrinsic signals, that is true. However, if you, for example, want to apply one extrinsic input pattern to one group of incoming connections, and a different input to the second group, you would still be fine with 2 new variables + inputs.

Of course, always happy to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants