Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8707761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:57:03+00:00 2026-06-13T03:57:03+00:00

Im trying to run this code : #!/usr/bin/env python The example presented at the

  • 0

Im trying to run this code :

#!/usr/bin/env python
"""
The example presented at the MURI review, illustrating the use of
jtlvint and automaton modules

Nok Wongpiromsarn (nok@cds.caltech.edu)
August 3, 2010

minor refactoring by SCL <slivingston@caltech.edu>
1 May 2011.

Small modifications by Yuchen Lin.
12 Aug 2011
"""

#@import_section@
import sys, os
from subprocess import call

from tulip import *
import tulip.polytope as pc
#@import_section_end@


# Specify where the smv file, spc file and aut file will go
#@filename_section@
testfile = 'robot_discrete_simple'
path = os.path.abspath(os.path.dirname(sys.argv[0]))
smvfile = os.path.join(path, 'specs', testfile+'.smv')
spcfile = os.path.join(path, 'specs', testfile+'.spc')
autfile = os.path.join(path, 'specs', testfile+'.aut')
#@filename_section_end@

# Specify the environment variables
#@envvar_section@
env_vars = {'park' : 'boolean'}
#@envvar_section_end@

# Specify the discrete system variable
# Introduce a boolean variable X0reach to handle the spec [](park -> <>X0)
# X0reach starts with TRUE. 
# [](next(X0reach) = X0 | (X0reach & !park))
#@sysdiscvar_section@
sys_disc_vars = {'X0reach' : 'boolean'}
#@sysdiscvar_section_end@

# Specify the transition system representing the continuous dynamics
#@ts_section@
disc_dynamics = prop2part.PropPreservingPartition(list_region=[], list_prop_symbol=[])

# These following propositions specify in which cell the robot is,
# i.e., Xi means that the robot is in cell Ci
disc_dynamics.list_prop_symbol = ['X0', 'X1', 'X2', 'X3', 'X4', 'X5'] 
disc_dynamics.num_prop = len(disc_dynamics.list_prop_symbol)

# Regions. Note that the first argument of Region(poly, prop) should
# be a list of polytopes. But since we are not dealing with the actual
# controller, we will just fill it with a string (think of it as a
# name of the region).  The second argument of Region(poly, prop) is a
# list that specifies which propositions in cont_props above is
# satisfied. As specified below, regioni satisfies proposition Xi.
region0 = pc.Region('C0', [1, 0, 0, 0, 0, 0])
region1 = pc.Region('C1', [0, 1, 0, 0, 0, 0])
region2 = pc.Region('C2', [0, 0, 1, 0, 0, 0])
region3 = pc.Region('C3', [0, 0, 0, 1, 0, 0])
region4 = pc.Region('C4', [0, 0, 0, 0, 1, 0])
region5 = pc.Region('C5', [0, 0, 0, 0, 0, 1])
disc_dynamics.list_region = [region0, region1, region2, region3, region4, region5]
disc_dynamics.num_regions = len(disc_dynamics.list_region)

# The transition relation between regions. disc_dynamics.trans[i][j] =
# 1 if starting from region j, the robot can move to region i while
# only staying in the union of region i and region j.
disc_dynamics.trans =   [[1, 1, 0, 1, 0, 0], \
                         [1, 1, 1, 0, 1, 0], \
                         [0, 1, 1, 0, 0, 1], \
                         [1, 0, 0, 1, 1, 0], \
                         [0, 1, 0, 1, 1, 1], \
                         [0, 0, 1, 0, 1, 1]]
#@ts_section_end@

#@specification@
assumption = 'X0reach & []<>(!park)'
guarantee = '[]<>X5 & []<>(X0reach)'
guarantee += ' & [](next(X0reach) = (X0 | (X0reach & !park)))'
#@specification_end@

# Generate input to JTLV
#@geninput@
prob = jtlvint.generateJTLVInput(env_vars, sys_disc_vars, [assumption, guarantee],
                                 {}, disc_dynamics, smvfile, spcfile, verbose=2)
#@geninput_end@

# Check realizability
#@check@
realizability = jtlvint.checkRealizability(smv_file=smvfile, spc_file=spcfile,
                                           aut_file=autfile, verbose=3)
#@check_end@

# Compute an automaton
#@compaut@
jtlvint.computeStrategy(smv_file=smvfile, spc_file=spcfile, aut_file=autfile,
                        priority_kind=3, verbose=3)
