Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [henshin-dev] InterpreterUtil.areIsomorphic(graph1, graph2) not working

Hi Faezeh,

you don't need to create resources to make the comparison. If you want to do it with EcoreUtil, just call:

EcoreUtil.equals(requestedModel, providedModel);

If you want to do it with Henshin:

InterpreterUtil.areIsomorphic(new EGraphImpl(requiredModel), new EGraphImpl(providedModel));

If EcoreUtil.equals() returns false, the models cannot be 100% identical. What you could try to do is either save the two models to files and compare the files, or debug into the EcoreUtil.equals() method. You should find at some point that haveEqualFeatures() returns false.

Hope this helps.

Cheers,
Christian

2014-03-20 9:39 GMT+01:00 Faezeh Ghassemi <faezeh.ghassemi@xxxxxxxxx>:
Dear Christian,

Thank you very much for your reply.

EcoreUtil.equals(..,..) also returns false for my models, although I compare a model file with it's own copy, so they are actually the same models. (Attached you can find an example model)

Here is the code that I use for loading and comparing the resources: (you can find some more explanations below)

    protected boolean matchProtocols(FSMProtocol requestedModel, FSMProtocol providedModel) {

        ResourceSet resourceSet = new ResourceSetImpl();

        //requested resource
        String tempRqstFilePath = requestedModel.eResource().getURI().trimSegments(1).toString() + "/tempRequested";
        Resource requestedResource = resourceSet.createResource(URI.createPlatformResourceURI(tempRqstFilePath, true));
        requestedResource.getContents().add(requestedModel);

        //provided resource
        String tempPrvdFilePath = providedModel.eResource().getURI().trimSegments(1).toString() + "/tempProvided";
        Resource providedResource = resourceSet.createResource(URI.createPlatformResourceURI(tempPrvdFilePath, true));
        providedResource.getContents().add(providedModel);
       
       
        EGraph rqstGraph = new EGraphImpl(requestedResource);
        EGraph prvdGraph = new EGraphImpl(providedResource);
       
        boolean matchingResult = InterpreterUtil.areIsomorphic(rqstGraph, prvdGraph);
        return matchingResult;

    }
  • Our models represent simple Finite State Machines.
  • FSMProtocol is the type of our models.
  • For creating a ResourceSet, here I have used the normal EMF mechanism, but I also have tried it with HenshinResourceSet, and the specific Resource Factory of our mode.
  • For comparing the models, I have tried the followings:
    • Creating EGraph, using the Reources (as above), and comparing the graphs,
    • Also, comparing the resources directly, without creating a graph.
  • Till now, the method InterpreterUtil.areIsomorphic(..., ...) have returned true, only in the case that I add empty models to the graphs.  >>> EGraph graph = new EGraphImpl(); graph.add(emptyModel);  <<<<

Thank you very much in advance for any help.

Best regards,

Faezeh




2014-03-19 19:02 GMT+01:00 Christian Krause <henshin.ck@xxxxxxxxx>:

Dear Faezeh,

I would need more information to find out what the problem is. Could you maybe provide the example models? Maybe also the code that you use for comparing them with Henshin?

What you can try out is whether EcoreUtil.equals(..,..) also returns false. In general, if EcoreUtil.equals() returns true, then InterpreterUtil.areIsomorphic() should also return true (but not necessarily in the opposite direction).

Cheers,
Christian 


2014-03-19 15:44 GMT+01:00 Faezeh Ghassemi <faezeh.ghassemi@xxxxxxxxx>:
Dear Henshin developers,

I am trying to use the method InterpreterUtil.areIsomorphic(graph1, graph2) for two models which I have previously created with EMF.

I load the models in two different resources, using EMF mechanism, and afterwards I transform the models into the Henshin format (EGraph), and then I compare them using the method areIsomorphic. But it returns false,
although the model files are exactly identical!

I would appreciate any help or guide in model comparison using Henshin :)

Best regards,
Faezeh Ghassemi

_______________________________________________
henshin-dev mailing list
henshin-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/henshin-dev



_______________________________________________
henshin-dev mailing list
henshin-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/henshin-dev




Back to the top