vensim link matlab

Use this forum to post Vensim related questions.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

Thank you all dear friends

Yes ,you are right. Because I thought the modified hfile never works.Now I tried:

>> vendll=['C:\Windows\SysWOW64\venDLL32.dll']

vendll =

C:\Windows\SysWOW64\venDLL32.dll

>> hfile = ['C:\Users\mrj\Desktop\New folder (3)\vendll.h']

hfile =

C:\Users\mrj\Desktop\New folder (3)\vendll.h

>> loadlibrary(vendll,hfile);
??? Error using ==> loadlibrary at 480
There was an error loading the library "C:\Windows\SysWOW64\venDLL32.dll"
C:\Windows\SysWOW64\venDLL32.dll is not a valid Win32 application.



Caused by:
Error using ==> loaddefinedlibrary
C:\Windows\SysWOW64\venDLL32.dll is not a valid Win32 application.
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

You should try one of the sample files that installs with Vensim to see if that works - probably the Excel example is the easiest to try. If you have files installed in Program Files(x86) that also means you must have an old version of Vensim - you should probably update that. The dll files should install to Users\Public\Vensim\DLL on Win 7.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

Vensim Dss(Vensim 5.9b), I work with this version.Is it old version?A company installed it on my computer.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

Yes there is not any thing about vensim in this path(Users\Public)
I open these two addresses :

C:\Program Files (x86)\Vensim\dll\EXCEL7
C:\Program Files (x86)\Vensim\dll\EXCEL97

And run them. They don’t response. I mail their response for you.

[Edited on 8-28-2010 by ahmadi2010]
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

You definitely can't open any excel files in the program directories on Windows 7. Try moving the DLL directory to a different location and seeing if any of the example (eg Java) will work.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

Excuse me bob ;

I can't understand what you mean exactly. before I never works with Java.
you mean I change the path of vendll32.dll, or try it on computer with win(xp), or write any program in Java or Excel program!!!!!!!!

and again Vensim Dss(Vensim 5.9b) is very old version of vensim that dosen't work with matlab?
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Post by tomfid »

5.9b is not particularly old, but evidently uses paths that don't work with Win7. I think what Bob is suggesting is that you should copy your C:\Program Files (x86)\Vensim\dll to another location, i.e. your user documents directory, because Win7 won't let them run where they are. No need to do any programming.

However, it may also be the case that your vendll32.dll is in the wrong place. I don't know where it belongs though as I don't use Win7. If you have an XP machine to try, that is much more likely to work with 5.9b.

Tom
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

Thank you Tom .

Can I give a backup of vensim software in win7 & Restore this backup to win XP in another computer?

[Edited on 8-31-2010 by ahmadi2010]
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

You can install to the XP machine using the same registration code you installed to the Win 7 machine.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

I want install 2 windos on my laptop. win xp & win7. & then install vensim DSS on both of them.Do DSS work on both of them corectly?
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

Yes, the current release of Vensim works on XP, Vista and 7.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

Finaly I could load vendll32.

Now I load this model:

str=['SPECIAL>LOADMODEL|',test,'.vpm'];
lp=libpointer('voidPtr',[int8(str) 0]);
calllib('vendll32','vensim_command',lp);

How can I see the result of my model in matlab or the amount of variable thet I defined in vensim?
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

See the example in the excel97 folder - this retrieves results from the DLL.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

Thank you Bob,
I couldn’t work with Ecxel Ex.It gives me error for Example I see this:

