<commit_before>#!/usr/bin/env python3
import houston
import bugzoo
from houston.generator.rand import RandomMissionGenerator
from houston.generator.resources import ResourceLimits

bz = bugzoo.BugZoo()
snapshot = bz.bugs['ardudemo:ardupilot:overflow']
snapshot.build()

sut = houston.ardu.ArduRover(snapshot)

# mission description
actions = [
    houston.action.Action("arm", {'arm': True}),
    houston.action.Action("goto", {
        'latitude' : -35.361354,
        'longitude': 149.165218,
        'altitude' : 5.0
    })
]
environment = houston.state.Environment({})
initial = houston.state.State({
    "homeLatitude" : -35.3632607,
    "homeLongitude" : 149.1652351,
    "latitude" : -35.3632607,
    "longitude": 149.1652351,
    "altitude" : 0.0,
    "battery"  : 100,
    "armed"    : False,
    "armable"  : True,
    "mode"     : "AUTO"
}, 0.0)
mission = houston.mission.Mission(environment, initial, actions)

# create a container for the mission execution
#sandbox = sut.provision()
#res = sandbox.run(mission)
#print(res)

mission_generator = RandomMissionGenerator(sut, initial, environment)
resource_limits = ResourceLimits(2, 1000)
mission_generator.generate(100, resource_limits)
#mission_generator.prepare(100, resource_limits)
#for i in range(5):
#    m = mission_generator.generate_mission()
#    print("Mission {}: {}".format(i, m.to_json()))
#    res = sandbox.run(m)
#    print(res)<commit_msg>updated example to compute coverage info<commit_after>#!/usr/bin/env python3
import houston
import bugzoo
from houston.generator.rand import RandomMissionGenerator
from houston.generator.resources import ResourceLimits

bz = bugzoo.BugZoo()
snapshot = bz.bugs['ardudemo:ardupilot:overflow']
snapshot.build()

sut = houston.ardu.ArduRover(snapshot)

# mission description
actions = [
    houston.action.Action("arm", {'arm': True}),
    houston.action.Action("goto", {
        'latitude' : -35.361354,
        'longitude': 149.165218,
        'altitude' : 5.0
    })
]
environment = houston.state.Environment({})
initial = houston.state.State({
    "homeLatitude" : -35.3632607,
    "homeLongitude" : 149.1652351,
    "latitude" : -35.3632607,
    "longitude": 149.1652351,
    "altitude" : 0.0,
    "battery"  : 100,
    "armed"    : False,
    "armable"  : True,
    "mode"     : "AUTO"
}, 0.0)
mission = houston.mission.Mission(environment, initial, actions)

# create a container for the mission execution
sandbox = sut.provision()
(res, coverage) = sandbox.run_with_coverage(mission)
print(coverage)

# mission_generator = RandomMissionGenerator(sut, initial, environment)
# resource_limits = ResourceLimits(2, 1000)
# mission_generator.generate(100, resource_limits)
#mission_generator.prepare(100, resource_limits)
#for i in range(5):
#    m = mission_generator.generate_mission()
#    print("Mission {}: {}".format(i, m.to_json()))
#    res = sandbox.run(m)
#    print(res)
{'fraction_non_alphanumeric': 0.1431528113142463, 'fraction_numerical': 0.053121766126250435, 'mean_word_length': 4.2727272727272725, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '317331', 'n_tokens_mistral': 1122, 'n_tokens_neox': 998, 'n_words': 197}