Debugging Calculation Algorithm

Debugging calculation algorithm is used to detect and correct errors and also enables the user to view intermediate values obtained during calculation. Viewing intermediate values is specially relevant if calculation uses intermediate cubes without data tables, that is, the cubes that cannot be used to view obtained values after algorithm calculation is finished.

To debug calculation algorithm:

  1. Open a calculation algorithm in the calculation mode:

  1. Click the Calculation Execution Settings button on the toolbar to show the Execute Calculation side panel:

Set calculation execution parameters:

To correct the specified formula, click the Stop button, after which algorithm calculation will be stopped. Manually edit the formula and recalculate the algorithm.

To skip the error, select one of the skip options and click the OK button. The calculated elements will be skipped and the calculation result is the empty value.

If the checkbox is deselected, arithmetic operations in formulas are not checked. If there is a division by zero, then calculated elements are skipped and the calculation result is the empty value.

NOTE. It is possible to not check arithmetic operations if calculation formula is correct and the calculation result may contain empty values.

NOTE. If after the calculation is complete, one should save data, select the Save Data item in the drop-down menu of the Continue Debugging button on the toolbar.

NOTE. Checkbox state is active only during algorithm calculation debugging.

NOTE. The checkbox is available if a calculation algorithm contains calculation blocks and control blocks, for which calculation formulas are set.

If the Pointwise Calculation checkbox is selected for specific calculation formulas, calculation can be executed using several methods.

IMPORTANT. The parameter use decreases performance and algorithm calculation takes more time.

If a calculation algorithm contains aggregation blocks, it is not possible to calculate aggregation for one calendar point when algorithm pointwise calculation is used. Select aggregation block calculation method using the radio buttons:

NOTE. The order of aggregation blocks calculation in the calculation tree is taken into account only if pointwise calculation of specific calculation formulas is used. When algorithm pointwise calculation is used, the order of aggregation blocks calculation depends on the selected calculation method.

  1. To debug algorithm calculation, select one of the items in the drop-down menu of the Calculate button on the toolbar:

After calculation is started, data is loaded to algorithm.

  1. If required, set up cyclic calculation of algorithm object in the <object name> - cycle settings dialog box.

NOTE. Cyclic calculation setup is available only for objects contained in a branching.

Open the dialog box

Set the parameters:

NOTE. The parameter is available only to set up cyclic calculation of function block.

To stop cyclic calculation of function block by means of a custom function, use the ITsUserData.Data property that is set to True. Set the BREAK_CYCLE key as a property parameter. To get the current calculation iteration, use the ITsUserData.Data property with the CURRENT_ITERATION parameter. To get a time interval that is set in the Time Interval between Iterations (sec.) parameter, use the ITsUserData.Data property with the ITERATION_INTERVAL parameter.

If the switch is toggled to the active state, and the number of iterations is set in the Number of Iterations parameter, cyclic calculation will be stopped using the BREAK_CYCLE key depending on the value of the ITsUserData.Data property. Cyclic calculation stop by means of a custom function has the highest priority.

The example of a function, in which cyclic calculation is stopped at the fifth iteration:

Public Function CalcFunction(Paramarray arr : array Of Variant) : Variant;
Var 
    Context: ITsCalculationContext;
    UserData: ITsUserData;
    CurrentIteration: Integer;
Begin
    
// Get user data
    Context := TsCalculation.Current;
    UserData := Context.UserData;
    
// Get current iteration of cyclic calculation
    CurrentIteration := UserData.Data("CURRENT_ITERATION")
    
If CurrentIteration = 5 Then
        
// If the current iteration is equal to 5, then stop cyclic calculation at this iteration
        UserData.Data("BREAK_CYCLE") := True;
    
End If;
Return Null;
End Function CalcFunction;

NOTE. The parameter is available if the Limit Number of Iterations switch is toggled to the active state.

NOTE. The parameter is available if more than one iteration is set in the Number of Iterations parameter, or the Limit Number of Iterations switch is toggled to the inactive state.

After executing the operations click the OK button. The calculation tree displays cyclic calculation progress to the right of the object according to the specified cycle parameters, for example:

To pause object cyclic calculation, click the Pause button on the toolbar. The following operations can be executed when object cyclic calculation is paused:

To stop object cyclic calculation, click the Stop Cycle button on the toolbar.

  1. Calculate the next block using the Continue Debugging button or select a specific block in the drop-down menu of the Continue Debugging button. The menu contains all the blocks that have not been yet executed.

The calculated block turns green in the working area. For example, left - the block before calculation, right - the block after calculation:

  1. If required, stop calculation using the Stop button.

All calculation algorithm objects can be read during debugging. For example, one can view calculation block settings or block calculation results in the data consumer.

After the calculation is completed, the message containing algorithm calculation results is displayed. If an error occurred on calculation, the corresponding error message is displayed.

TIP. To speed up algorithm calculation, see the How to Speed Up Algorithm Calculation? section.

Message with Algorithm Calculation Results

After the algorithm calculation or calculation of specific blocks is completed, the message with algorithm calculation result is displayed:

Copy calculation result to clipboard

View calculation result details

See also:

Building Calculation Algorithm