result=vensim_command("SIMULATE>LOADMODEL|c:\............)

I don't know how should I change this in matlab.

I write very simple model in vensim.
G=A*X, A=5,8,10,16,X=5, initial for G=0,
After I run the matlab:
It's response is :
str =
SPECIAL>LOADMODEL| .vpm
lp =
libpointer
ans =
0

Dose it correct?
Could anyone please help me to resolve this issue?
And for simulating the model?
How can I see amount of G, A, and X in matlab?

[Edited on 9-25-2010 by ahmadi2010]

[Edited on 9-25-2010 by ahmadi2010]

[Edited on 9-25-2010 by ahmadi2010]
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Post by tomfid »

It looks like you have some stray single-quote marks in your code.
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

In VB you will need to change the location of the sample model so that it matches the location that the file is actually in. Once you have done this that sample should work and the vensim_get_data calls will demonstrate how to get results out.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

I correct them but again give error!!! I

and thise time I use fullpath.

str=['SPECIAL>LOADMODEL|D:\Documents and Settings\m\Desktop\vensim practice\1.vpm']
lp=libpointer('voidPtr',[int8(str) 1])
calllib('vendll32','vensim_command',lp)
……………………………
It’s response is:

str =SPECIAL>LOADMODEL|D:\Documents and Settings\m\Desktop\vensim practice\1.vpm
lp =libpointer
ans = 0
…………………….
Again Can any one help me?
I want simulate very simple model in matlab:(vensime model is: G=A*X, A=5,8,10,16,X=5, initial for G(level)=0)

what I should write in matlab?

another question: I attached error file but I can't see it here!!!!!

[Edited on 9-26-2010 by ahmadi2010]

[Edited on 9-26-2010 by ahmadi2010]
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

What happens if you try the following (I copied it from http://www.ventanasystems.co.uk/forum/v ... php?t=4181)?

str=['SPECIAL>LOADMODEL|D:\Documents and Settings\m\Desktop\vensim practice\1.vpm'];
lp=libpointer('voidPtr',[int8(str) 0]);
calllib('vendll32','vensim_command',lp);
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

Thank you dear Administrator for your quick response.
I try this:(I save m file as gg)

if not(libisloaded('vendll32'))
hfile = ['D:\Program Files\Vensim\dll\vendll.h'];
loadlibrary('vendll32', hfile);
end
libfunctionsview vendll32
..................................................
str=['SPECIAL>LOADMODEL|D:\Documents and Settings\m\Desktop\vensim practice\1.vpm'];
lp=libpointer('voidPtr',[int8(str) 0]);
calllib('vendll32','vensim_command',lp);
………………………
For first time it opens the functions in library vendll32 table & I see the vensim open & close rapidly
& in matlab it’s response is,

Warning: Warnings messages were produced while parsing. Check the functions you
intend to use for correctness. Warning text can be viewed using:
[notfound,warnings]=loadlibrary(...)
> In loadlibrary at 374
In gg at 7
Warning: The function 'VensimCGetSubstring' was not found in the library
> In loadlibrary at 435
In gg at 7
Warning: The function 'vensim_shutdown' was not found in the library
> In loadlibrary at 435
In gg at 7
>>
…………………….
And for second & third times it only open that table without any warning.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

Maybe it's best to try contacting someone who has successfully managed to get Matlab and Vensim communicating (try arraywanted or mrj.hoseini).

http://www.ventanasystems.co.uk/forum/m ... ile&u=1847
http://www.ventanasystems.co.uk/forum/m ... ile&u=1861

Most of us do not use Matlab so are only guessing about how to get it working.

Tony.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

thank you Tony.
arraywanted
Member
Posts: 36
Joined: Fri Aug 20, 2010 11:03 am

Post by arraywanted »

I've never had these warning messages before. Have you checked which functions are contained in the library you loaded? You can do so with "libfunctionsview('vendll32')".
My vendll32 does contain 'VensimCGetSubstring', but not vensim_shutdown. That one isn't even mentioned in the manual, so I have no idea what this warning means.
Neither do I know why these functions should be needed for loading a model. Do these warnings appear when you load the library without loading a model for starters?

Do you know if your model has been loaded correctly? The callib(...) command has to return 1 for that.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

Yes, these warnings appear when I load the library without loading a model for starters. But for second time these warning don’t appear.
My vendll32 does contain 'Vensim_get_substring' not 'VensimCGetSubstring',and not vensim_shutdown, too.:(
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

What version of Vensim are you using? You need to make sure that the vendll.h file you have is consistent with that for the Vensim DLL in use. The easiest way to do this is to reinsatall selecting the DLL option and use those files.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

I am using vensim Dss version 5.3- yes before I selest the DLL option. I don't know why this warnning apears!!!!!

[Edited on 9-27-2010 by ahmadi2010]

[Edited on 9-27-2010 by ahmadi2010]
Post Reply