ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xml-dev
xml-dev
Re: [xml-dev] An approach to describing the relationships between units-of-measure
by Thomas B. Passin other posts by this author
Jul 21 2003 2:16PM messages near this date
Re: [xml-dev] An approach to describing the relationships between units-of-measure | [xml-dev] [off-topic] Web services mailing lists?
[Roger L. Costello]
> 
>  Below is an approach to describing the relationship between
>  units-of-measure.  I invite your comments.  Special thanks to
>  Tom Passin, Jon Hanna and Joe Chiusano, as their comments
>  inspired this approach.

>  Recall that <kilometer> may be considered as a function:
> 
>      kilometer(length(Yangtze)) --> 6340
> 
>  "kilometer maps the length of the Yangtze to 6340."
> 
>  More generally,
> 
>      kilometer(Distance) --> number
> 

Yes, I think this mapping is sound.

>  "kilometer maps an (abstract) Distance class to a number."
> 

>  Now we arrive at the approach.  The approach is this:
> 
>  This is how to define the Distance class:
> 
>  <Class id="Distance">
>      <equivalentInstances>
>          {k, m | k = m * 1.62}
>      </equivalentInstances>
>  </Class>
> 

The expression of a mapping here is good - basically it is a lambda
(anonymous) function, which are available in many programming languages.

But there are still some problems lurking here -

A. No way to say __which__ equivalence is being specified, e.g., that it is
a miles-to-km relationship.  It would  be  better to write something like

(roger:MilesToKilometersEquivalence,
    roger:equivalenceSpec,
       {k, m | k = m * 1.62}
)

(roger:MilesToCentimeterEquivalence,
    roger:equivalenceSpec,
       {cm, m | cm = m * 1.62 * 10^5}
)

(Class,
   id,Distance;
     equivalentInstances,
         roger:MilesToKilometersEquivalence
         roger:MilesToCentimetersEquivalence
)

Of course, as Jown Cowan said, with a reference to a canonical transform,
the others would not necessarily have to be stated.

B. The formal parameters (k,m) have to be related to their to their units,
which is critical.  One has to know which formal parameter is a mile and
which a kilometer.

The following seems like it should work -

(roger:MilesToKilometersEquivalence,
    roger:equivalenceSpec,
      (k, roger:unitsOf, roger:kilometer)
      (m, roger:unitsOf, roger:mile)
       {k, m | k = m * 1.62}
)

C. Tolerance is missing.  That is, applying

>  represent the same Distance is a matter of checking
>  for set containment:
> 
>      (6340 k, 3914 m) in {k, m | k = m * 1.62}
> 

will almost always fail to show containment because of practical
considerations of numerical accuracy.  For example, in this case, the ratio
of the numbers to four decimal places is 1.61983, not 1.6200000.....,
therefore the number pair would not be contained in the set as the test is
stated here.  I am sure that the intent is that they should be rated as
equivalent, and hence some measure of tolerance is needed.

However, you have to solve the tolerance issue anyway so that you can
compare different measurements of the same physical thing.  Might as well
use the same means for both, I would say.

A simple definition of a test to replace set containment would be

{k, m, tolerance | k - (m * 1.62) <= tolerance}

This would return a boolean.  What is needed is a way to get from the
original statement of the (k,m) relationship to this form.

Cheers,

Tom P



-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org> , an
initiative of OASIS <http://www.oasis-open.org> 

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://lists.xml.org/ob/adm.pl> 
Thread:
Roger L. Costello
=?ISO-8859-1?Q?Bill_de_h=D3ra?=
Emmanuil Batsis (Manos)
John Cowan
David Carlisle
Thomas B. Passin

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved