Re: product types in OCL 2.0



Date view Thread view Subject view Author view Attachment view

From: Joaquin Miller (miller@joaquin.net)
Date: Thu 20 Feb 2003 - 16:33:11 GMT


That might do the job.  But now i have a new class in my model, when all i 
wanted was a Cartesian product in an OCL statement.


>A very simple possibility to model the Cartesian Product is the following:
>
>Suppose you want to model the product of objects of classes A and B.
>This can be done by introduction of a new class ProdAB a s follows:
>
>  -----                              -----
>  - A  -                               - B  -
>  -----                              -----
>     | 1                                       |1
>     |                                          |
>     |              --------          |
>     ------|  ProdAB |-----
>               * -------- *
>
>constraints:
>
>--  uniqueness
>    ProdAB.allInstances->forall(p1,p2| p1.a = p2.a and p1.b = p2.b implies 
> p1 = p2)
>
>-- totality
>   A.allInstances->forAll(a1| B.allInstances->forAll(b1|
>        ProdAB->exists(p| p.a = a1 and p.b = b1)))

Date view Thread view Subject view Author view Attachment view