src/java/isac/util/interfaces/IToCalc.java
author wneuper
Fri, 24 Sep 2004 11:13:37 +0200
changeset 1873 d943efe20ebe
parent 1713 07b0d4921072
child 1876 6638177386a8
permissions -rw-r--r--
methods for calcHead shifted from MathEngine to CalcHead
rgradisc@1311
     1
/*
rgradisc@1311
     2
 * Created on Sep 19, 2003
rgradisc@1311
     3
 */
rgradisc@1311
     4
package isac.util.interfaces;
rgradisc@1311
     5
akremp@1629
     6
import java.rmi.Remote;
akremp@1629
     7
import java.rmi.RemoteException;
akremp@1629
     8
wneuper@1873
     9
import isac.util.Formalization;
rgradisc@1311
    10
import isac.util.formulae.*;
rgradisc@1311
    11
import isac.util.tactics.*;
rgradisc@1311
    12
rgradisc@1311
    13
rgradisc@1311
    14
/**
rgradisc@1311
    15
 * Interface to be used to communicate in the direction towards the Math Engine.
rgradisc@1311
    16
 * 
akremp@1338
    17
 * @author Alan Krempler
wneuper@1873
    18
 * WN040924 rename to ICalcTree !
rgradisc@1311
    19
 */
rgradisc@1311
    20
akremp@1661
    21
