Example #1
0
 def get_initial_lookup(self, name):
     a = vensimDLLwrapper.get_varattrib(name, 3)[0]
     elements = a.split('],', 1)
     b = elements[1][0:-1]
           
     list = []
     list2 = []
     number = []
     for c in b:
         if (c != '(') and (c != ')'):
             list.append(c) 
      
     list.append(',')      
     for c in list:
         if c != ',':
             number.append(c)
         else:
             list2.append(float(''.join(number)))
             number[:] = []
     x = []
     y = []
     xT = True
     for i in list2:
         if xT:
             x.append(i)
             xT = False
         else:
             y.append(i)
             xT = True
     return (x, y)
Example #2
0
 def _get_initial_lookup(self, name):
     '''
     Helper function to retrieve the lookup function as defined in the
     vensim model. This lookup is transformed using a distortion function.
     
     :param name: name of variable in vensim model that contains the lookup
     
     '''
     
     a = vensimDLLwrapper.get_varattrib(name, 3)[0]
     elements = a.split('],', 1)
     b = elements[1][0:-1]
           
     list1 = []
     list2 = []
     number = []
     for c in b:
         if (c != '(') and (c != ')'):
             list1.append(c) 
      
     list1.append(',')      
     for c in list1:
         if c != ',':
             number.append(c)
         else:
             list2.append(float(''.join(number)))
             number[:] = []
     x = []
     y = []
     xT = True
     for i in list2:
         if xT:
             x.append(i)
             xT = False
         else:
             y.append(i)
             xT = True
     return (x, y)
Example #3
0
from connectors.vensimDLLwrapper import VensimWarning

try:
    from networkx import graphviz_layout
except ImportError:
    raise ImportError("This example needs Graphviz and either PyGraphviz or Pydot")


from connectors import vensim
from connectors import vensimDLLwrapper as venDLL

vensim.load_model(r'C:\workspace\EMA-workbench\src\sandbox\sils\MODEL.vpm')

vars = venDLL.get_varnames()

graph = nx.DiGraph()
graph.add_nodes_from(vars)

for var in vars:
    try:
        causes = venDLL.get_varattrib(var, attribute=4) #cause
        for cause in causes:
            graph.add_edge(cause, var)
    except VensimWarning:
        print var

cPickle.dump(graph, open("model of Oliva.cPickle",'wb'))

pos=nx.graphviz_layout(graph,prog='twopi',args='')
nx.draw_networkx(graph, pos=pos)
plt.show()