# Anomaly Detection for Hydraulic Power Units--A Case Study
## 2 Materials and Methods
### Algorithms Deployment
#### 2.3.4 Summary of Algorithms Workflow in Production Environment  
To summarize Sections 2.3.1 and 2.3.2, step by step, the deployed algorithm runs as follows:  
1. Download required variables time series (power, pressure, fuel consumption, rotation speed) from cloud storage using API from the last hour.
2. Determine stable periods.
3. Calculate mean for each variable for each stable period.
4. Handle anomaly detection: 1. Calculate point-to-curve distance (PTCD); 2. Confront PTCD with IQR Criterion.
5. Handle novelty detection: 1. Download model from BLOB storage; 2. Use model to predict novelty.
6. Send feedback to IoTHub on whether an anomaly or novelty was detected or not. MOLOS.CLOUD will raise an alarm if necessary.  
It is worth mentioning the costs of deployed workflow and ecosystem for analytical solutions. Several components that generate cost could be named:  
* Function App as a consumption plan [61]: 1. Costs are generated per Azure Function run;In described solution it is \(2\)\(functions*24\frac{executions}{daysfunction}*30\frac{day}{month}=1440\frac{executions}{month}\).
* Storage: 1. Costs are generated by read operations--both volume and quantity of reads; 2. Read operations from table storage with time series data for desired variables; 3. Read operations BLOB storage with models for anomaly detection; 4. Read operations BLOB storage with models for novelty detection.
* API: 1. Fee is charged for working hour.  
The approximate cost of Azure cloud resources for data analysis in the described project is about EUR 10 per month. The costs were calculated based on invoices received from Microsoft. Unfortunately, the costs of specific components pointed out in the list in Section 2.3.4 were restricted and could not be provided in the article. In the context of project cloud costs, it is also possible to use the Azure Pricing Calculator; however, it gives only a rough estimate of costs. An accurate cost calculation using only the Azure Pricing Calculator is hard because making assumptions about data of inbound and outbound traffic in the cloud is hard to be carried out accurately and often requires the usage of special traffic monitoring tools [62]. Moreover, the proper interpretation of calculations made using the Azure Pricing Calculator is often hard [63]. Therefore, a common experience is that accurate costs of cloud resources are known only after deploying the solution.  
It is important to notice that the solution is not real-time monitoring. Hypotheses are developed once an hour. Assumptions made during the synthesis of Azure Architecture have not involved real-time workflow. Therefore, the used cloud tools are not suited for such a workflow. For a fast and responsive tool for monitoring in Azure, see Azure Stream Analytics [64]. Moreover, to estimate the cost of the whole delivered Azure solution (visualization + analytics) to the above costs, a couple of other components should be added. Nevertheless, it is beyond the scope of this article because the description of visualization details in both a frontend and backend manner is not the purpose of the article.  
A concise summary of workflow and tools used while putting algorithms into production is shown in Figure 7.