XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Large class of problems: constrain a bunch of pieces to form a chain

Hi Folks,

 

There are a large class of problems that may be characterized this way: Given a bunch of pieces, constrain them so they form a single, connected chain.

 

The following is a beautiful example from this class of problems.

 

Problem: Constrain the segments in an aircraft’s route so that they form a single, connected chain.

 

Explanation: An aircraft flies a route. A route consists of segments. A route has a starting fix and an ending fix. A “fix” is a position. Each segment also has a starting fix and an ending fix. One segment’s starting fix must match the route’s starting fix. One segment’s ending fix must match the route’s ending fix. For the other segments, they must be connected: the ending fix of one segment must be the starting fix of another segment.

 

 

Example: Here is a trivial route with just one segment:

 

<Route>
   
<start-Fix>
       
<Airport id="BOS"/>
   
</start-Fix>
   
<end-Fix>
       
<Airport id="JFK"/>
   
</end-Fix>
   
<Segment>
        
<start-Fix>
           
<Airport id="BOS"/>
       
</start-Fix>
       
<end-Fix>
           
<Airport id="JFK"/>
       
</end-Fix>
   
</Segment>
</Route>

 

Here is a route with three segments. Notice the segments are connected:
                BOS -> MARSHFIELD -> FITCHBURG -> JFK

 

Declarative description of the connected-segments constraint:

 

Every segment in a route must satisfy these three constraints:

1.       The segment is the route’s first segment, or the segment follows another segment.

2.       The segment is the route’s last segment, or the segment precedes another segment.

3.       The segment does not follow the route and the segment does not precede the route.

 

Here is a more detailed description:

 

For every segment s in route r:

1.       The starting fix of s matches the starting fix of r, or there is a segment s2 whose ending fix matches the starting fix of s.

2.       The ending fix of s matches the ending fix of r, or there is a segment s2 whose starting fix matches the ending fix of s.

3.       The starting fix of s does not match the ending fix of r and the ending fix of s does not match the starting fix of r.

 

Schematron implementation of the connected-segments constraint:

 

<!--  no disconnected segments in a route -->
<sch:pattern id="no_disconnected_segments_in_a_route">
   
<sch:rule context="Route">
       
<sch:let name="r" value="."/>
       
<sch:assert test="

             every $s in Segment satisfies
             ($s/start-Fix/*/@id = $r/start-Fix/*/@id) or
            (some $s2 in Segment satisfies $s2/end-Fix/*/@id = $s/start-Fix/*/@id)

            and

($s/end-Fix/*/@id = $r/end-Fix/*/@id) or
            (some $s2 in Segment satisfies $s2/start-Fix/*/@id = $s/end-Fix/*/@id)

             and

(not($s/start-Fix/*/@id = $r/end-Fix/*/@id) and not($s/end-Fix/*/@id = $r/start-Fix/*/@id))

">
           The segments in the route must be connected.
       
</sch:assert>
   
</sch:rule>
</sch:pattern>

 

That is so neat. It is a beautiful, declarative expression of the constraints on the segments in a route.

 

/Roger



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS