User Tools

Site Tools


ptidej_solver

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
ptidej_solver [2014/03/31 14:46]
yann [Problem Motifs Definitions]
ptidej_solver [2014/03/31 14:51]
yann [Problem Motifs Definitions]
Line 7: Line 7:
 Because it uses a constraint solver, Ptidej requires each motif to be defined as a constraint satisfaction problem. A simple example of problem follows: Because it uses a constraint solver, Ptidej requires each motif to be defined as a constraint satisfaction problem. A simple example of problem follows:
  
 +<​code>​
 public final class CompositionAndInheritanceTest { public final class CompositionAndInheritanceTest {
- public static final char[] SUPER_ENTITY = "​SuperEntity"​.toCharArray();​ 
- public static final char[] SUB_ENTITY = "​SubEntity"​.toCharArray();​ 
- 
  public static Problem getProblem(final List allEntities) {  public static Problem getProblem(final List allEntities) {
  final Problem pb =  final Problem pb =
Line 19: Line 17:
  
  final Variable subEntity =  final Variable subEntity =
- new Variable(pb, ​CompositionAndInheritanceTest.SUB_ENTITY, true);+ new Variable(pb, ​"​SubEntity"​.toCharArray(), true);
  final Variable superEntity =  final Variable superEntity =
- new Variable(pb, ​CompositionAndInheritanceTest.SUPER_ENTITY, true);+ new Variable(pb, ​"​SuperEntity"​.toCharArray(), true);
  
  pb.addVar(subEntity);​  pb.addVar(subEntity);​
  pb.addVar(superEntity);​  pb.addVar(superEntity);​
  
- final ​InheritancePathConstraint ​c1 = + final ​StrictInheritanceConstraint ​c1 = 
- new ​InheritancePathConstraint+ new ​StrictInheritanceConstraint
- "​SuperEntity ​-|>- ... -|>- SubEntity",​ + "​SuperEntity -|>- SubEntity",​ 
- "​throw new RuntimeException(\"​SuperEntity ​-|>- ... -|>- SubEntity\"​);",​+ "​throw new RuntimeException(\"​SuperEntity -|>- SubEntity\"​);",​
  subEntity,​  subEntity,​
  superEntity,​  superEntity,​
Line 49: Line 47:
  }  }
 } }
 +</​code>​
  
 +In this problem, two roles are defined: that of ''​SubClass''​ and of ''​SuperClass''​. For classes to play the roles of ''​SubClass''​ and ''​SuperClass'',​ the ''​SubClass''​ must inherit from the ''​SuperClass''​ (even if zero, one, or more entities stands between the ''​SubClass''​ and the ''​SuperClass''​ in the inheritance tree) and the ''​SubClass''​ must be composed of instances of the ''​SuperClass''​.
  
 ===== Constraints Definitions ===== ===== Constraints Definitions =====
ptidej_solver.txt · Last modified: 2019/10/06 20:37 (external edit)