## 2 Materials and Methods  
### Functional Design and Components of the Cloud-Based CPPS Architecture  
Several initiatives during the past years addressed manufacturing optimization, but most of them aimed to run the software locally and very tightly aligned with specific factory ecosystems. Optimizing production capacity, quality control, or energy consumption by themselves without considering interoperability between the several stakeholders misses the full purpose of Industry 4.0. The architecture put forth by our work amplifies the principles of vertical and horizontal integration while also elevating the concept of end-to-end product integration and engineering:  
Vertical integration: to integrate and interoperate all software tools and hardware inside a factory;  
Horizontal integration: with the capacity to enable the interoperation of all the actors that contribute to the value chain, not only the suppliers, transporters, and factories but also the product itself;  
End-to-end product integration and engineering: with the capacity to know or track the product and sub-product information along the life cycle. Figure 5: Comparison between conventional, web-based, and cloud-based robots (adapted from [13]). The integration of all available information at these different levels allows the cloud-based cyber-physical ecosystem to coordinate activities, optimize the system as a whole, and generate more knowledge that previously was not available. Using energy consumption as an example, several works such as openMOS [24] and PERFoRM [25] presented solutions to have some feedback of consumption on machines, transporters, or products but they did not present a globally optimal solution (only local solutions to each component). Complex system optimization, with several actors, requires distributed tools and a full view of the entire value chain. With the cloud-based tools now available and in conjunction with new architectures such as the ones previously presented, it is possible to create an advanced ICT solution for monitoring and optimizing complex environments at different levels and granularities. Using an ecosystem like the one presented in Figure 6, it is not yet straightforward how to optimize it. This ecosystem can be easily divided into two big levels: the cloud and the factory levels. At a factory level, nowadays, information is already collected by the production processes, and data are generated and gathered by the integrated sensors at the different line modules, or data are manually input by the plant workers into their internal systems. These data can be extracted and made available for all software tools inside the factory or at the cloud level (if some service is used subscribing for data updates for instance). With these up-to-date data, different tools can share information and knowledge about the processes and work together smoothly. This allows optimization at different levels and with different purposes and targets (optimization of the production process, quality control, energy consumption, etc.). If we divide and separate correctly what should be running locally and remotely, it will bring flexibility and adaptability for different users. Some tools require real-time control, and those time-critical activities must be deployed inside the factory; in other cases, it is more profitable to run the tools at a cloud level, where resources are virtually infinite. When we look closely, the factory and its energy problems are only one of the nodes in a very complex and interconnected system. Perhaps the locally optimal solution is not the global optimal solution. That is why there is a need to consider cloud-based computing power when dealing with all the constraints along the value chain. The value chain is constituted of a complex flow of tasks and actions performed by several actors (suppliers, logistics, factories, or customers).