The invention relates to a method and apparatus for providing an adaptive self-learning control program for deployment on a target field device, in particular on an industrial controller.
Industrial controllers such as PLCs used in an industrial automation system need to be able to perceive their environment or reason about their performance and optimize their control parameters. To predict a potential consequence of a control intervention by the controller a model can be used which is able to predict the effect of a control and/or to calculate necessary control steps based on an expected target value. These models are typically configured by means of parameters which need to be adjusted to real system properties. In conventional systems setting up these relationships is cumbersome and labour-intensive. For instance, the exact effect of a motor control needs to be exactly adjusted where the control can exactly control the angle of a stepper motor of a robot. However, the change of the end effectors depends on the kinematics of the robot which are also influenced by physical properties of the joints of the respective robot. Due to manufacturing tolerances, these physical properties can vary between different robots. Besides manufacturing tolerances, also a wear-out of other components can lead to a de-calibration of the technical system. For example, the position of a robot joint of the robot can drift over time due to a slack in the robot joints. Calibration and re-calibration is often performed in a manual process where a human operator is adjusting the function parameters.
Accordingly, it is an object of the present invention to provide a method and apparatus for providing an adaptive self-learning control program for deployment of a target field device where the setup can be performed faster and provides an even more accurate control.
This object is achieved according to a first aspect of the present invention by a method for deploying and executing self-optimizing functions on a target field device comprising the features of claim 1.
The invention provides according to the first aspect a method for deploying and executing self-optimizing functions on a target field device such as a controller, wherein the method comprises the steps of:
providing a set of functions having at least one tuneable parameter,
deriving automatically from the provided set of functions an additional set of functions used to optimize the tuneable parameters of the original set of functions,
converting both sets of functions into a machine executable code specific to the respective target field device and
deploying and executing the converted machine executable code on said target field device.
In a possible embodiment of the method according to the first aspect of the present invention, the provided set of functions forms a system model adapted to learn characteristics of a technical system.
In a still further possible embodiment of the method according to the first aspect of the present invention, the system model is a machine learning model which comprises a neural network.
In a possible embodiment, the machine learning model comprises a deep learning neural network.
In a still further possible embodiment, the system model comprises a decision tree.
In a further possible embodiment, the system model comprises a logistic regression model.
In a still further possible embodiment, the system model comprises an equation system.
In a further possible embodiment of the method according to the first aspect of the present invention, the additional set of functions comprises partial gradients with respect to the tuneable parameters of the provided original set of functions derived automatically from said original set of functions.
In a further possible embodiment of the method according to the first aspect of the present invention, the additional set of functions represent stochastic gradient descents, mini-batch gradient descents and/or full gradient descents.
In a still further possible embodiment of the method according to the first aspect of the present invention, on the basis of the system model formed by the provided input set of functions a computation graph is automatically generated by a graph generation software component.
In a still further possible embodiment of the method according to the first aspect of the present invention, the generated computation graph comprises
a forward computation subgraph representing the original set of functions and
a backward computation subgraph representing the derived additional set of functions used to train the tuneable parameters of the original set of functions.
In a further possible embodiment of the method according to the first aspect of the present invention, the generated computation graph describes operations of the functions in a sequential order to be performed by the target field device.
In a still further possible embodiment of the method according to the first aspect of the present invention, the generated computation graph is exported to a model transformation module which converts automatically the received computation graph into a binary machine executable code specific for said target field device and the binary machine executable code is deployed automatically on said target field device.
In a still further possible embodiment of the method according to the first aspect of the present invention, the generated computation graph received by the model transformation module is parsed to provide an intermediate code in a low level programming language which is compiled to generate the binary machine executable code specific to said target field device which is deployed on said target field device.
In a still further possible embodiment of the method according to the first aspect of the present invention, the forward computation subgraph forming part of the generated computation graph is parsed to provide a first intermediate code compiled to generate a first binary machine executable software component forming a model execution software component deployed on said target field device and
wherein the backward computation subgraph forming part of the generated computation graph is parsed to provide a second intermediate code compiled to generate a second binary machine executable software component forming an online model training software component deployed on said target field device.
In a still further possible embodiment of the method according to the first aspect of the present invention, the model execution software component deployed on said target field device is executed in a real time context.
In a further possible embodiment of the method according to the first aspect of the present invention, the deployed online model training software component deployed on said target field device is executed either in a non-real time context or in a real time context.
In a still further possible embodiment of the method according to the first aspect of the present invention, the deployed online model training software component updates iteratively the deployed model execution software component on the basis of a data stream received from the technical system using partial gradients to optimize the parameters of the provided set of functions.
In a still further possible embodiment of the method according to the first aspect of the present invention, the deployed model execution software component applies computations prescribed by its binary machine executable code to an input data stream received from the technical system for calculating estimated target values.
In a still further possible embodiment of the method according to the first aspect of the present invention, the input data stream comprises a sensor data stream received from sensors of the technical system.
In a still further possible embodiment of the method according to the first aspect of the present invention, the machine executable code is deployed and executed on a target field device formed by a controller, in particular a PLC controller or a CNC controller.
In a still further possible embodiment of the method according to the first aspect of the present invention, the tuneable parameters of the provided set of functions are optimized iteratively with a learning rate.
In a further possible embodiment of the method according to the first aspect of the present invention, the tuneable parameters of the provided set of functions are optimized iteratively by weighting partial gradients of the parameters with the learning rate and then adding the result to the respective parameters.
In a further possible embodiment of the method according to the first aspect of the present invention, the converted machine executable code is deployed in a memory of the target field device and executed by a processor of the target field device.
In a still further possible embodiment of the method according to the first aspect of the present invention, an error between observed target values and estimated target values calculated by the model execution software component deployed on said target field device is measured by comparing the observed target values and the estimated target values by means of a predetermined loss function.
The invention further provides according to a second aspect a deployment system for deployment of an adaptive self-learning program on a target field device comprising the features of claim 20.
The invention provides according to the second aspect a deployment system for deployment of an adaptive self-learning control program on a target field device, in particular on a controller, wherein said system comprises:
an input user interface to input a set of functions having at least one tuneable parameter forming a system model representing characteristics of a technical system,
a processing unit configured to extend the system model by deriving automatically from the input set of functions an additional set of functions used to optimize the tuneable parameters of the model and to convert both sets of functions into a machine executable code specific to the respective target field device and
an output interface used to deploy the machine executable code in a memory of said target field device for execution by a processor of the target field device.
In the following, possible embodiments of the different aspects of the present invention are described in more detail with reference to the enclosed figures.
The method for deploying and executing self-optimizing functions on a target field device according to an aspect of the present invention can comprise in a possible exemplary embodiment several main steps as illustrated in
In the illustrated exemplary embodiment, in a first step S1, a set of functions f having at least one tuneable parameter θ is provided. The provided set of functions f can form a system model adapted to learn characteristics of a technical system such as the conveyor belt system with an observation camera as illustrated in
In a further step S2, an additional set of functions is automatically derived from the provided original set of functions wherein the additional set of functions is used to optimize the tuneable parameters θ of the original set of functions f forming the system model.
In a further step S3, both sets of functions, i.e. the original set of functions f and the additional derived set of functions are converted automatically into a machine executable code specific to the respective target field device TFD. The target field device TFD can be for instance a controller adapted to control a process within an automation system.
In a further step S4, the converted machine executable code is deployed on said target field device and then executed. In a possible embodiment, the converted machine executable code is deployed in a local memory of the target field device TFD and then executed by a processor of the respective target field device TFD.
The system model represented by the set of functions f can comprise in a possible embodiment a machine learning model which comprises a neural network. In a possible embodiment, the neural network is a deep learning neural network. In a possible embodiment, the neural network is a convolutional neural network CNN or a recurrent neural network RNN. In a still further possible embodiment, the system model can comprise a decision tree. In a further alternative embodiment, the system model represented by the set of functions can comprise a logistic regression model. In a still further possible embodiment, the system model of the technical system can comprise an equation system, in particular a linear equation system. The set of functions forming the system model comprises at least one tuneable parameter and can be input in a possible embodiment by means of an input interface.
The additional set of functions derived from the original set of functions can comprise in a possible embodiment partial gradients with respect to the tuneable parameters θ of the original set of functions wherein the partial gradients are derived automatically from the original set of functions. The additional set of functions represents the gradient, which in turn is utilized in stochastic gradient descents, mini-batch gradient descents or full gradient descents algorithms.
In a possible embodiment of the method according to the first aspect of the present invention as illustrated in the flowchart of
In a possible embodiment, the generated computation graph CG comprises a forward computation subgraph FCG and a backward computation subgraph BCG. The forward computation subgraph FCG represents the original set of functions f. The backward computation subgraph BCG represents the derived additional set of functions used to train the tuneable parameters θ of the original set of functions. The generated computation graph CG can describe operations of the functions in a sequential order to be performed by the target field device TFD or controller. The generation of the computation graph CG comprising the forward computation subgraph FCG and the backward computation subgraph BCG is performed in step S3 of the method illustrated in
In a possible embodiment, the generated computation graph CG received by the model transformation module MTM is parsed to provide an intermediate code in a low-level programming language such as C or Assembler. The intermediate code is then compiled to generate the binary machine executable code BMEC specific to the target field device TFD and deployed on the target field device TFD. In a possible embodiment, the forward computation subgraph FCG forming part of the generated computation graph CG is parsed to provide a first intermediate code which is then compiled to generate a first binary machine executable software component forming a model execution software component MESC, deployed in a memory of said target field device TFD. Further, the backward computation subgraph BCG forming also part of the generated computation graph CG is also parsed to provide a second intermediate code which is then compiled to generate a second binary machine executable software component forming an online model training software component OMTSC deployed on said target field device TFD in step S4. The model execution software component MESC deployed on the target field device TFD in step S4 is executed in a real-time context. On the other hand, the deployed online model training software component OMTSC deployed on the target field device TFD can be either executed in a non-real time context or in a real-time context. As also illustrated in
The model transformation module MTM converts the computation graph CG from a high-level description format to a format suitable to be executed in a target field device TFD. The deployed model execution software component applies the computations prescribed by the learned model to a live stream of data which can come for example from smart sensors or from other sources internal to the controller or real-time device. The deployed online model training software component OMTSC can use stochastic gradient descents. The online model training software component OMTSC takes the model and gradient and can iteratively update the weights of the model.
In a possible embodiment, both software components, i.e. the online model training software component OMTSC and the model execution software component MESC are deployed directly in a real-time system context of the respective system. In an alternative embodiment, the online model training software component OMTSC is deployed in a real-time context of the target field device, whereas the model execution software component MESC is separately deployed, i.e. in a non-real-time context of the same device, or on a separate device connected by a data interface. The online model training software component OMTSC can periodically update coefficients and possibly also a topology of the computation graph CG that are used by the execution component, i.e. the model execution software component MESC which runs in the real-time context.
The trained analytical model can be deployed on any kind of industrial target field devices TFD, in particular to any kind of controller used in an industrial system. In a possible embodiment, the high-level serialized representation of the computation graph CG and associated parameters are converted into a set of source code files which can be compiled into a device-specific program and deployed into a memory of the target field device TFD. With the present invention, training and learning of the model using the online model training software component OMTSC is tightly coupled with the execution of the deployed model execution software component MESC.
In a first variant of the method according to the first aspect of the present invention, the online model training software component OMTSC is separately deployed from the model execution software component MESC, e.g. the deployed online model training software component OMTSC is deployed in this first variant in a non-real time context. In this embodiment, online learning takes place on the device logically but in a non-real time context. Physically, the nonreal time context can be a separate physical device connected via a data interface. This variant provides a closed loop continuous feedback mechanism to perform model updates in a non-real time context and feeds the results back to the real-time context of the target field device TFD, e.g. by updating model parameters in a memory of the target field device. In another variant, both deployed software components, i.e. the deployed online model training software component OMTSC as well as the deployed model execution software component MESC are executed in a real-time context. In this second variant, model execution takes place on the target field device TFD but also the online learning takes place on the device logically in the same real-time context. The target field device TFD can be formed by a controller, e.g. by a SIMATIC S7 controller or another PLC controller. In a possible embodiment, the tuneable parameters of the provided set of functions f can be optimized iteratively with a learning rate η. The tuneable parameters of the provided set of functions can be optimized iteratively by weighting partial gradients of the parameters θ with the learning rate η and then adding the result to the respective parameters.
In a possible embodiment, an error e between observed target values y and estimated target values ŷ calculated by the model execution software component MESC deployed in a memory of the target field device TFD is measured by comparing the observed target values y and the estimated target values ŷ by means of a predetermined loss function.
In a possible embodiment, the computation graph CG received by the model transformation module MTM is parsed to provide an intermediate code in a low-level programming language which is then processed to generate the binary machine executable code BMEC specific to the target field device TFD. As illustrated in
The processing unit 3 of the deployment system 1 is configured to derive automatically from the input set of functions f an additional set of functions used to optimize the tuneable parameters θ of the model and to convert both sets of functions into a machine executable code specific to the respective target field device TFD. This machine executable code is in a preferred embodiment a binary machine executable code BMEC specific to the target field device TFD. The binary machine executable code BMEC comprises two software components, i.e. the model execution software component MESC and the online model training software component OMTSC as illustrated in
The processing unit 3 of the deployment system 1 can comprise the graph generation software component GGCS and the model transformation module MTM as illustrated in the block diagram of
The technical system is described in this simple example for this use case by a single function f: y=w·x+b, wherein b is a bias or offset of the camera CAM, x are input values and w is the conveyor belt velocity relative to the camera image and y are observed values, wherein w=c·v with c depending on a focal length and angle of the camera CAM.
The tuneable parameters θ of this technical system are in the given example w, b.
Generally, ŷ=ƒ(x;θ), wherein x is the input, and θ represents the parameters, i.e. the property to be estimated and ŷ is the estimated target value. In the exemplary use case, x is the end effector position, y is the vector of the pixel coordinates perceived. The weights of the model are optimal if ŷ=y. To find the optimal parameters θ (i.e. bias b and velocity w), an optimization problem can be formulated of a loss function L (y, ŷ; θ)=sum (yi−ƒ(xi,θ))2 (fix quadratic loss) and the parameters θ are optimized sequentially by calculating the gradient at θi and by doing a gradient step towards θi+1. Ideally, the gradient descent converges towards the minima of the loss function L. In a possible embodiment, stochastic gradient descents can be used. This stochastic gradient descent is approximating the gradient on a single sample or on a mini-batch instead of calculating the true gradient of a full training set. It then takes a small step in the direction of the gradient. A possible implementation of the stochastic gradient descent is as follows:
Using stochastic gradient descent has the advantage that storing the training samples is not needed and in addition, due to the fixed size mini-batches, real-time guarantees can be given. In the illustrated use case of
There are two different phases of operation, i.e. first a setup phase and then an online learning phase.
In the setup phase, the model to be used is deployed by the system 1 on a target field device TFD, e.g. on an S7 controller. The model comprises a set of functions defining the characteristics or the behaviour of the system. The model definition is partial in the sense that not all parameters θ need to be fully specified. In mechanical systems, for example, this definition consists of standard operations like scaling, translation and/or rotation. The partial definition of the system shall not be over-constrained. For example, a real system may comprise a translation not covered by the system model. Some variables or measurements can act as input values x and other act as target values y. Based on the input variables x and the parameters θ using the model, the estimated target values ŷ can be calculated ŷ=ƒ(x;θ). An error e between the true value y and the predicted value ŷ can be measured by means of the loss function L. One example is the 3D projection with unknown camera location. There, the missing information is a translation and rotation of the camera CAM as well as intrinsic camera parameters of the camera CAM. Another example is the kinematic of a robot arm where the relationship of a motor position to a position of a joint is partially defined, e.g. that a joint introduces a rotation of an end effector around the joint. The model can also contain other functions which predict values based on the weights learned by the systems. In a simple case, in the 3D projection, the expected position of the end effector can be based on joint positions. Or in the other example, utilizing the parameters in the inverse kinematic of the robot arm can be utilized to calculate the motor positions to reach a certain position with the end effector. The functions or formula of the system model can be translated into the computation graph CG which forms a model description. The computation graph CG forms a description of computational steps to apply the model to the measured data. In addition, the computation graph CG is augmented with partial derivatives with respect to each of the variables to be optimized by the learning process. The model is translated into a binary library which can be then executed as a target field device TFD. The model can typically consist of two subgraphs FCG, BCG which are related to one another. The forward computation subgraph FCG defines operations used for inference (model execution/scoring), and the other backward computation subgraph BCG defines the computations used for training, i.e. for updating the model parameters θ. Both subgraphs FCG, BCG can be parsed in order to convert them into a representation suitable for industrial real-time target field devices TFD. This conversion involves converting the computation graphs FCG, BCG for example into sets of C++ code files or any other low level language. This code can in turn be compiled in the model binary by means of a field device compiler. This model binary together with the generic learning code optionally with any other binaries required by the target device, e.g. a generic program to connect the self optimizing program to specific signals in the target device, can then be deployed in a memory of the target field device TFD. This step can be done separately for the forward (execution) and backward (training) subgraphs.
The target field device TFD can have different execution contexts, e.g. a real-time context and a non-real time context. In a possible deployment alternative, only the model execution software component MESC (representing the forward computation graph FCG) is deployed to the realtime context to work on a live stream of sensor data. The learning graph, i.e. the backward computation subgraph BCG may have more relaxed latency requirements. For example, the model can be updated or trained more slowly than the data flow and does not need to be updated on reception of every data sample. This makes it possible to deploy the corresponding training subgraph, i.e. the backward computation graph BCG on a non-real time context. The real-time context is typically more restrictive and the transformation helps the resulting model to meet the required constraints and qualities for real-time execution. The non-real time context can be less restrictive enabling a more flexible model training component to be deployed, which can work on a higher level representation of the model without requiring a parsing step or conversion to source code. Accordingly, there are two different possible alternative embodiments. In a first embodiment, the online learning software component is deployed in a non-real time context and therefore the parsing and/or conversion into a standalone binary is optional for this software component. The alternative embodiment, where both execution and online learning is performed on the real-time context, requires both to be parsed into efficient binaries.
After the setup phase has been concluded, the online learning phase is initiated. The online learning phase contains besides standard control flows the following steps. When the control is started up, the parameters θ which are also called weights representing the unknown information in the model definition phase can be initialized at random. When the control is running all data is processed in the target field device TFD or controller as normal. However, in addition, each measured data point required by the model deployed is also run through the following processing steps. First, all measurements, parameters and if available also target values, are injected into the binary library generated in the model definition phase. The library then calculates based on the weights and parameters the expected target values, but also the parameters and the partial derivatives of all parameters in respect to the values. The partial derivatives of the parameters, weighted by the learning rate, are then added to parameters to derive a new parameterisation. In addition, the additional functions are evaluated.
The derivative of the first unknown parameter b is as follows: −(2·(y−((w·x)+b)).
The derivative of the second unknown parameter w is as follows: x·(−(2(y−((w·x)+b).
Accordingly, the derivative of the second parameter w can use the result of the first parameter b as also illustrated in the computation graph CG shown in
The method and deployment system according to the present invention can be used for any kind of industrial system, in particular automation systems or robotic systems. The method allows for a self-adaption to change the process parameters θ. Further, it allows for a partial setup system as it can itself adapt to changes between preconfigured and real process parameters. The learning can be performed in a possible embodiment in real time. The method can be applied whenever an industrial automation is used to control some kind of effectors or actuators such as motors, valves for fluids, etc. where the consequences (e.g. position, speed, flow, temperature) can be measured and there is an expected target for the measured consequences. Accordingly, the method according to the present invention can be used for both a feedforward control system or a regulation or a feedback control system. In a feedforward control system, the target value can be hit more accurately. In regulation systems, the system becomes more stable as the prediction of the consequence of a control intervention can be more accurately predicted by a machine. To predict the consequence of a control intervention, the model can predict the effort of a control and/or calculate necessary control steps based on the expected target value. These models can be typically configured by means of parameters θ which need to be adjusted to the real system properties of the technical system.
The method according to the present invention provides a learning in an industrial control system where the learning can be optionally performed in real time. A model generation learning is based on a predefined model of the technical system. The method and deployment system according to the present invention result in a more accurate and precise control since the controlled technical system can be adapted automatically to its environment. Further, maintenance costs for the technical system are reduced as no manual calibration needs to be triggered. Therefore, maintenance costs but also non-productive periods of the technical system can be significantly reduced. This can be achieved by the online learning software component OMTSC which ensures that the parameters θ describing the technical system to be controlled are adjusted more accurately. Therefore, the method allows to adjust the parameters of the technical system more precisely.
Number | Date | Country | Kind |
---|---|---|---|
17181431.2 | Jul 2017 | EP | regional |
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/EP2018/069113 | 7/13/2018 | WO | 00 |