aut = automaton.Automaton(autfile, [], 3)

# Remove dead-end states from automaton.
aut.trimDeadStates()
#@compaut_end@


# Visualize automaton with DOT file

# This example uses environment vs. system turn distinction.  To
# disable it, just use (the default),
if not aut.writeDotFile(fname="rdsimple_example.dot", hideZeros=True):
# if not aut.writeDotFile("rdsimple_example.dot",
#                         distinguishTurns={"env": prob.getEnvVars().keys(),
#                                           "sys": prob.getSysVars().keys()},
#                         turnOrder=("env", "sys")):
# if not aut.writeDotFileEdged(fname="rdsimple_example.dot",
#                              env_vars = prob.getEnvVars().keys(),
#                              sys_vars = prob.getSysVars().keys(),
#                              hideZeros=True):
    print "Error occurred while generating DOT file."
else:
    try:
        call("dot rdsimple_example.dot -Tpng -o rdsimple_example.png".split())
    except:
        print "Failed to create image from DOT file. To do so, try\n\ndot rdsimple_example.dot -Tpng -o rdsimple_example.png\n"


# Simulate.
#@sim@
num_it = 30
env_states = [{'X0reach': True}]
for i in range(1, num_it):
    if (i%3 == 0):
        env_states.append({'park':True})
    else:
        env_states.append({'park':False})

graph_vis = raw_input
destfile = 'rdsimple_example.gexf'
label_vars = ['park', 'cellID', 'X0reach']
delay = 2
vis_depth = 3
aut_states = grsim.grsim([aut], aut_trans_dict={}, env_states=env_states,
                         num_it=num_it, deterministic_env=False,
                         graph_vis=graph_vis, destfile=destfile,
                         label_vars=label_vars, delay=delay,
                         vis_depth=vis_depth)
#@sim_end@

However just before it ends, it fails at #simulate where it says :

Traceback (most recent call last):
  File "/Applications/Python 2.7/tulip-0.3c/examples/robot_discrete_simple.py", line 151, in <module>
    vis_depth=vis_depth)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tulip/grsim.py", line 109, in grsim
    raise TypeError("Invalid arguments to grsim")
TypeError: Invalid arguments to grsim

Not sure if this info would help, but the DOT file also failed to be created ..

Failed to create image from DOT file. To do so, try

dot rdsimple_example.dot -Tpng -o rdsimple_example.png

Why is giving me a TypeError problem ? How can I fix this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:57:04+00:00Added an answer on June 13, 2026 at 3:57 am

    The following code from grsim throws the exception:

    if not (isinstance(aut_list, list) and len(aut_list) > 0 and
            isinstance(aut_trans_dict, dict) and
            isinstance(env_states, list) and len(env_states) > 0 and
            isinstance(num_it, int) and isinstance(deterministic_env, bool) and
            isinstance(graph_vis, bool) and isinstance(destfile, str) and
            (label_vars == None or isinstance(label_vars, list)) and
            isinstance(delay, int) and isinstance(vis_depth, int)):
        raise TypeError("Invalid arguments to grsim")
    

    Your graph_vis variable is not a bool, but the raw_input function:

    graph_vis = raw_input
    

    which you don’t even invoke.

    The documentation asks for a boolean as well:

    grsim.grsim(aut_list, aut_trans_dict={}, env_states=[{}], num_it=20, deterministic_env=True, graph_vis=False, destfile='sim_graph.gexf', label_vars=None, delay=2, vis_depth=3)

    […]

    • graph_vis – specify whether to visualize the simulation in Gephi.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run this code but this error appear: Uncaught TypeError: string is
I'm trying to run this code: let coins = [50, 25, 10, 5, 2,1]
I am trying to run this code: ItemTaxonomy iTaxonomy = from itemTaxonomy in connection.ItemTaxonomy
I am trying to run this code : exec myStoredProcedure Cast('c5b48202-36af-4597-9780-5366d4188f55' AS uniqueidentifier), 744,
I am trying to run this seemingly simple piece of code which is repeated
Trying to convert this c code into MIPS and run it in SPIM. int
I'm trying to deobfuscate the following Perl code ( source ): #!/usr/bin/perl (my$d=q[AA GTCAGTTCCT
I'm trying to use pygtk in Python but when I try running my code
I am trying to run a Python program using PHP. Here's the code $command
I need urgent help in this regard. I am trying to run a Python

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.