"Vensim <--> C" - Could anybody help me plea

Use this forum to post Vensim related questions.
Post Reply
ram
Junior Member
Posts: 9
Joined: Fri Apr 22, 2005 4:33 am

"Vensim <--> C" - Could anybody help me plea

Post by ram »

Hello everybody,

Could anybody please tell me if the task I am trying to do is at all possible...??

The problem I want to tackle is as follows: I have two separate things here. One is a system dynamics simulation model in Vensim. And the other one is a Genetic Algorithm written in C language to solve an optimization problem. Now, my task is to link both of them, as mentioned below, to optimize the simulation model.

What this C program actually does is, at every iteration, it generates a set of 5 values (these are the variables in my problem). I want to send these 5 values to the Vensim model and simulate the model with these 5 values and then send the output back to the C program (in this case the output is set of points on a curve) . Now the C program, using these output values, computes the area of that curve and stores it in the memory. The next thing to happen is C program again generates a different set of 5 values. Again I want these values be sent to Vensim, simulate the model and get the output back to C. And the process goes on till the end of the loop. Finally I would pick the set of values that generated the curve with minimum area.

Could you please tell me if what I am trying to do here is at all possible? I would greatly appreciate all your comments and feedback on how I could get this done.

With best regards,
-Ram.
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

This is possible.

Start by looking at the example source code for the Vensim external function library. This is fairly straightforward, you just create your own custom function and pass any parameters from Vensim to it. Then what you do within the function is up to you.

Have a look at chapter 8 of the DSS Reference Manual
http://www.vensim.com/documentation/vensim.htm

When I started using external functions, I found the easiest way was to just look at the example that comes with Vensim, it is well documented.

Tony.
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

Tony's reply works if you want to run the GA within a function call. It sound more to me like you intend to have the GA control Vensim's simulation. The best way to do this would be using the Vensim DLL. See the C++ example that comes with that.
ram
Junior Member
Posts: 9
Joined: Fri Apr 22, 2005 4:33 am

Thank you very much

Post by ram »

Mr. Tony and Mr. Bob,

Thank you very very much for your immediate response and Valuable advice. I felt very happy about it. I will immediately try to do what you guys suggested.

With best regards,
-Ram.


[Edited on 4-30-2005 by ram]
Post Reply