@@ -1271,6 +1271,8 @@ else if (mult1 == ModelElement.MANY && mult2 == ModelElement.ONE)
12711271 ematch , entities ,
12721272 modmatch , res );
12731273 }
1274+ else
1275+ { multiplicityReduction (); }
12741276
12751277 q .addSourceEntity (realsrc );
12761278 q .addTargetEntity (realtrg );
@@ -1319,6 +1321,8 @@ else if (mult1 == ModelElement.MANY && mult2 == ModelElement.MANY &&
13191321 "Feature " + realsrc + "::" + src +
13201322 " narrowed from * to 0..1 multiplicity in " +
13211323 realtrg + "::" + trg );
1324+ multiplicityReduction ();
1325+
13221326 q .addSourceEntity (realsrc );
13231327 q .addTargetEntity (realtrg );
13241328 q .addSourceFeature (src );
@@ -1397,6 +1401,29 @@ private void optionalToTotal(Entity realtrgsup, Entity realsrc, Entity realtrg,
13971401 }
13981402 }
13991403 }
1404+
1405+ public void multiplicityReduction ()
1406+ { // src is *, trg is not
1407+ Type elemT = src .getElementType ();
1408+ if (elemT != null && elemT .isNumeric ())
1409+ { System .out .println (">>> Suggest replacing " + src + " |--> " + trg );
1410+ System .out .println ("with reduction such as " + src + "->sum() |--> " + trg );
1411+ }
1412+ else if (elemT != null && elemT .isString ())
1413+ { System .out .println (">>> Suggest replacing " + src + " |--> " + trg );
1414+ System .out .println ("with reduction such as " + src + "->sum() |--> " + trg );
1415+ }
1416+ else if (src .isOrdered ())
1417+ { System .out .println (">>> Suggest replacing " + src + " |--> " + trg );
1418+ System .out .println ("with reduction such as " + src + "->first() |--> " + trg );
1419+ System .out .println ("or " + src + "->last() |--> " + trg );
1420+ }
1421+ else
1422+ { System .out .println (">>> Suggest replacing " + src + " |--> " + trg );
1423+ System .out .println ("with reduction such as " + src + "->any() |--> " + trg );
1424+ }
1425+ System .out .println ();
1426+ }
14001427
14011428 public boolean isEquality ()
14021429 { // types are the same
@@ -3776,10 +3803,10 @@ public void checkModel(ModelSpecification mod,
37763803 ObjectSpecification tobj = (ObjectSpecification ) trgobjs .get (i );
37773804
37783805 if (src .isEnumeration () && trg .isEnumeration ())
3779- { String senumval = sobj .getEnumerationValue (src ,mod );
3780- String tenumval = tobj .getEnumerationValue (trg ,mod );
3781- xstrs [i ] = senumval ;
3782- ystrs [i ] = tenumval ;
3806+ { String senumval = sobj .getEnumerationValue (src ,mod );
3807+ String tenumval = tobj .getEnumerationValue (trg ,mod );
3808+ xstrs [i ] = senumval ;
3809+ ystrs [i ] = tenumval ;
37833810 if (senumval != null && tenumval != null && senumval .equals (tenumval ))
37843811 { System .out .println (">> objects " + sobj + " and" );
37853812 System .out .println (tobj + " satisfy matching " + this );
@@ -3845,8 +3872,8 @@ else if (src.isString() && trg.isString())
38453872 else
38463873 { System .out .println ("!! objects " + sobj + " and" );
38473874 System .out .println (tobj + " fail to satisfy matching " + this );
3848- valid = false ;
3849- removed .add (this );
3875+ valid = false ;
3876+ removed .add (this );
38503877 }
38513878 System .out .println ("----------------------" );
38523879 System .out .println ();
@@ -3860,29 +3887,29 @@ else if (src.isEntity() && trg.isEntity())
38603887 { System .out .println ("?? Incomplete model: Referred object " + trg + " of " + tobj + " is undefined." ); }
38613888 if (trgobj != null && srcobj != null )
38623889 { if (mod .correspondence .getAll (srcobj ) != null && mod .correspondence .getAll (srcobj ).contains (trgobj ))
3863- { System .out .println (">> objects " + srcobj + " and" );
3864- System .out .println (trgobj + " correspond." );
3865- System .out .println (">> objects " + sobj + " and" );
3866- System .out .println (tobj + " satisfy matching " + this );
3890+ { System .out .println (">> objects " + srcobj + " and" );
3891+ System .out .println (trgobj + " correspond." );
3892+ System .out .println (">> objects " + sobj + " and" );
3893+ System .out .println (tobj + " satisfy matching " + this );
38673894 }
3868- else
3869- { System .out .println (">> objects " + srcobj + " and" );
3895+ else
3896+ { System .out .println (">> objects " + srcobj + " and" );
38703897 System .out .println (trgobj + " do not correspond." );
38713898 System .out .println ("!! objects " + sobj + " " + tobj + " fail to satisfy matching " + this );
3872- valid = false ;
3873- removed .add (this );
3874- }
3875- }
3876- else
3877- { valid = false ;
3878- removed .add (this );
3879- }
3880- System .out .println ("----------------------" );
3881- System .out .println ();
3882- }
3883- else if (src .isCollection () && trg .isCollection ())
3884- { Vector srcvect = sobj .getCollectionValue (src ,mod );
3885- Vector trgvect = tobj .getCollectionValue (trg ,mod );
3899+ valid = false ;
3900+ removed .add (this );
3901+ }
3902+ }
3903+ else
3904+ { valid = false ;
3905+ removed .add (this );
3906+ }
3907+ System .out .println ("----------------------" );
3908+ System .out .println ();
3909+ }
3910+ else if (src .isCollection () && trg .isCollection ())
3911+ { Vector srcvect = sobj .getCollectionValue (src ,mod );
3912+ Vector trgvect = tobj .getCollectionValue (trg ,mod );
38863913
38873914 xvect [i ] = srcvect ;
38883915 yvect [i ] = trgvect ;
@@ -3894,7 +3921,7 @@ else if (src.isCollection() && trg.isCollection())
38943921 }
38953922 else if (mod .correspondingObjectSequences (sent ,tent ,srcvect ,trgvect ))
38963923 { System .out .println (">> objects " + sobj + " and" );
3897- System .out .println (tobj + " satisfy matching " + this );
3924+ System .out .println (tobj + " satisfy matching " + this );
38983925 }
38993926 else
39003927 { System .out .println ("!! objects " + sobj + " and" );
@@ -3907,28 +3934,28 @@ else if (mod.correspondingObjectSequences(sent,tent,srcvect,trgvect))
39073934 }
39083935 else if (src .isCollection () && trg .isCollection ())
39093936 { // System.out.println(srcvect + " " + trgvect);
3910- if (srcvect .containsAll (trgvect ) && trgvect .containsAll (srcvect ))
3911- { System .out .println (">> objects " + sobj + " and" );
3912- System .out .println (tobj + " satisfy matching " + this );
3913- }
3914- else if (mod .correspondingObjectSets (srcvect ,trgvect ))
3915- { System .out .println (">> objects " + sobj + " and" );
3916- System .out .println (tobj + " satisfy matching " + this );
3917- }
3918- else
3919- { System .out .println ("!! Collections " + srcvect );
3920- System .out .println (trgvect + " Do not correspond" );
3921- System .out .println (">> Sizes are " + srcvect .size () + " and " + trgvect .size ());
3922- System .out .println ("!! objects " + sobj + " and" );
3923- System .out .println (tobj + " fail to satisfy matching " + this );
3924- valid = false ;
3937+ if (srcvect .containsAll (trgvect ) && trgvect .containsAll (srcvect ))
3938+ { System .out .println (">> objects " + sobj + " and" );
3939+ System .out .println (tobj + " satisfy matching " + this );
3940+ }
3941+ else if (mod .correspondingObjectSets (srcvect ,trgvect ))
3942+ { System .out .println (">> objects " + sobj + " and" );
3943+ System .out .println (tobj + " satisfy matching " + this );
3944+ }
3945+ else
3946+ { System .out .println ("!! Collections " + srcvect );
3947+ System .out .println (trgvect + " Do not correspond" );
3948+ System .out .println (">> Sizes are " + srcvect .size () + " and " + trgvect .size ());
3949+ System .out .println ("!! objects " + sobj + " and" );
3950+ System .out .println (tobj + " fail to satisfy matching " + this );
3951+ valid = false ;
39253952 // removed.add(this);
3926- }
3927- System .out .println ("----------------------" );
3928- System .out .println ();
3929- }
3930- }
3953+ }
3954+ System .out .println ("----------------------" );
3955+ System .out .println ();
3956+ }
39313957 }
3958+ }
39323959
39333960 if (!valid && src .isEnumeration () && trg .isEnumeration ())
39343961 { if (AuxMath .isConstant (ystrs ))
0 commit comments