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:
Open a calculation algorithm in the calculation mode:
Click the Calculation Execution Settings button on the toolbar to show the Execute Calculation side panel:
Set calculation execution parameters:
Check Arithmetic Operations. Select the checkbox to check arithmetic operations used in formulas during algorithm calculation. If, during algorithm calculation, there is division by zero in the formula, the corresponding message is displayed specifying calculation formula and block.
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.
Do not Save Result to Database. Select the checkbox to calculate algorithm without saving results.
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.
Multithreaded Calculation. Select the checkbox to speed up calculation of calculation blocks and control blocks if the Multithreaded Calculation checkbox is selected in the calculation block or control block editing wizard. Aggregation blocks are calculated only using single-threaded calculation. For details about multithreaded calculation see the How to Execute Multithreaded Calculation? section. The checkbox is deselected by default, and single-threaded algorithm calculation is executed.
NOTE. Checkbox state is active only during algorithm calculation debugging.
Pointwise Calculation. Select the checkbox to change formula calculation methods in all calculation blocks and control blocks contained in a calculation algorithm. If pointwise calculation is enabled, formulas are calculated one-by-one in each data point: first, formulas are calculated by the first data point, then by the second one, and so on. This calculation method can be used if current calendar point data depends on the data calculated by the previous calendar point. If the checkbox is deselected, series calculation is used, that is, formulas are calculated by all data points.
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:
Do not Calculate Aggregation. Aggregation blocks will not be calculated
Calculate before Pointwise Calculation. Aggregation blocks will be calculated before pointwise calculation of calculation blocks and control blocks
Calculate after Pointwise Calculation. Default value. Aggregation blocks will be calculated after pointwise calculation of calculation blocks and control blocks.
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.
To debug algorithm calculation, select one of the items in the drop-down menu of the Calculate button on the toolbar:
Start in debugging mode. The entire calculation algorithm is debugged.
Start selected in debugging mode. Specific calculation algorithm blocks are debugged. Before executing the command select the blocks on the working area or in the calculation tree using the SHIFT or CTRL keys.
After calculation is started, data is loaded to algorithm.
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.
Set the parameters:
Limit Number of Iterations. If required, toggle the switch to inactive state to stop cyclic calculation of function block by means of a custom function or manually. By default, the switch is toggled to active state, and cyclic calculation will be executed by the specified number of iterations.
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 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;
Number of Iterations. Specify the number of iterations of object cyclic calculation.
NOTE. The parameter is available if the Limit Number of Iterations switch is toggled to active state.
Time Interval between Iterations (sec.). Specify time interval between cyclic calculations of object in seconds.
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 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:
View calculation formulas specified for calculation blocks and control blocks.
Open repository objects located on the working area.
View calculated data.
To stop object cyclic calculation, click the Stop Cycle button on the toolbar.
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:
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.
After the algorithm calculation or calculation of specific blocks is completed, the message with algorithm calculation result is displayed:
See also: