Reroute with probability behaves strangely - sumo

I have network with 2 junctions. All cars starts from the left and on the first junction they drive bottom(with probability=0.2) or right (with probability=0.8). And that works perfectly fine. The code doing the stuff is below (hello.rou.xml):
<?xml version="1.0" encoding="UTF-8"?>
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">
<vType accel="1.0" decel="5.0" id="Car" length="5.0" minGap="2.0" maxSpeed="50.0" sigma="0" />
<flow id="type1" color="1,1,0" begin="0" end= "7200" period="3" type="Car">
<routeDistribution id="routedist1">
<route id="route0" edges="gneE7 gneE8" probability="0.2"/>
<route id="route1" edges="gneE7 gneE10" probability="0.8"/>
</routeDistribution>
</flow>
</routes>
So we have many cars that comes to gneE10 edge. I want to specify probability of going top/right/bottom in this moment. So I attach additional file with rerouter:
<?xml version="1.0" encoding="UTF-8"?>
<additional>
<routeDistribution id="reRouteE10">
<route id="routeX0" edges="gneE10 -gneE14" probability="0.34" /><!--UP-->
<route id="routeX1" edges="gneE10 gneE15" probability="0.33" /><!--STRAIGHT-->
<route id="routeX2" edges="gneE10 gneE12" probability="0.33" /><!-- DOWN -->
</routeDistribution>
<rerouter id="rerouterE10" edges="gneE10">
<interval begin="0" end="100000">
<routeProbReroute id="reRouteE10" />
</interval>
</rerouter>
</additional>
If we have probabilities like above I always have such behaviour:
Every vehicle goes down! Why? Most likely because of being last in code to be honest.
I have specified a little bit different density.
Even with very large number 0.7 - all cars still goes straight. (It changes with 0.9 - then all goes up).
Not sure if bug or I have misunderstood something. Full code aviable at Github

The rerouter does not take route distributions as argument. I agree this would be the logical thing to do, but the SUMO way to do it is:
<rerouter id="rerouterE10" edges="gneE10">
<interval begin="0" end="100000">
<routeProbReroute id="routeX0" probability="0.34" />
<routeProbReroute id="routeX1" probability="0.33" />
<routeProbReroute id="routeX2" probability="0.33" />
</interval>
</rerouter>
In your example sumo draws one route from the given distribution on creating the rerouter and then always uses this one.

Related

SCORM 2004 Rollup with single sco

I'm having issues rolling up a completion from a completed item.
I'm running this on SABA and I can successfully set the completion_status and success_status on the item but having issues rolling it up to the next level on the LMS, both satisfied and notSatisfied.
I find these rules utterly confusing. I do mostly work in SCORM 1.2.
This is my chunk to-date. Any assistance is really, really appreciated.
<organizations default="ORG-487461">
<organization identifier="ORG-487461">
<title>STATUS TESTING - 1d</title>
<item identifier="ACT-687940" identifierref="RES-123054">
<title>Launch</title>
<imsss:sequencing>
<imsss:deliveryControls completionSetByContent="true" objectiveSetByContent="true" />
</imsss:sequencing>
</item>
<imsss:sequencing>
<imsss:controlMode choice="true" flow="true"/>
<imsss:rollupRules>
<imsss:rollupRule childActivitySet="any">
<imsss:rollupConditions>
<imsss:rollupCondition condition="satisfied"/>
</imsss:rollupConditions>
<imsss:rollupAction action="satisfied"/>
</imsss:rollupRule>
<imsss:rollupRule childActivitySet="all">
<imsss:rollupConditions conditionCombination="any">
<imsss:rollupCondition operator="not" condition="satisfied" />
</imsss:rollupConditions>
<imsss:rollupAction action="notSatisfied" />
</imsss:rollupRule>
</imsss:rollupRules>
<imsss:rollupRules rollupObjectiveSatisfied="true" rollupProgressCompletion="true" />
</imsss:sequencing>
</organization>
</organizations>
I was deep in this a few years back but I'll try to assist based on some of my prior examples.
I think you need to set a primary objective. Else - I don't believe there is anything to roll up to. I don't however know that for a fact, as it would require going back and doing a deeper dive in to the SCORM 2004 3rd/4th edition spec and covering the IMSS Sequencing section.
Small example for an activity:
<!-- Activity 1 -->
<title>ims_sequencing_objectives</title>
<item identifier="ACT-001" identifierref="RES-001">
<title>SCOBot-QUnit1</title>
<imsss:sequencing IDRef="COMMON_SEQ_RULES">
<imsss:sequencingRules>
<!-- If you also wanted to limit the number of attempts -->
<imsss:preConditionRule>
<imsss:ruleConditions>
<imsss:ruleCondition condition="attemptLimitExceeded" />
</imsss:ruleConditions>
<!-- Can not choose -->
<imsss:ruleAction action="disabled" />
</imsss:preConditionRule>
</imsss:sequencingRules>
<imsss:limitConditions attemptLimit="1" /> <!-- attemptAbsoluteDurationLimit="" set if max_time_allowed -->
<imsss:rollupRules objectiveMeasureWeight="0" />
<imsss:objectives>
<!-- My Understanding is SCO1_SATISFIED will assume the scoring of the SCO, then you can continue to SCO 2 after the preCondition is met. This SCO is just a "intro" no score reported. Removed satisfiedByMeasure -->
<imsss:primaryObjective objectiveID="SCO1_SATISFIED">
<imsss:mapInfo targetObjectiveID="com.cybercussion.SCOBot.ACT-001" readSatisfiedStatus="true" writeSatisfiedStatus="true" readNormalizedMeasure="true" writeNormalizedMeasure="true" />
</imsss:primaryObjective>
</imsss:objectives>
</imsss:sequencing>
Then a subsequent activity would allow the LMS Player the opportunity to decide whether it should allow the navigation/show it using pre/post rules. And I would agree this gets confusing. Further more its even harder to unit test unless you have some rules engine that can parse this realtime to validate your intent. This below sample would be like Activity/SCO 3...
<imsss:preConditionRule>
<imsss:ruleConditions>
<imsss:ruleCondition referencedObjective="SCO2_SATISFIED" condition="satisfied" />
</imsss:ruleConditions>
<imsss:ruleAction action="disabled" />
</imsss:preConditionRule>
You can also control how the content controls the LMS. As some parts of SCORM like completion and success status could be based on progress_measure and scoring if completion thresholds are set (for example).
<!-- Sequence Collection used by SCOs -->
<imsss:sequencingCollection>
<imsss:sequencing ID="COMMON_SEQ_RULES">
<!-- Rollup: set to 0 if you don't want these scored. -->
<!--imsss:rollupRules objectiveMeasureWeight="1" /-->
<!-- prevent from accidentally being quto-completed/satisfied -->
<imsss:deliveryControls completionSetByContent="true" objectiveSetByContent="true" />
<!-- Attempt limit here had no effect -->
</imsss:sequencing>
</imsss:sequencingCollection>
I have a one page progression example here: https://github.com/cybercussion/SCOBot/wiki/Single-Pages-Managed-by-LMS-Navigation There may be something to glean off it. I always thought this was an area/gap the community would eventually fill with some builder/tool but since we are talking about 14 years almost now! I started to attempt to address some of this with my Packager app but there simply isn't enough customer request/demand to spend the time on it.
Good Luck.

How to get more info within only one geosearch call via Wikipedia API?

I am using an API call similar to http://en.wikipedia.org/w/api.php?action=query&list=geosearch&gsradius=10000&gscoord=41.426140|26.099319.
I returns something like this
<?xml version="1.0"?>
<api>
<query>
<geosearch>
<gs pageid="27460829" ns="0" title="Kostilkovo" lat="41.416666666667" lon="26.05" dist="4245.1" primary="" />
<gs pageid="27460781" ns="0" title="Belopolyane" lat="41.45" lon="26.15" dist="4988.7" primary="" />
<gs pageid="27460862" ns="0" title="Siv Kladenets" lat="41.416666666667" lon="26.166666666667" dist="5713.5" primary="" />
<gs pageid="13811116" ns="0" title="Svirachi" lat="41.483333333333" lon="26.116666666667" dist="6521.9" primary="" />
<gs pageid="27460810" ns="0" title="Gorno Lukovo" lat="41.366666666667" lon="26.1" dist="6613.4" primary="" />
<gs pageid="27460799" ns="0" title="Dolno Lukovo" lat="41.366666666667" lon="26.083333333333" dist="6746.2" primary="" />
<gs pageid="27460827" ns="0" title="Kondovo" lat="41.433333333333" lon="26.016666666667" dist="6937" primary="" />
<gs pageid="27460848" ns="0" title="Plevun" lat="41.45" lon="26.016666666667" dist="7383.1" primary="" />
<gs pageid="24179704" ns="0" title="Villa Armira" lat="41.499069444444" lon="26.106263888889" dist="8130" primary="" />
<gs pageid="27460871" ns="0" title="Zhelezari" lat="41.413333333333" lon="25.998333333333" dist="8540.1" primary="" />
</geosearch>
</query>
</api>
But while I am actually trying to get some pictures of those pages, subsequent calls are needed, like
to get some page images
http://en.wikipedia.org/w/api.php?action=query&prop=images&pageids=13843906
then, to get image info
http://en.wikipedia.org/w/api.php?action=query&titles=File:Alexandru_Ioan_Cuza_Dealul_Patriarhiei.jpg&prop=imageinfo&iiprop=url
Well, even if this gets me what I ultimately need, it is not efficient at all.
I would like to know if there are some parameters for this calls, or maybe completely other call(s) that would bring all this info in maximum 2 steps/calls. It would be great, though, if it would be only one.
Wow, I had no idea that such a feature exists nowadays! But to answer your question, since it's a list query, you can probably use it as a generator.
Let's try it:
Original geosearch query: http://en.wikipedia.org/w/api.php?action=query&list=geosearch&gsradius=10000&gscoord=41.426140|26.099319
Generator query to get images on matching pages: http://en.wikipedia.org/w/api.php?action=query&prop=images&imlimit=max&generator=geosearch&ggsradius=10000&ggscoord=41.426140|26.099319
The prop=images query can also be used as a generator, so you can also do this:
Get URLs for all images on a list of pages: http://en.wikipedia.org/w/api.php?action=query&prop=imageinfo&iiprop=url&generator=images&gimlimit=max&pageids=13811116|24179704|27460781|27460799|27460810|27460827|27460829|27460848|27460862|27460871
Alas, AFAIK you can't nest generators, so you can't do both steps in one query. You can either:
get the list of images in one query, and then use another query to get the URLs, or
start with the basic geosearch query to get the page IDs, and then get the images and their URLs in another query.
Alas, it turns out that both of these options fail to give you some information that you may want. If you use list=geosearch as a generator, you don't get the coordinate information that you may need if you e.g. wish to display the results on a map. On the other hand, using prop=images as a generator makes you miss out on something even more important: the knowledge of which images are used on which pages!
Thus, unfortunately, it seems that, if your goal is to place images on a map, you'll probably have to do it with three separate queries. At least you can still query multiple pages / images in one request, so you shouldn't need more than three (until you hit the query limits and need to use continuations, that is).
(Also, doing it in three steps lets you apply some filtering to the images before the third step. For example, most of the pages returned by your example query only have the same three images — Flag of Bulgaria.svg, Ivaylovgrad Reservoir.jpg and Oblast Khaskovo.png — all of which are used via templates, and none of which really look like good choices to represent the specific location.)
Ps. If you're just interested in finding images near a particular location, even if they're not used on any specific Wikipedia article, you might want to try using geosearch directly on Wikimedia Commons. It doesn't seem to return any results for your Bulgarian example coordinates, but it works just fine in a more crowded location.
Here is an alternative to build on the previous answer. If you start with this query as a partial answer:
https://en.wikipedia.org/w/api.php?action=query&prop=images&imlimit=max&generator=geosearch&ggsradius=10000&ggscoord=41.426140|26.099319
Then you can build on this to get the information in a single query. The pageimages property can work with the generator. You cannot nest generators but you can chain properties. A query can use pageimages to get the page's main image url for each of the geosearch results. It looks like this:
https://en.wikipedia.org/w/api.php?action=query&prop=images|pageimages&pilimit=max&piprop=thumbnail&iwurl=&imlimit=max&generator=geosearch&ggsradius=10000&ggscoord=41.426140|26.099319
This query returns the image "File" names (images property) and a single URL for the main image (pageimages property). The main image of the page is all I need. You might be able to extrapolate the "file" urls by matching the changes from the file to the url that is output with the query but I cannot recommend such a hack.
The images property has a setting that is supposed to return urls for interwiki links, iwurl. I see the "file" as an interwiki link. This parameter is not working and images does not return a url. Playing on the sandbox might lead you to a better answer.
Intuitively it seems like you should be able to chain the images and imageinfo properties together. Doing so does not give the expected results.
If a single url for the main image of the page is not enough I can encourage you to play in the API sandbox to try and get what you need with some combination of properties. I am using the geosearch generator and get the page image, text description, and lat/long coordinates so that I can get the address. Good luck!

Does the Wikipedia API support searches for a specific template?

