src/java/isac/interfaces/IToCalc.java
author wneuper
Thu, 17 Jan 2008 16:27:03 +0100
changeset 3881 72f0be16d83b
parent 3623 374f1db5f95a
child 3928 d38196e9b162
permissions -rw-r--r--
start-work-070517 merged into HEAD
wneuper@2758
     1
/**
wneuper@2758
     2
 * @author Alan Krempler
wneuper@2750
     3
 * Created on Sep 19, 2003
wneuper@2750
     4
 */
wneuper@2750
     5
package isac.interfaces;
wneuper@2750
     6
wneuper@2750
     7
import java.rmi.Remote;
wneuper@2750
     8
import java.rmi.RemoteException;
wneuper@2750
     9
wneuper@2750
    10
import isac.util.formulae.*;
wneuper@2750
    11
import isac.util.tactics.*;
wneuper@2750
    12
wneuper@2750
    13
/**
wneuper@2750
    14
 * Interface to be used to communicate in the direction towards the Math Engine.
wneuper@2750
    15
 * 
wneuper@2750
    16
 * @author Alan Krempler WN040924 rename to ICalcTree ?
wneuper@2750
    17
 */
wneuper@2750
    18
wneuper@2750
    19
public interface IToCalc extends Remote {
wneuper@2750
    20
wneuper@3178
    21
    /** remove the CalcTree in the math-engine
wneuper@3178
    22
     */
wneuper@3178
    23
    public boolean destruct() throws RemoteException;
wneuper@3178
    24
    
wneuper@2750
    25
    /**
wneuper@2750
    26
     * Get a new iterator referencing the root element of the calculation tree.
wneuper@2750
    27
     * <p>
wneuper@2750
    28
     * The functionality for navigating the calculation is implemented in the
wneuper@2750
    29
     * CalcIterator object.
wneuper@2750
    30
     * 
wneuper@2750
    31
     * @return new instance of CalcIterator
wneuper@2750
    32
     */
wneuper@2750
    33
    public ICalcIterator iterator() throws RemoteException;
wneuper@2750
    34
wneuper@2750
    35
    /**
wneuper@2750
    36
     * Register a new listener who wants to be notified of changes in the data.
wneuper@2750
    37
     * The listener has to implement the IToUser interface.
wneuper@2750
    38
     * 
wneuper@2750
    39
     * @param listener
wneuper@2750
    40
     *            New listener to be registered.
wneuper@2750
    41
     * @return false on success, true otherwise.
wneuper@2750
    42
     */
wneuper@2750
    43
    public boolean addDataChangeListener(IToUser listener)
wneuper@2750
    44
            throws RemoteException;
wneuper@2750
    45
wneuper@2750
    46
    /**
wneuper@2750
    47
     * @return an iterator referencing the current "hot spot" in the
wneuper@2750
    48
     *         calculation, i.e. the active formula.
wneuper@2750
    49
     */
wneuper@2750
    50
    public ICalcIterator getActiveFormula() throws RemoteException;
wneuper@2750
    51
wneuper@2750
    52
    /**
wneuper@2750
    53
     * Makes the passed formula the active formula, i.e. the formula the next
wneuper@2750
    54
     * tactic is applied to.
wneuper@2750
    55
     * 
wneuper@2750
    56
     * @param newActiveFormula
wneuper@2750
    57
     *            Iterator referencing the new desired position
wneuper@2750
    58
     */
wneuper@2750
    59
    public void moveActiveFormula(ICalcIterator newActiveFormula)
wneuper@2750
    60
            throws RemoteException;
wneuper@2750
    61
wneuper@2750
    62
    /**
wneuper@2831
    63
     * Set the Descriptions for all ModelItems given by the problem which is
wneuper@2831
    64
     * specified in the CalcHead held in the MathEngine (this may still be
wneuper@2831
    65
     * hidden from the front-end).
wneuper@2831
    66
     * 
wneuper@2838
    67
     * in contrary to isac.interfaces.IToCalc#setNextTactic this method has a
wneuper@2838
    68
     * returnvalue from the calculation.
wneuper@2838
    69
     * 
wneuper@2831
    70
     * @return CalcHead with Descriptions (e.g. equality, solveFor)
wneuper@2831
    71
     * @exception RemoteException
wneuper@2831
    72
     */
wneuper@3142
    73
    public CalcHead modelProblem() throws RemoteException;
wneuper@2831
    74
wneuper@2831
    75
    /**
wneuper@2831
    76
     * Add _ONE_ item to the Model or to the Specification, as long as the
wneuper@2831
    77
     * CalcHead is not complete.
wneuper@2831
    78
     * 
wneuper@2838
    79
     * in contrary to the methods for the solve-phase this method returns a
wneuper@2838
    80
     * value from the calculation.
wneuper@2838
    81
     * 
wneuper@2831
    82
     * @return CalcHead with one item added; if the CalcHead was complete, the
wneuper@2831
    83
     *         CalcHead remains unchanged
wneuper@2831
    84
     * @exception RemoteException
wneuper@2837
    85
     */
wneuper@2831
    86
    public CalcHead nextSpecify() throws RemoteException;
wneuper@2831
    87
wneuper@2831
    88
    /**
wneuper@2831
    89
     * Check a given CalcHead. The result is the same CalcHead with status flags
wneuper@2750
    90
     * for each item
wneuper@2750
    91
     * 
wneuper@2838
    92
     * in contrary to the methods for the solve-phase this method returns a
wneuper@2838
    93
     * value from the calculation.
wneuper@2838
    94
     * 
wneuper@2750
    95
     * @see CalcHead for possible status flags
wneuper@2831
    96
     * @param calc_head
wneuper@2831
    97
     *            CalcHead to be checked
wneuper@2831
    98
     * @return new CalcHead with a status for each item
wneuper@2750
    99
     */
wneuper@2831
   100
    public CalcHead checkCalcHead(CalcHead calc_head) throws RemoteException;
wneuper@2750
   101
wneuper@2750
   102
    /**
wneuper@2837
   103
     * Complete the Model of a CalcHead: Tell the Kernel to fill out all the
wneuper@2837
   104
     * missing fields in the Model; this may not succeed if the (manual) input
wneuper@2837
   105
     * is too messed up (in this case first a resetCalcHead must be done).
wneuper@2750
   106
     * 
wneuper@2838
   107
     * in contrary to the methods for the solve-phase this method returns a
wneuper@2838
   108
     * value from the calculation.
wneuper@2838
   109
     * 
wneuper@2837
   110
     * @return the CalcHead with the completed Model
wneuper@2837
   111
     */
wneuper@2837
   112
    public CalcHead completeModel() throws RemoteException;
wneuper@2837
   113
wneuper@2837
   114
    /**
wneuper@2837
   115
     * Transfer the Theory selected in the TheoryBrowser to the SML-kernel. This
wneuper@2837
   116
     * method is used for transferring the Theory to the Worksheet (i.e. the
wneuper@2837
   117
     * CalcHead with the Theory inserted and checked has to be fetched from the
wneuper@2837
   118
     * SML-kernel by the front-end)
wneuper@2837
   119
     * 
wneuper@2838
   120
     * in contrary to the methods for the solve-phase this method returns a
wneuper@2838
   121
     * value from the calculation.
wneuper@2838
   122
     * 
wneuper@2838
   123
     * @param thy_id
wneuper@2838
   124
     *            the identifier of the theory
wneuper@2837
   125
     * @return CalcHead with the Theory inserted; the new Theory may cause parse
wneuper@2837
   126
     *         errors (because parts of a formula are unknown in this Theory)
wneuper@2837
   127
     *         displayed in the Model (or in the guard)
wneuper@2837
   128
     * @exception RemoteException
wneuper@2837
   129
     */
wneuper@2838
   130
    public CalcHead setTheory(String thy_id) throws RemoteException;
wneuper@2837
   131
wneuper@2837
   132
    /**
wneuper@2837
   133
     * Transfer the Problem selected in the ProblemBrowser to the SML-kernel.
wneuper@2837
   134
     * This method is used for transferring the Problem to the Worksheet (i.e.
wneuper@2837
   135
     * the CalcHead with the Problem inserted and checked has to be fetched from
wneuper@2837
   136
     * the SML-kernel by the front-end)
wneuper@2837
   137
     * 
wneuper@2838
   138
     * in contrary to the methods for the solve-phase this method returns a
wneuper@2838
   139
     * value from the calculation.
wneuper@2838
   140
     * 
wneuper@2837
   141
     * @return CalcHead with the Problem inserted; the new Problem may cause
wneuper@2837
   142
     *         error-status for some ModelItems already input (because they do
wneuper@2837
   143
     *         not match the Problem selected)
wneuper@2837
   144
     * @exception RemoteException
wneuper@2837
   145
     */
wneuper@2837
   146
    public CalcHead setProblem(ProblemID id) throws RemoteException;
wneuper@2837
   147
wneuper@2837
   148
    /**
wneuper@2837
   149
     * Transfer the Method selected in the MethodBrowser to the SML-kernel. This
wneuper@2837
   150
     * method is used for transferring the Method to the Worksheet (i.e. the
wneuper@2837
   151
     * CalcHead with the Method inserted and checked has to be fetched from the
wneuper@2837
   152
     * SML-kernel by the front-end)
wneuper@2837
   153
     * 
wneuper@2838
   154
     * in contrary to the methods for the solve-phase this method returns a
wneuper@2838
   155
     * value from the calculation.
wneuper@2838
   156
     * 
wneuper@2837
   157
     * @return CalcHead with the Method inserted; the new Method may cause
wneuper@2837
   158
     *         error-status for some ModelItems in the guard (because they do
wneuper@2837
   159
     *         not match the Method selected)
wneuper@2837
   160
     * @exception RemoteException
wneuper@2837
   161
     */
wneuper@2837
   162
    public CalcHead setMethod(MethodID id) throws RemoteException;
wneuper@2837
   163
wneuper@2837
   164
    /**
wneuper@2837
   165
     * Complete a given CalcHead: Tell the Kernel to fill out all the missing
wneuper@2837
   166
     * fields in the Model _and_ in the Specification; this may not succeed if
wneuper@2837
   167
     * the (manual) input is too messed up (in this case first a resetCalcHead
wneuper@2837
   168
     * must be done).
wneuper@2837
   169
     * 
wneuper@2838
   170
     * in contrary to the methods for the solve-phase this method returns a
wneuper@2838
   171
     * value from the calculation.
wneuper@2838
   172
     * 
wneuper@2830
   173
     * @return the completed CalHead
wneuper@2750
   174
     */
wneuper@2830
   175
    public CalcHead completeCalcHead() throws RemoteException;
wneuper@2750
   176
wneuper@2750
   177
    /**
wneuper@2837
   178
     * Reset the CalcHead to the state as it was after startCalculation. This
wneuper@2837
   179
     * may help to escape from a CalcHead with messed input, which may not allow
wneuper@2837
   180
     * for a successful completeCalcHead.
wneuper@2831
   181
     * 
wneuper@2838
   182
     * in contrary to the methods for the solve-phase this method returns a
wneuper@2838
   183
     * value from the calculation.
wneuper@2838
   184
     * 
wneuper@2831
   185
     * @return an empty CalcHead
wneuper@2831
   186
     * @exception RemoteException
wneuper@2831
   187
     */
wneuper@2831
   188
    public CalcHead resetCalcHead() throws RemoteException;
wneuper@2831
   189
wneuper@2831
   190
    /**
wneuper@2750
   191
     * Complete a given calc_head_: Tell the Kernel to fill out a missing field
wneuper@2750
   192
     * in the calc_head_, which is specified by an parameter
wneuper@2750
   193
     * 
wneuper@2838
   194
     * in contrary to the methods for the solve-phase this method returns a
wneuper@2838
   195
     * value from the calculation.
wneuper@2838
   196
     * 
wneuper@2750
   197
     * @param calc_head_
wneuper@2750
   198
     *            the calc_head_ to be completed
wneuper@2750
   199
     * @param completeItem
wneuper@2750
   200
     *            the item which should be added TODO: return int like
wneuper@2830
   201
     *            replaceFormula etc. WN040916 don't confuse with
wneuper@2830
   202
     *            autCalculate(...CompleteCalcHead) WN0504 this case is notyet
wneuper@2830
   203
     *            designed: how indicate the field ???
wneuper@2830
   204
     * @return the completed CalHead
wneuper@2750
   205
     */
wneuper@2830
   206
    public CalcHead completeCalcHead(CalcHead calcHead, int completeItem)
wneuper@2750
   207
            throws RemoteException;
wneuper@2750
   208
wneuper@2750
   209
    /**
wneuper@2750
   210
     * Tries to replaces the active formula in the calculation tree by the
wneuper@2750
   211
     * passed formula. This could fail if no valid derivation from the preceding
wneuper@2750
   212
     * formula to the (new) active formula can be found.
wneuper@2750
   213
     * <p>
wneuper@2750
   214
     * Parts of the calculation after the replaced formula are likely to become
wneuper@2750
   215
     * invalid, listeners will be informed of this with the update message,
wneuper@2750
   216
     * which contains the last unchanged formula.
wneuper@2750
   217
     * 
wneuper@2750
   218
     * @param newFormula
wneuper@2750
   219
     * @return The method will return 0 on success or a nonzero value indicating
wneuper@2750
   220
     *         the status otherwise.
wneuper@2750
   221
     */
wneuper@2750
   222
    public int replaceFormula(CalcFormula newFormula) throws RemoteException;
wneuper@2750
   223
wneuper@2750
   224
    /**
wneuper@2750
   225
     * Tries to append the passed formula after the active formula. This could
wneuper@2750
   226
     * fail if no valid derivation from the preceding formula to the (new)
wneuper@2750
   227
     * active formula can be found. The method will fail as well if the active
wneuper@2750
   228
     * formula is not the last formula in the (sub)calculation. Parts of the
wneuper@2750
   229
     * calculation might become invalid.
wneuper@2750
   230
     * 
wneuper@2750
   231
     * @param newFormula
wneuper@2750
   232
     * @return The method will return 0 on success or a nonzero value indicating
wneuper@2750
   233
     *         the status otherwise.
wneuper@2750
   234
     */
wneuper@2750
   235
    public int appendFormula(CalcFormula newFormula) throws RemoteException;
wneuper@2750
   236
wneuper@2750
   237
    /**
wneuper@2750
   238
     * requests the intermediate steps leading to the Formula at the Iterator
wneuper@2750
   239
     * (i.e. these steps might be calculated by the math-engine)
wneuper@2750
   240
     * 
wneuper@2750
   241
     * @param Iterator
wneuper@2750
   242
     * 
wneuper@3881
   243
     * @return transactionID also returned in the CalcChanged
wneuper@2750
   244
     */
wneuper@2750
   245
    public int intermediateSteps(ICalcIterator ic) throws RemoteException;
wneuper@2750
   246
wneuper@2750
   247
    /**
wneuper@2750
   248
     * Set the tactic to be used in the next step of calculation.
wneuper@2750
   249
     * 
wneuper@2750
   250
     * @param tactic
wneuper@2750
   251
     *            the Tactic to be used in the the next step
wneuper@2750
   252
     * @return The return value indicates success, failure or probable success
wneuper@2750
   253
     *         at a later time.
wneuper@2750
   254
     */
wneuper@2750
   255
    public int setNextTactic(Tactic tactic) throws RemoteException;
wneuper@2750
   256
wneuper@2750
   257
    /**
wneuper@2750
   258
     * Retrieve the tactic proposed by the SML-Kernel for the next step in the
wneuper@2750
   259
     * calculation.
wneuper@2750
   260
     * 
wneuper@2750
   261
     * @return proposed tactic. Can be null, if the kernel does not know what to
wneuper@2750
   262
     *         do next, or if the end of the calculation is reached
wneuper@2750
   263
     */
wneuper@2750
   264
    public Tactic fetchProposedTactic() throws RemoteException;
wneuper@2750
   265
wneuper@2750
   266
    /**
wneuper@2750
   267
     * Fetch all tactics applicable to the current situation known to the
wneuper@2750
   268
     * system.
wneuper@2750
   269
     * 
wneuper@2750
   270
     * @see #fetchApplicableTactics(int)
wneuper@2750
   271
     */
wneuper@2750
   272
    public static final int TACTICS_ALL = 1;
wneuper@2750
   273
wneuper@2750
   274
    /**
wneuper@2750
   275
     * Fetch all tactics applicable to the current situation, but restrict the
wneuper@2750
   276
     * result to tactics from the current theory.
wneuper@2750
   277
     * 
wneuper@2750
   278
     * @see #fetchApplicableTactics(int)
wneuper@2750
   279
     */
wneuper@2750
   280
    public static final int TACTICS_CURRENT_THEORY = 2;
wneuper@2750
   281
wneuper@2750
   282
    /**
wneuper@2750
   283
     * Fetch all tactics applicable to the current situation, but restrict the
wneuper@2750
   284
     * result to tactics from the method being applied.
wneuper@2750
   285
     * 
wneuper@2750
   286
     * @see #fetchApplicableTactics(int)
wneuper@2750
   287
     */
wneuper@2750
   288
    public static final int TACTICS_CURRENT_METHOD = 3;
wneuper@2750
   289
wneuper@2750
   290
    //	/**
wneuper@2750
   291
    //	 * Get a list of tactics applicable to the active formula.
wneuper@2750
   292
    //	 *
wneuper@2750
   293
    //	 * @param scope
wneuper@2750
   294
    //	 * The filter parameter selects the scope of search for
wneuper@2750
   295
    //	 * applicable tactics.
wneuper@2750
   296
    //	 * @return Array with applicable tactics
wneuper@2750
   297
    //	 * @see #TACTICS_ALL
wneuper@2750
   298
    //	 * @see #TACTICS_CURRENT_THEORY
wneuper@2750
   299
    //	 * @see #TACTICS_CURRENT_METHOD
wneuper@2750
   300
    //	 */
wneuper@2750
   301
    //	public Tactic[] fetchApplicableTactics(int scope) throws RemoteException;
wneuper@2750
   302
wneuper@2750
   303
    /**
wneuper@2750
   304
     * Do the number of steps requested, without any restrictions. autoCalculate
wneuper@2750
   305
     * ... CompleteCalc Do NOT change the value of this constant, as this number
wneuper@2750
   306
     * has a specifig meaning in other parts of the system!
wneuper@2750
   307
     * 
wneuper@2750
   308
     * @see #autoCalculate(int, int)
wneuper@2750
   309
     */
wneuper@2750
   310
    public static final int SCOPE_CALCULATION = 7;
wneuper@2750
   311
wneuper@2750
   312
    /**
wneuper@2750
   313
     * Do the number of steps requested, without any restrictions. autoCalculate
wneuper@2830
   314
     * ... CompleteModel Do NOT change the value of this constant, as this
wneuper@2830
   315
     * number has a specifig meaning in other parts of the system!
wneuper@2750
   316
     * 
wneuper@2750
   317
     * @see #autoCalculate(int, int)
wneuper@2750
   318
     */
wneuper@2750
   319
    public static final int SCOPE_MODEL = 6;
wneuper@2750
   320
wneuper@2750
   321
    /**
wneuper@2750
   322
     * Do the number of steps requested, but do not leave the current
wneuper@2750
   323
     * subcalculation into a subproblem: CompleteToSubpbl Do NOT change the
wneuper@2750
   324
     * value of this constant, as this number has a specifig meaning in other
wneuper@2750
   325
     * parts of the system!
wneuper@2750
   326
     * 
wneuper@2750
   327
     * @see #autoCalculate(int, int)
wneuper@2750
   328
     */
wneuper@2750
   329
    public static final int SCOPE_SUBCALCULATION = 5;
wneuper@2750
   330
wneuper@2750
   331
    /**
wneuper@2750
   332
     * Do the number of steps requested, but do not leave the current
wneuper@2750
   333
     * subproblem: autoCalculate ... CompleteSubpbl Do NOT change the value of
wneuper@2750
   334
     * this constant, as this number has a specifig meaning in other parts of
wneuper@2750
   335
     * the system!
wneuper@2750
   336
     * 
wneuper@2750
   337
     * @see #autoCalculate(int, int)
wneuper@2750
   338
     */
wneuper@2750
   339
    public static final int SCOPE_SUBPROBLEM = 4;
wneuper@2750
   340
wneuper@2750
   341
    /**
wneuper@2750
   342
     * Calculate the next n steps starting from the active formula or until the
wneuper@2750
   343
     * specified scope is left, whichever comes first.
wneuper@2750
   344
     * 
wneuper@2750
   345
     * @param scope
wneuper@2750
   346
     *            The scope parameter can have following values:
wneuper@2750
   347
     * @param nSteps
wneuper@2750
   348
     *            Specifies the count of steps to be autocalculated. Passing 0
wneuper@2750
   349
     *            for nSteps will calculate until reaching a final result.
wneuper@2750
   350
     * @return The method returns an unique id to identify the request when
wneuper@2750
   351
     *         notifying about updates in the tree.
wneuper@2750
   352
     * @see #SCOPE_CALCULATION
wneuper@2750
   353
     * @see #SCOPE_SUBCALCULATION
wneuper@2750
   354
     * @see #SCOPE_SUBPROBLEM
wneuper@2750
   355
     */
wneuper@2750
   356
    /*
wneuper@2750
   357
     * WN040624: the above design is desirable, but currently not impl. in the
wneuper@2750
   358
     * math-engine, rather: either steps == 0, then regard SCOPE_* or steps !=
wneuper@2750
   359
     * 0, then SCOPE_* irrelevant !
wneuper@2750
   360
     */
wneuper@2750
   361
    public int autoCalculate(int scope, int nSteps) throws RemoteException;
wneuper@2750
   362
wneuper@2750
   363
}