Eigenvector calculation

Use this forum to post Vensim related questions.
Post Reply
agroe
Junior Member
Posts: 9
Joined: Sun Feb 10, 2013 8:32 pm
Vensim version: DSS

Eigenvector calculation

Post by agroe »

Hi,

I am working with a symmetric matrix (2-dimensional array) and was wondering if there is any way to compute the eigenvalues and eigenvectors of this matrix within Vensim Professional at every Time Step (the matrix changes over time). Alternatively, is there a way to export the matrix to Excel, Matlab or any other software, perform the calculations there, and then reimport the calculated eigenvectors back into Vensim at every Time Step?

Any help is greatly appreciated!
Administrator
Super Administrator
Posts: 4838
Joined: Wed Mar 05, 2003 3:10 am

Re: Eigenvector calculation

Post by Administrator »

Can you fill in the serial number of your licence on your profile correctly please and we will be more than happy to help.

Tony.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
agroe
Junior Member
Posts: 9
Joined: Sun Feb 10, 2013 8:32 pm
Vensim version: DSS

Re: Eigenvector calculation

Post by agroe »

Hello Tony,

Ok, I found the mistake. I selected the wrong Vensim Version. Now it should be okay.

Kind regards,
Agroe
Administrator
Super Administrator
Posts: 4838
Joined: Wed Mar 05, 2003 3:10 am

Re: Eigenvector calculation

Post by Administrator »

Thanks. Sorry for the hassle, we've spent a long time in the past helping users who have acquired Vensim illegally.

I'll have to read up on eignevalues/vectors so will not get the chance to do this till Monday. Maybe Tom might will visit the forum later, he might know the answer without having to read up on it.

Tony.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
agroe
Junior Member
Posts: 9
Joined: Sun Feb 10, 2013 8:32 pm
Vensim version: DSS

Re: Eigenvector calculation

Post by agroe »

Thank you very much! I am looking forward to your suggestion.
tomfid
Administrator
Posts: 3995
Joined: Wed May 24, 2006 4:54 am

Re: Eigenvector calculation

Post by tomfid »

I don't think there's an easy way to do it within Vensim, but it would be an easy external function to write. You could either link to an external library, or incorporate a routine from something like Numerical Recipes. I might have some code lying around that would be useful - I'll look.

What do you need this for? There might be some other way ...
agroe
Junior Member
Posts: 9
Joined: Sun Feb 10, 2013 8:32 pm
Vensim version: DSS

Re: Eigenvector calculation

Post by agroe »

I need it to calculate the eigenvector centrality of nodes in a network. I only need to compute the eigenvector of the largest eigenvalue. In addition, it is a symmetrical matrix. This should facilitate the calculation of the respective eigenvector at every time step. If possible, it would be great if I could do this in Vensim without needing a second program, unless it is something common like Excel.
Could you tell me what such an external function would look like and how I could incorporate it in Vensim? Do you happen to know numerical recipes to calculate eigenvectors which are easy to implement within Vensim? If you have some code that would be perfect.
Thanks a lot!
tomfid
Administrator
Posts: 3995
Joined: Wed May 24, 2006 4:54 am

Re: Eigenvector calculation

Post by tomfid »

External functions are described in http://www.vensim.com/documentation/dss_external_fn.htm

One possibility would be to link in LINPACK. Numerical Recipes probably has a decent routine too.

Symmetry helps in general, but I'm not sure it makes it possible to solve the problem entirely within Vensim (no external functions).
LAUJJL
Senior Member
Posts: 1477
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: Eigenvector calculation

Post by LAUJJL »

Hi

You can do any programming in Vensim that lacks a current way to manage loops available in all procedural languages. The solution is to use subscripts and populate the different subscript values with the number generated within each loop.

Example joined that makes the following simplistic calculation but works with any kind of loop.

Value = 0
For I = 1 to 20
Value = value + (Time/time step)
EndI
Value = Value + preceding value at each time step

The model joined makes the calculation of Value for each time step.

You can too embed one loop into another, using a second subscript, but it becomes more tricky.

I have never used this method for my own models, and maybe in the long run it maybe more comfortable to use external routines especially if the algorithm is complex.
But I have too so far been able to avoid using external routines too. So it is diffucult to give an advice. I my case I use extensively the Reality checks features (wthout it I would be anuable to build my models). If I had to use an external routine, I would not be able to make RC tests within it, which might be quite annoying.

Of course whether you really need to calculate eigenvectors at each step is another story as Tom says.
I have a serious doubt about it.

Regards.
JJ
Attachments
loop_ programming.mdl
(2.22 KiB) Downloaded 625 times
agroe
Junior Member
Posts: 9
Joined: Sun Feb 10, 2013 8:32 pm
Vensim version: DSS

Re: Eigenvector calculation

Post by agroe »

Thank you very much for your suggestions! I'll have a closer look at them.
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Eigenvector calculation

Post by gwr »

Once you are down to Eigenvectors and Eigenvalues for a system of ODEs I would reccomend taking a close look at Mathematica (Wolfram Research). It offers the additional value of being a full fledged CAS so instead of having to go with numbers it will also handle systems symbolically (e.g. you can nicely use it to simplify long equations etc.). To me Mathematica has become pretty much a one fits (almost) all kind of solution (it as of now also completly integrates R if you need that for statistics) and I use Vensim for prototyping SD-models (unit checks, reality checks [@JJ ;-) ] and graphical front end) mainly. You can easily run the Vensim DLL using Mathematica (a description of how to do that can be found on this board). I believe that to be a very sophisticated combination by far beating excel solutions - especially once you have taken a closer look at Mathematica's graphics capabilities which will plot graphs and networks also.

I hope Tony and Tom will not "beat" me for promoting that solution but actually a specialized tool like Vensim for SD still makes a lot of sense. Mathematica is much closer to programming than Vensim and has a very steep learning curve which albeit is worth every bit of it in my opinion. But once I have to think about coding in C to get in an external function Vensim's ease of doing things significantly drops off in my opinion.

Best,
Guido
tomfid
Administrator
Posts: 3995
Joined: Wed May 24, 2006 4:54 am

Re: Eigenvector calculation

Post by tomfid »

No beating needed - we like Mathematica too.
Post Reply