Changeset 1743


Ignore:
Timestamp:
09/13/14 14:33:46 (10 years ago)
Author:
rkrimmel
Message:

Fixed replacment routine

Location:
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/RuleUtils.java

    r1742 r1743  
    1616 
    1717import de.ugoe.cs.autoquest.tasktrees.treeifc.IMarkingTemporalRelationship; 
     18import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship; 
    1819import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 
    1920import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 
     
    6465                final ISequenceInstance subsequence = taskFactory 
    6566                                .createNewTaskInstance(model); 
    66                 // TODO: Debugging output 
    6767                /* 
    68                 int modelid = model.getId(); 
    69                 if(modelid == 5412) { 
    70                         System.out.println("Printing session: "); 
    71                         for (int i = 0; i < parent.size();i++) { 
    72                                 System.out.println(parent.get(i)); 
     68                System.out.println("PRINTING MODEL: "); 
     69                for (int i = 0; i < subsequence.getSequence().getChildren().size(); i++) { 
     70                        System.out.println(subsequence.getSequence().getChildren().get(i)); 
     71 
     72                        if (subsequence.getSequence().getChildren().get(i).getType() == "selection") { 
     73                                for (int j = 0; j < ((ISelection) subsequence.getSequence() 
     74                                                .getChildren().get(i)).getChildren().size(); j++) { 
     75                                        if (((IStructuringTemporalRelationship) subsequence 
     76                                                        .getSequence().getChildren().get(i)).getChildren() 
     77                                                        .get(j).getType() == "sequence") { 
     78                                                ISequence foo = (ISequence) ((ISelection) (subsequence 
     79                                                                .getSequence().getChildren().get(i))) 
     80                                                                .getChildren().get(j); 
     81                                                System.out.println("\t" + foo); 
     82                                                for (int k = 0; k < foo.getChildren().size(); k++) { 
     83                                                        System.out.println("\t\t" 
     84                                                                        + foo.getChildren().get(k)); 
     85                                                } 
     86                                                System.out.println(); 
     87                                        } else { 
     88                                                System.out.println("\t" 
     89                                                                + ((ISelection) subsequence.getSequence() 
     90                                                                                .getChildren().get(i)).getChildren() 
     91                                                                                .get(j)); 
     92                                        } 
     93 
     94                                } 
    7395                        } 
    74                         System.out.println("startIndex: " + startIndex + " endIndex: " + endIndex + "\n"); 
    75                         System.out.println("Printing model: "); 
    76                         for(int i = 0; i < ((ISequence)model).getChildren().size();i++) { 
    77                                 System.out.println((ISequence)model.getChildren().get(i));               
    78                         } 
    79                          
    80                 }*/ 
     96 
     97                } 
     98                System.out.println(); 
     99                */ 
    81100                // TODO: This is dirty, return this in addition with the sequence 
    82101                // instance instead 
     
    89108                        } 
    90109                        final ITask tempTask = model.getChildren().get(modelindex); 
    91                         // System.out.println("Trying to add " + parent.get(startIndex) 
     110                        //System.out.println("Trying to add " + parent.get(startIndex) 
    92111                        // + " to the model instance " + tempTask); 
    93112                        if (tempTask.getType() == "optionality") { 
     
    111130                                } 
    112131                        } else if (tempTask instanceof ISelection) { 
    113                                 final ISelectionInstance selection = taskFactory.createNewTaskInstance((ISelection) tempTask); 
     132                                final ISelectionInstance selection = taskFactory 
     133                                                .createNewTaskInstance((ISelection) tempTask); 
    114134                                final ISelection tmpSel = (ISelection) tempTask; 
    115                                 //Check if the selection has 2 sequences as children 
    116                                 if ((tmpSel.getChildren().get(0) instanceof ISequence) && (tmpSel.getChildren().get(1) instanceof ISequence)) { 
     135                                if (tmpSel.getChildren().size() == 0) { 
     136                                        try { 
     137                                                throw new Exception("Selection without children"); 
     138                                        } catch (Exception e) { 
     139                                                e.printStackTrace(); 
     140                                        } 
     141                                } 
     142                                // Check if the selection has 2 sequences as children 
     143                                // TODO: This segment is a mess, clean it up. 
     144                                if ((tmpSel.getChildren().get(0) instanceof ISequence) 
     145                                                && (tmpSel.getChildren().get(1) instanceof ISequence)) { 
    117146                                        ISequenceInstance selseq = null; 
    118                                         // The selection I create can just have 2 children, we need to check here, to which sequence of the model this occurence belongs 
    119                                         //This if checks of the occurrence is equal to the first element of the first sequence in the model 
    120                                         if (parent.get(startIndex).getTask().equals(((ISequence) tmpSel.getChildren().get(0)).getChildren().get(0))) { 
    121                                                 selseq = taskFactory.createNewTaskInstance((ISequence) tmpSel.getChildren().get(0)); 
    122                                         //This if checks of the occurrence is equal to the first element of the second sequence in the model                                             
    123                                         } else if (parent.get(startIndex).getTask().equals(((ISequence) tmpSel.getChildren().get(1)).getChildren().get(0))) { 
    124                                                 selseq = taskFactory.createNewTaskInstance((ISequence) tmpSel.getChildren().get(1)); 
    125                                         //If the occurence is already a sequence we don't need to do anything, the next iteration will detect this as a sequence and add it 
    126                                         } else if ((parent.get(startIndex).getTask().equals(tmpSel.getChildren().get(0).getId())) 
    127                                                         || (parent.get(startIndex).getTask().equals(tmpSel.getChildren().get(1).getId()))) { 
     147                                        // The selection I create can just have 2 children, we need 
     148                                        // to check here, to which sequence of the model this 
     149                                        // occurence belongs 
     150                                        // This if checks of the occurrence is equal to the first 
     151                                        // element of the first sequence in the model 
     152                                        if (parent 
     153                                                        .get(startIndex) 
     154                                                        .getTask() 
     155                                                        .equals(((ISequence) tmpSel.getChildren().get(0)) 
     156                                                                        .getChildren().get(0))) { 
     157                                                selseq = taskFactory 
     158                                                                .createNewTaskInstance((ISequence) tmpSel 
     159                                                                                .getChildren().get(0)); 
     160                                                for (int k = 0; k < selseq.getSequence().getChildren() 
     161                                                                .size(); k++) { 
     162                                                        taskBuilder 
     163                                                                        .addChild(selseq, parent.get(startIndex)); 
     164                                                        taskBuilder.removeTaskInstance(parent, startIndex); 
     165                                                        i++; 
     166                                                } 
     167                                                taskBuilder.setChild(selection, selseq); 
     168                                                taskBuilder.addChild(subsequence, selection); 
     169                                                modelindex++; 
     170                                                continue; 
     171                                        } 
     172                                        // This if checks of the occurrence is equal to the first 
     173                                        // element of the second sequence in the model 
     174                                        else if (parent 
     175                                                        .get(startIndex) 
     176                                                        .getTask() 
     177                                                        .equals(((ISequence) tmpSel.getChildren().get(1)) 
     178                                                                        .getChildren().get(0))) { 
     179                                                selseq = taskFactory 
     180                                                                .createNewTaskInstance((ISequence) tmpSel 
     181                                                                                .getChildren().get(1)); 
     182                                                for (int k = 0; k < selseq.getSequence().getChildren() 
     183                                                                .size(); k++) { 
     184                                                        taskBuilder 
     185                                                                        .addChild(selseq, parent.get(startIndex)); 
     186                                                        taskBuilder.removeTaskInstance(parent, startIndex); 
     187                                                        i++; 
     188                                                } 
     189                                                taskBuilder.setChild(selection, selseq); 
     190                                                taskBuilder.addChild(subsequence, selection); 
     191                                                modelindex++; 
     192                                                continue; 
     193                                        } 
     194                                        // If the occurrence is already a sequence wedon't need to 
     195                                        // do anything, the next iteration will detect this as a 
     196                                        // sequence and add it 
     197                                        else if ((parent.get(startIndex).getTask().equals(tmpSel 
     198                                                        .getChildren().get(0))) 
     199                                                        || (parent.get(startIndex).getTask().equals(tmpSel 
     200                                                                        .getChildren().get(1)))) { 
    128201                                                taskBuilder.setChild(selection, parent.get(startIndex)); 
    129202                                                taskBuilder.addChild(subsequence, selection); 
    130                                                 taskBuilder.removeTaskInstance(parent, startIndex); 
     203                                                taskBuilder.removeTaskInstance(parent,startIndex); 
    131204                                                modelindex++; 
    132205                                                continue; 
    133                                                  
    134                                         } 
    135                                         //TODO: Sometimes nullpointer exception here :( 
    136                                         for (int k = 0; k < ((ISequence)tmpSel.getChildren().get(0)).getChildren().size(); k++) { 
    137                                                 taskBuilder.addChild(selseq, parent.get(startIndex)); 
    138                                                 taskBuilder.removeTaskInstance(parent, startIndex); 
    139                                                 i++; 
    140                                         } 
    141                                         taskBuilder.setChild(selection, selseq); 
    142                                         taskBuilder.addChild(subsequence, selection); 
    143                                         modelindex++; 
    144                                         continue; 
    145                                 //It is just a plain selection 
    146                                 } else { 
     206                                        } 
     207                                } 
     208                                // It is just a plain selection 
     209                                else { 
    147210                                        taskBuilder.setChild(selection, parent.get(startIndex)); 
    148211                                        taskBuilder.addChild(subsequence, selection); 
     
    160223 
    161224                taskBuilder.addTaskInstance(parent, startIndex, subsequence); 
    162          
    163225 
    164226                return subsequence; 
     
    227289                                // Thread.currentThread().getName() + ": " + Math.round((float) 
    228290                                // count/size*100))+ "%"); 
    229                                 System.out.println(message + " in thread " 
    230                                 + Thread.currentThread().getName() + ": " 
    231                                 + Math.round(((float) count / size) * 100) + "%"); 
     291                                // System.out.println(message + " in thread " 
     292                                // + Thread.currentThread().getName() + ": " 
     293                                // + Math.round(((float) count / size) * 100) + "%"); 
    232294                        } 
    233295                } else { 
     
    235297                        // Thread.currentThread().getName() + ": " +Math.round((float) 
    236298                        // count/size*100))+ "%"); 
    237                         System.out.println(message + " in thread " 
    238                         + Thread.currentThread().getName() + ": " 
    239                         + Math.round(((float) count / size) * 100) + "%"); 
     299                        // System.out.println(message + " in thread " 
     300                        // + Thread.currentThread().getName() + ": " 
     301                        // + Math.round(((float) count / size) * 100) + "%"); 
    240302 
    241303                } 
  • branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignment.java

    r1742 r1743  
    7575 
    7676        /** The n threads. */ 
    77         public static int nThreads = Runtime.getRuntime().availableProcessors() - 1; 
     77        //public static int nThreads = Runtime.getRuntime().availableProcessors() - 1; 
     78        public static int nThreads = 1; 
    7879 
    7980        /** The iteration. */ 
Note: See TracChangeset for help on using the changeset viewer.