Is it possible to query the Wikipedia API for articles that contain a specific template? The documentation does not describe any action that would filter search results to pages that contain a template. Specifically, I am after pages that contain Template:Persondata. After that, I am hoping to be able to retrieve just that specific template in order to populate genealogy data for the openancestry.org project.
The query below shows that the Albert Einstein page contains the Persondata Template, but it doesn't return the contents of the template, and I don't know how to get a list of page titles that contain the template.
http://en.wikipedia.org/w/api.php?action=query&prop=templates&titles=Albert%20Einstein&tlcontinue=736|10|ParmPart
Returns:
<api>
<query>
<pages>
<page pageid="736" ns="0" title="Albert Einstein">
<templates>
...
<tl ns="10" title="Template:Persondata"/>
...
</templates>
</page>
</pages>
</query>
<query-continue>
<templates tlcontinue="736|10|Reflist"/>
</query-continue>
</api>
I suspect that I can't get what I need from the API, but I'm hoping I'm wrong and that someone has already blazed a trail down this path.
You can use the embeddedin query to find all pages that include the template:
curl 'http://en.wikipedia.org/w/api.php?action=query&list=embeddedin&eititle=Template:Persondata&eilimit=5&format=xml'
Which gets you:
<?xml version="1.0"?>
<api>
<query>
<embeddedin>
<ei pageid="307" ns="0" title="Abraham Lincoln" />
<ei pageid="308" ns="0" title="Aristotle" />
<ei pageid="339" ns="0" title="Ayn Rand" />
<ei pageid="340" ns="0" title="Alain Connes" />
<ei pageid="344" ns="0" title="Allan Dwan" />
</embeddedin>
</query>
<query-continue>
<embeddedin eicontinue="10|Persondata|595" />
</query-continue>
</api>
See full docs at mediawiki.org.
Edit Use embeddedin query instead of backlinks (which doesn't cover template inclusions)
Using embeddedin does not allow you to search for a specific person, the search string becomes the Template:Persondata.
The best way I've found to get only people from Wikipedia is to use list=search and filter the search using AND"Born"AND"Occupation":
http://en.wikipedia.org/w/api.php?action=query&list=search&srsearch="Tom Cruise"AND"Born"AND"Occupation"&format=jsonfm&srprop=snippet&srlimit=50`
Remember that Wikipedia is using a search engine that doesn't yet allow us to search only the title, it will search the full text. You can take advantage of that to get more precise results.
The accepted answer explains how to list pages using a certain template, but if you need to search for pages using the template, you can with the hastemplate: search keyword: https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=hastemplate:NPOV%20physics

vxml: defining grammars with equivalent inputs

I am using an engine based on TellMe. I have seen examples of grammars where the user can say one of a few different things that are considered the same. However, all the examples i've seen have been for in-line grammars (which dont work with the vxml engine im using). I want to know how i can change my .grxml file to do this. This is the file:
<?xml version="1.0"?>
<!-- created by Matthew Murdock. Grammars for speech rec menus -->
<grammar xmlns="http://www.w3.org/2001/06/grammar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/06/grammar http://www.w3.org/TR/speech-grammar/grammar.xsd" xml:lang="en" version="1.0" mode="voice" scope="dialog" tag-format="semantics/1.0.2006">
<rule id="keep">
<one-of>
<item>exit</item>
<item>exit the system</item>
<item>another</item>
<item>another mailbox</item>
<item>play</item>
<item>play back</item>
</one-of>
</rule>
</grammar>
instead of having 6 items, i want to have 3 items, each having two possible utterances. Any ideas on how i can do this?
A more compact form:
<rule id="exit">
exit <item repeat="0-1">the system</item>
<tag>out.result = "exit"</tag>
</rule>
<rule id="play">
play <item repeat="0-1">back</item>
<tag>out.result = "play"</tag>
</rule>
The answers you want are in the SISR specification which provides a mechanism for attaching meaning to input paths. Rewriting your example:
<?xml version="1.0"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/06/grammar http://www.w3.org/TR/speech-grammar/grammar.xsd" xml:lang="en" version="1.0" mode="voice" scope="dialog" tag-format="semantics/1.0-literals">
<rule id="keep">
<one-of>
<item>
<one-of>
<item>exit</item>
<item>exit the system</item>
</one-of>
<tag>exit</tag>
</item>
<item>
<one-of>
<item>another</item>
<item>another mailbox</item>
</one-of>
<tag>another</tag>
</item>
<item>
<one-of>
<item>play</item>
<item>play back</item>
</one-of>
<tag>play</tag>
</item>
</one-of>
</rule>
</grammar>
Several things to know:
I chose the literal tag format (notice the tag-format attribute of the grammar element). It could have also been implemented using "semantics/1.0" and the contents of the tag would have looked like: out="exit";
TellMe tag-format values may need to be different, but their development guide implies they follow the standards.
Once you have it working, don't hesitate to create filler grammars (in SRGS speak, rules). Filler rules would be rules without any SI (no tag elements) and contain common phrases people add to responses. For example, a trailing rule that could be added at the end of your grammar:
</one-of>
<item repeat="0-1"><ruleref uri="#trailing"/></item>
</rule>
<rule id="trailing>
<one-of>
<item>please</item>
<item>thank you</item>
</one-of>
</rule>
</grammar>
This would support more natural types of responses. This may or may not be important depending on your calling base. Filler grammars can be very large, but tend to be highly reusable. You can also add filler at the beginning of input. In rich speech applications, a the most significant gain in the tuning process involves updating the grammar to contain the actual phrases spoken by the caller versus what the developer or VUI designer thought would be spoken.
I figured it out. I changed my grammar to look like this:
<?xml version="1.0"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/06/grammar http://www.w3.org/TR/speech-grammar/grammar.xsd" xml:lang="en" version="1.0" mode="voice" scope="dialog" tag-format="semantics/1.0-literals">
<rule id="keep">
<one-of>
<item><ruleref id="#exit"/></item>
<item><ruleref id="#play"/></item>
</one-of>
</rule>
<rule id="exit">
<one-of>
<item>exit</item>
<item>exit the system</item>
</one-of>
<tag>out.result = "exit"</tag>
</rule>
<rule id="play">
<one-of>
<item>play</item>
<item>play back</item>
</one-of>
<tag>out.result = "play"</tag>
</rule>
</grammar>
Then, back in my script instead of basing my actions on callerInput (the variable specified in the <field> tag), i based them off of callerInput$.interpretation which holds xml containing whatever i assigned out.result to in the <tag> element of the grammar.
I guess it makes sense to base your actions on the "interpretation" and not the caller's literal input.
NOTE: Because we are working with our own vxml engine we were able to create a method for extracting the interpretation value out of the xml.

list=alllinks confusion

I'm doing a research project for the summer and I've got to use get some data from Wikipedia, store it and then do some analysis on it. I'm using the Wikipedia API to gather the data and I've got that down pretty well.
What my questions is in regards to the links-alllinks option in the API doc here
After reading the description, both there and in the API itself (it's down and bit and I can't link directly to the section), I think I understand what it's supposed to return. However when I ran a query it gave me back something I didn't expect.
Here's the query I ran:
http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=google&rvprop=ids|timestamp|user|comment|content&rvlimit=1&list=alllinks&alunique&allimit=40&format=xml
Which in essence says: Get the last revision of the Google page, include the id, timestamp, user, comment and content of each revision, and return it in XML format.
The allinks (I thought) should give me back a list of wikipedia pages which point to the google page (In this case the first 40 unique ones).
I'm not sure what the policy is on swears, but this is the result I got back exactly:
<?xml version="1.0"?>
<api>
<query><normalized>
<n from="google" to="Google" />
</normalized>
<pages>
<page pageid="1092923" ns="0" title="Google">
<revisions>
<rev revid="366826294" parentid="366673948" user="Citation bot" timestamp="2010-06-08T17:18:31Z" comment="Citations: [161]Tweaked: url. [[User:Mono|Mono]]" xml:space="preserve">
<!-- The page content, I've replaced this cos its not of interest -->
</rev>
</revisions>
</page>
</pages>
<alllinks>
<!-- offensive content removed -->
</alllinks>
</query>
<query-continue>
<revisions rvstartid="366673948" />
<alllinks alfrom="!2009" />
</query-continue>
</api>
The <alllinks> part, its just a load of random gobbledy-gook and offensive comments. No nearly what I thought I'd get. I've done a fair bit of searching but I can't seem to find a direct answer to my question.
What should the list=alllinks option return?
Why am I getting this crap in there?
You don't want a list; a list is something that iterates over all pages. In your case you simply "enumerate all links that point to a given namespace".
You want a property associated with the Google page, so you need prop=links instead of the alllinks crap.
So your query becomes:
http://en.wikipedia.org/w/api.php?action=query&prop=revisions|links&titles=google&rvprop=ids|timestamp|user|comment|content&rvlimit=1&format=xml