public interface IToCalc extends Remote {
rgradisc@1311
    22
	
rgradisc@1311
    23
	
rgradisc@1311
    24
	/**
rgradisc@1311
    25
	 * Get a new iterator referencing the root element of the calculation tree. 
rgradisc@1311
    26
	 * <p> The functionality for navigating the calculation 
rgradisc@1311
    27
	 * is implemented in the CalcIterator object.
rgradisc@1311
    28
	 * @return new instance of CalcIterator
rgradisc@1311
    29
	 */
akremp@1629
    30
	public ICalcIterator iterator()  throws RemoteException;
rgradisc@1311
    31
	  
rgradisc@1311
    32
	/**
rgradisc@1311
    33
	 * Register a new listener who wants to be notified of changes in the data.
rgradisc@1311
    34
	 * The listener has to implement the IToUser interface.
rgradisc@1311
    35
	 * 
rgradisc@1311
    36
	 * @param listener New listener to be registered.
rgradisc@1311
    37
	 * @return false on success, true otherwise.
rgradisc@1311
    38
	 */  
akremp@1629
    39
	public boolean addDataChangeListener(IToUser listener)  throws RemoteException;
rgradisc@1311
    40
	
rgradisc@1311
    41
	/**
rgradisc@1311
    42
	 * @return an iterator referencing the current
rgradisc@1311
    43
	 * "hot spot" in the calculation, i.e. the active formula.
rgradisc@1311
    44
	 */
akremp@1629
    45
	public ICalcIterator getActiveFormula() throws RemoteException;
rgradisc@1311
    46
	
rgradisc@1311
    47
	/**
akremp@1338
    48
	 * Makes the passed formula the active formula, i.e. the formula 
akremp@1338
    49
	 * the next tactic is applied to.
akremp@1338
    50
	 * @param newActiveFormula Iterator referencing the new desired position
akremp@1338
    51
	 */
akremp@1629
    52
	public void moveActiveFormula(ICalcIterator newActiveFormula) throws RemoteException;
rgradisc@1311
    53
	
wneuper@1873
    54
	 /**
wneuper@1873
    55
	  * Enter the solving phase of the calculation.
wneuper@1873
    56
	  * StartSpecifying must be called first
wneuper@1873
    57
	  * Only possible with a complete and correct calcHead
wneuper@1873
    58
	  * @param calcHead CalcHead for this calculation
wneuper@1873
    59
	  * @return CalcTree represents the calculation on the java side
wneuper@1873
    60
	  */
wneuper@1873
    61
	 public void startSolving(/*CalcHead calcHead*/) throws Exception;
wneuper@1873
    62
	  
wneuper@1873
    63
	 /**
wneuper@1873
    64
	   * Modify a given CalcHead    
wneuper@1873
    65
	   * The result is the same CalcHead with status flags for each item
wneuper@1873
    66
	   * @see CalcHead for possible status flags
wneuper@1873
    67
	   * @param calcHead CalcHead to be modified 
wneuper@1873
    68
	   * @return new CalcHead with a status for each item   
wneuper@1873
    69
	   */
wneuper@1873
    70
	 public void modifyCalcHead(CalcHead calcHead);
wneuper@1873
    71
	  
wneuper@1873
    72
	 /**
wneuper@1873
    73
	   * Complete a given calcHead: Tell the Kernel to fill out 
wneuper@1873
    74
	   * all the missing fields in the calcHead
wneuper@1873
    75
	   * @param calcHead the calcHead to be completed
wneuper@1873
    76
	   */
wneuper@1873
    77
	 public void completeCalcHead(CalcHead calcHead);
wneuper@1873
    78
	  
wneuper@1873
    79
	 /**
wneuper@1873
    80
	  * Complete a given calcHead: Tell the Kernel to fill out 
wneuper@1873
    81
	  * a missing fields in the calcHead, which is specified by an
wneuper@1873
    82
	  * parameter
wneuper@1873
    83
	  * @param calcHead the calcHead to be completed
wneuper@1873
    84
	  * @param completeItem the item which should be added
wneuper@1873
    85
	  * 
wneuper@1873
    86
	  * WN040916 don't confuse with autCalculate(...CompleteCalcHead)
wneuper@1873
    87
	  */
wneuper@1873
    88
	 public void completeCalcHead(CalcHead calcHead, int completeItem);
wneuper@1873
    89
	 
wneuper@1873
    90
	 /**
akremp@1338
    91
	 * Tries to replaces the active formula in the calculation tree by 
akremp@1338
    92
	 * the passed formula. This could fail if no valid derivation from 
akremp@1338
    93
	 * the preceding formula to the (new) active formula can be found. 
akremp@1338
    94
	 * <p>Parts of the calculation after the replaced 
akremp@1338
    95
	 * formula are likely to become invalid, listeners will be informed
akremp@1338
    96
	 * of this with the update message, which contains the last unchanged 
akremp@1338
    97
	 * formula.
akremp@1338
    98
	 * @param newFormula
akremp@1338
    99
	 * @return The method will return 0 on success or a nonzero value 
akremp@1338
   100
	 * indicating the status otherwise. 
akremp@1338
   101
	 */
akremp@1629
   102
	public int replaceFormula(Formula newFormula) throws RemoteException;
rgradisc@1311
   103
	
rgradisc@1311
   104
	/**
rgradisc@1311
   105
	Tries to append the passed formula after the active formula. 
rgradisc@1311
   106
	This could fail if no valid derivation from the preceding formula 
rgradisc@1311
   107
	to the (new) active formula can be found. The method will fail as 
rgradisc@1311
   108
	well if the active formula is not the last formula in the (sub)calculation.
rgradisc@1311
   109
	Parts of the calculation might become invalid.
rgradisc@1311
   110
	* @param newFormula
rgradisc@1311
   111
	* @return The method will return 0 on success or a nonzero value 
rgradisc@1311
   112
	indicating the status otherwise.
rgradisc@1311
   113
	*/
akremp@1629
   114
	public int appendFormula(Formula newFormula) throws RemoteException;
rgradisc@1311
   115
	
rgradisc@1311
   116
	/**
akremp@1373
   117
	 Set the tactic to be used in the next step of calculation.   
rgradisc@1311
   118
	 * @param tactic the Tactic to be used in the the next step
rgradisc@1311
   119
	 * @return The return value indicates success, failure or probable
akremp@1338
   120
	 * success at a later time.
rgradisc@1311
   121
	 */
akremp@1629
   122
	 public int setNextTactic(Tactic tactic) throws RemoteException;
rgradisc@1311
   123
	 
rgradisc@1311
   124
	/**
akremp@1338
   125
	 * Retrieve the tactic proposed by the SML-Kernel for 
akremp@1338
   126
	 * the next step in the calculation.  
rgradisc@1311
   127
	 * @return proposed tactic.
rgradisc@1311
   128
	 * Can be null, if the kernel does
rgradisc@1311
   129
	 * not know what to do next, or if the end 
rgradisc@1311
   130
	 * of the calculation is reached 
rgradisc@1311
   131
	 */
akremp@1629
   132
	 public Tactic fetchProposedTactic() throws RemoteException;
rgradisc@1311
   133
	 
akremp@1379
   134
	/**
akremp@1379
   135
	 * Fetch all tactics applicable to the current situation known to
akremp@1379
   136
	 * the system.
akremp@1379
   137
	 * @see #fetchApplicableTactics(int)
akremp@1379
   138
	 */
rgradisc@1311
   139
	 public static final int TACTICS_ALL = 1;
akremp@1379
   140
	/**
akremp@1379
   141
	 * Fetch all tactics applicable to the current situation, but restrict
akremp@1379
   142
	 * the result to tactics from the current theory.
akremp@1379
   143
	 * @see #fetchApplicableTactics(int)
akremp@1379
   144
	 */
rgradisc@1311
   145
	 public static final int TACTICS_CURRENT_THEORY = 2;
akremp@1379
   146
	/**
akremp@1379
   147
	 * Fetch all tactics applicable to the current situation, but restrict 
akremp@1379
   148
	 * the result to tactics from the method being applied.
akremp@1379
   149
	 * @see #fetchApplicableTactics(int)
akremp@1379
   150
	 */
rgradisc@1311
   151
	 public static final int TACTICS_CURRENT_METHOD = 3;
rgradisc@1311
   152
	 
rgradisc@1311
   153
	 
rgradisc@1311
   154
	/**
akremp@1338
   155
	 * Get a list of tactics applicable to the active formula. 
rgradisc@1311
   156
	 * @param scope The filter parameter selects the scope of
akremp@1338
   157
	 * search for applicable tactics.
akremp@1338
   158
	 * @return Array with applicable tactics
akremp@1338
   159
	 * @see #TACTICS_ALL
akremp@1338
   160
	 * @see #TACTICS_CURRENT_THEORY
akremp@1338
   161
	 * @see #TACTICS_CURRENT_METHOD
rgradisc@1311
   162
	 */
akremp@1629
   163
	 public Tactic[] fetchApplicableTactics(int scope) throws RemoteException;
rgradisc@1311
   164
	 
akremp@1379
   165
	/**
akremp@1379
   166
	 * Do the number of steps requested, without any restrictions.
wneuper@1713
   167
	 * autoCalculate ... CompleteCalc
akremp@1379
   168
	 * Do NOT change the value of this constant, as this 
akremp@1379
   169
	 * number has a specifig meaning in other parts of the system!
akremp@1379
   170
	 * @see #autoCalculate(int, int)
akremp@1379
   171
	 */	 
akremp@1379
   172
	 public static final int SCOPE_CALCULATION = 6;
akremp@1379
   173
	/**
akremp@1379
   174
	 * Do the number of steps requested, but do not leave the 
wneuper@1713
   175
	 * current subcalculation into a subproblem: CompleteToSubpbl
akremp@1379
   176
	 * Do NOT change the value of this constant, as this 
akremp@1379
   177
	 * number has a specifig meaning in other parts of the system!
akremp@1379
   178
	 * @see #autoCalculate(int, int)
akremp@1379
   179
	 */	 
akremp@1379
   180
	 public static final int SCOPE_SUBCALCULATION = 5;
akremp@1379
   181
	/**
akremp@1379
   182
	 * Do the number of steps requested, but do not leave the 
wneuper@1713
   183
	 * current subproblem: autoCalculate ... CompleteSubpbl
akremp@1379
   184
	 * Do NOT change the value of this constant, as this 
akremp@1379
   185
	 * number has a specifig meaning in other parts of the system!
akremp@1379
   186
	 * @see #autoCalculate(int, int)
akremp@1379
   187
	 */	 
akremp@1379
   188
	 public static final int SCOPE_SUBPROBLEM = 4;
rgradisc@1311
   189
	 
rgradisc@1311
   190
	/**
akremp@1661
   191
	 * Calculate the next n steps starting from the active formula or until the 
akremp@1661
   192
	 * specified scope is left, whichever comes first.   
rgradisc@1311
   193
	 * @param scope The scope parameter can have following values:
rgradisc@1311
   194
	 * @param nSteps Specifies the count of steps to be autocalculated. 
akremp@1338
   195
	 * Passing 0 for nSteps will calculate until reaching a final result. 
rgradisc@1311
   196
	 * @return The method returns an unique id to identify the request when 
akremp@1338
   197
	 * notifying about updates in the tree.
akremp@1338
   198
	 * @see #SCOPE_CALCULATION
akremp@1338
   199
	 * @see #SCOPE_SUBCALCULATION
akremp@1338
   200
	 * @see #SCOPE_SUBPROBLEM
rgradisc@1311
   201
	 */
wneuper@1713
   202
	/*WN040624: the above design is desirable, but currently not impl., rather:
rgradisc@1618
   203
	 * either steps == 0, then regard SCOPE_*
rgradisc@1618
   204
	 * or	  steps != 0, then SCOPE_* irrelevant !
rgradisc@1618
   205
	 */
akremp@1629
   206
	 public int autoCalculate(int scope, int nSteps) throws RemoteException;
rgradisc@1311
   207
	  
rgradisc@1311
   208
}