Evaluation of Optimization Solvers On Programmable Logic Controller
Evaluation of Optimization Solvers On Programmable Logic Controller
TABLE I. PLC PLATFORM CONSTRAINTS Table 3 presents the code sizes of optimization solvers.
SCIP and NSGA2 solvers require approximately 21.0
No Constraint Limit MB and 7MB for the program storage which is more than
1 CPU time (msec) Application the 4MB program memory available in AC500 PLC.
Requirement Program size of SCIP and NSGA2 limits their use for
2 CPU load (%) embedded optimization. Therefore it is not feasible to
3 FBsize (KB) deploy SCIP and NSGA2 solvers on AC500 PLC.
4 Task stack size (KB) CVXGEN generates problem specific optimization solver
PLC Specification code for embedded applications. Code size of CVXGEN
5 Program data size (KB)
solver is reported for two variable optimization problem.
6 Program size (KB) MIDACO being a commercial solver, very limited
version of 4 variables is available for trial. MIDACO can
534
Authorized licensed use limited to: Amazon. Downloaded on May 15,2024 at 15:16:02 UTC from IEEE Xplore. Restrictions apply.
solve NLP with integer and linear constraints. PSwarm is printing and scanning functions are removed for PLC
selected to check the performance of evolutionary deployment; internal arrays used within the solver code are
algorithms on PLC. lp_solve is Linear Programing (LP) reduced to accommodate maximum expected problem size.
and Mixed Integer Linear Programming (MILP) solver. Solver files not relevant for optimization testing are
lp_solve is not selected because it requires external lex (.l) removed to reduce the code size without loss of desired
and yyac (.y) support along with the C libraries which
are not supported by Control Builder. MINPACK functionality. Resulting C code is used for the feasibility
considered in this work is C-translated library Cminpack study.
[11], which is originally written in FORTRAN. C code is compiled in ABB Control Builder Plus
environment to get CPU specific executable file. C code
TABLE III. SOLVER SELECTION AND SIZES
executable file is wrapped by the Program Organizing Unit
Solver Code Size(KB) Selected (POU) type FB in Structured Text (ST) programming
qpOASES 200 Yes language. Objective function and constraints for
optimization are defined within the C code application.
MINPACK 812 Yes After successful compilation of C code application, IEC
lp_solve 121 No 61131-3 interface is built in CODESYS for deployment on
MIDACO 134.77 Yes PLC platform. Resulting POU type FB is called from
NSGA2 7168 No CODESYS for optimization solver feasibility tests on PLC.
CVXGEN 276 Yes PSwarm is particle swarm derivative-free global
SCIP 21504 No optimization solver [13], which requires high number
PSwarm 331 Yes function evaluations and iterations. It is found from
experiments that it takes more execution time, in the order
B. Test Functions of minutes, for test problems. Therefore, PSwarm is less
efficient for solving embedded optimization problems.
Standard test functions are used to test the performance of Hence, it is not considered for detailed evaluation in this
optimization algorithms. Generalized form of Rosenbrock work.
function and Powell function are used because these IV. RESULTS AND DISCUSSION: TEST FUNCTION
functions are widely used for optimization solver testing
[12]. Modified Rosenbrock and Powell functions given by Objective of this section is to analyze the feasibility of
(1) and (2) are considered for this work. each solver for deployment on PLC platform and not to
Modified Rosenbrock Function compare performance of different solvers on PLC.
- . ( - ' . & - ' . (1) Feasibility is evaluated against different platform and
application specific constraints presented in Table 2.
Modified Powell Function Optimization complexity is varied by increasing the test
- . ( - & . & - ' . & problem size i.e. number of variables. Test problems
- ' . & * ' + (2) with more than 100 variables are considered to check the
limits of PLC platform. MIDACO being a commercial
Constrained optimization problem is constructed with
solver, very limited version of 4 variables is available for
generalized test functions as objective and linear constraints.
Test optimization problems are given by (3) and (4). trial therefore MIDACO is not considered for test
problems but it is considered for compressor case study.
Generalized Modified Rosen Brock objective Function CVXGEN is not preferred for higher number of variables
because of large size of generated code [1] hence
- . ( , - ' . & - ' ! .
! CVXGEN is excluded for test problem evaluation.
Subject to, ) & & & ) (3)
Table 4 and 5 present results of optimization
Generalized Modified Powell objective Function experiments conducted on test problems (3) and (4).
- . ( , - & . & - ' Results are recorded for cycle time of 40 sec and load
!
sampling time of 15 msec; average over 20 cycles is
. & - ' . & * '
+ reported for analysis in Table 4 and 5. CPU load is one of
the important specifications for any automation project.
Subject to, ) & & & ) (4)
Therefore, results are compared for similar CPU load for
C. Implementation different cases. It can be seen that optimization problem
size of more than 130 variables can be solved with
Selected solvers are compiled in Visual Studio
approximately 45% CPU load with 40 sec cycle time.
environment to test the solver implementation. Visual
Code size does not get significantly affected with increase
studio environment results are further used to test accuracy
of solver results from PLC platform. All inbuilt solver in problem size. Code size of both the solvers is much
535
Authorized licensed use limited to: Amazon. Downloaded on May 15,2024 at 15:16:02 UTC from IEEE Xplore. Restrictions apply.
lower than the available program memory of 4MB; execution is one part of the CPU compute cycle. Other
qpOASES code size is ~ 200kb while MINPACK code CPU tasks in compute cycle are < scanning inputs,
size is ~ 40 kb. Therefore both the solvers could be reading and writing global variables, interrupts execution
downloaded on PLC. and writing to output variables which results in discrete
load levels. Since presence of other automation libraries
TABLE IV. TEST FUNCTION RESULTS: QPOASES ON PLC affect the observed CPU load it is difficult to generalize
Solver qpOASES the CPU load and test problem size results. But it can be
concluded that CPU load is an important criteria for
Function Rosenbrock* Powell*
optimization based solution deployment on PLC
Variables 2 129 4 124 platform.
Average CPU 2.58 38.86 2.5 41.99
Load (%) TABLE V. TEST FUNCTION RESULTS: MINPACK ON PLC
Task stack size 20.56 182 19.776 182.0
Solver MINPACK
(KB)
Function Rosenbrock* Powell*
POU Size (B) 40 1144 64 1224
Variables 2 140 4 32
IEC-61131 data 3825 4978 3460 5140
size (B) Function 7 283 1004 6606
evaluations
C data size(KB) 4.704 667.3 8.496 708.1
Jacobean 2 2 191 199
IEC 61131 code 259.8 260.3 256.35 261.5 evaluations
size (KB) Average CPU 2.57 50.126 2.43 49.96
C code size 200.9 200.4 197.36 201.65 Load (%)
(KB) Task stack size 10.14 890.53 6.512 38.73
Maximum CPU 0.328 1536 0.584 1336 (KB)
Time (msec) POU Size (B) 48 1224 56 304
Different solvers behave differently with increase in IEC-61131 2403 5098 4486 3304
problem size; stack memory requirement is ~ 10kb for Data size (B)
MINPACK while it is ~ 20kb for qpOASES, data size C data size(KB) 0.84 3.6 0.784 1.4
increase is similar for the two solvers but they occupy IEC 61131 code 68.58 69.13 66.87 66.12
different memory sections of the PLC which becomes size (KB)
important because different PLCs have different C code size (KB) 40.90 40.94 38.74 38.77
limitations on different memory sections. AC500 has tight
Max. CPU time 0.171 1323 39 1520
limitation of 12kb stack memory with no FB memory limit
(msec)
while Siemens has 64kb FB memory limitation and no
documented limitation on stack memory [1]. Therefore
memory management might be required to run the solver V. CASE STUDY: COMPRESSORS LOAD ALLOCATION
on different PLCs. Both solvers take less than 1.5 sec for OPTIMIZATION
problem size of ~ 130 variables which is less than 6 sec A. Problem Formulation
hardware limit imposed by Siemens PLC S7-300 and many
Parallel train of compressors shown in Fig. 1 is
practical applications in process industry. Therefore, both
considered for realistic case study. It is based on reference
the solvers can be used for the embedded optimization
and discussions in [6]. Compressor efficiency curves or
problems.
island curves are given in Fig. 2. It can be clearly seen
Generally, automation project requirements specify that compressor efficiency increases by moving towards
average PLC load in the rage of 60-80%. AC500 PLC the center of the ellipse. Single compressor iso-efficiency
supports 16 tasks which implies permissible average task curve approximation is given by Equation (5).
load of 4-5%. But optimization problems with more than
100 variables can lead to approximately 40% to 50% CPU ( - # ' . & - ' .
(5)
load which is significantly greater than the average Where Pp is pressure ratio and W is mass flow rate.
permissible task load. Therefore, CPU load can be the most Equation (5) can be represented in QP formulation as well
constraining factor for many industrial applications. It is as least square formulation. For 2 compressors system
observed that increasing number of variables does not efficiency is described by (6) [6].
result in linear increase of CPU load. It can be explained
( - # ' . & - ' .
&- # ' .
&
by the fact that many system tasks load CPU irrespective
of the optimization task complexity. Optimization solver - ' . (6)
536
Authorized licensed use limited to: Amazon. Downloaded on May 15,2024 at 15:16:02 UTC from IEEE Xplore. Restrictions apply.
Subject to, This problem can be extended to N variables and
! % objective function representation in QP and least
$"$ ) & ) $"$ (7)
! % square can be generalized. Most of the compressor
) ) Where, i = [0, 1] (8)
stations have maximum 7 compressors connected in parallel
Where, C1, C2 and C3, C4 are center points of iso- connection. Therefore compressor train of maximum seven
efficiency compressor curves, W1, W2 are mass flow rate compressors is considered in this work. Identical
%
of first and second compressor, $"$ and $"$!
are compressors are considered for the present work
maximum and minimum value for header mass flow rate because many compressor stations in practice have this
and % and ! are minimum and maximum mass configuration. Hence c1=0.175, c2=10 is considered for all
flow rate of ith compressor. compressors in parallel train [6].
537
Authorized licensed use limited to: Amazon. Downloaded on May 15,2024 at 15:16:02 UTC from IEEE Xplore. Restrictions apply.
B. Results and Discussion REFERENCES
Table 6 presents the results of compressor train load [1] B. Huyck, H. J. Ferreau, M. Diehl, J. D. Brabanter, J. F. V. Impe, B.
D. Moor, and F. Logist, (201=,4/"0,+)'+#*,"#)-/#"'!1'3#
allocation optimization. Results are recorded with the control on a programmable logic controller: practical
same procedure that is followed for test function results. !,+0'"#/1',+0?Mathematical Problems in Engineering, 2012.
Additional solvers CVXGEN and MIDACO are [2] B. Huyck, J. D. Brabanter, B. D. Moor, J. F. V. Impe, and F. Logist,
included for evaluation because the problem sizes are =+)'+#*,"#)-/#"'!1'3#!ontrol of industrial processes
using low level control hardware: A pilot-scale distillation column
small. All the solvers except MIDACO report Max CPU !0#012"6? Control Engineering Practice, 28, 34-48.
time of less than 3.2 msec for seven compressor load [3] I. Rauová, R. Valo, M. Kvasnica, and '(/=#)-time
allocation problem. MIDACO reports ~ 0.5 sec of Max model predictive control of a fan heat#/3'?In Proceedings of
CPU time which is less than the practical limit. Therefore the 18th International Conference on Process Control (pp. 388-
393).
CPU time is not a constraining factor. Code size increases [4] B. Meindl, and #*-)=+)60'0,$!,**#/!')+"$/##
with problem size for CVXGEN while it remains constant +",-#+0,2/!#0,)3#/0$,/)'+#/,-1'*'71',+-/, )#*0? Eurostat
for other solvers. MINPACK is the most compact solver and Statistics Netherlands within the project ESSnet on common
with less than 40kb code size. Code size is not a tools and harmonised methodology for SDC in the ESS.
[5] %2+/1: =5-#/'*#+1)1#01'+%,$"3+!#"
constraining factor for any of the solvers. All the solvers scatter search designs for global optimization of multimodal
report similar CPU load of ~ 2.5% which is less than the $2+!1',+0? Journal of Global Optimization, 33(2), 235-255.
average permissible task load. MINPACK and CVXGEN [6] T. F. Øvervåg. "Centrifugal Compressor Load Sharing with the use
needs less than 10kb stack memory while qpOASES needs of MPC." (2013).
[7] ))/1&='5#"'+1#%#/,-1'*'71',+'+1&#!&#*'!)
~ 20kb and MIDACO takes ~ 60kb of stack memory. process industry: Experience, potential and future
AC500 PLC has limit of 12 KB on stack memory -#/0-#!1'3#0? Chemical Engineering Research and Design, 78(6),
therefore, memory management is required to deploy 809-822.
qpOASES and MIDACO on AC500. [8] H. J. Ferreau, C. Kirches, A.Potschka, H. G. Bock, and M. Diehl
=.- -/*#1/'!!1'3#-set algorithm for quadratic
Results show that all solvers provide solution in -/,%/**'+%?Mathematical Programming Computation, 6(4),
327-363.
microseconds time scale, except MIDACO. MIDACO [9] H. J. Ferreau, P.Ortner, P. Langthaler, L. Del Re, and M. Diehl,
being Ant Colony Optimization solver includes maximum =/#"'!1'3#!,+1/,),$/#)-world diesel engine using an
number of function evaluations as stopping criteria. With #51#+"#",+)'+#!1'3#0#101/1#%6? Annual Reviews in
default number 10,000 function evaluations, solution Control, 31(2), 293-301.
[10] D. Kolokotsa, G. S. Stavrakakis, K. Kalaitzakis, and D. Agoris.
accuracy is compromised. But increasing number of "Genetic algorithms optimized fuzzy controller for the indoor
function evaluations increases CPU time. Therefore use of environmental management in buildings implemented using PLC
MIDACO for PLC deployment need to be assessed on case and local operating networks." Engineering Applications of
by case basis. CVXGEN is a code generation based solver. Artificial Intelligence 15, no. 5 (2002): 417-428.
Stack size remains constants with increase in number of [11] F. Devernay. C/C++ MINPACK. Website:
http://devernay.free.fr/hacks/cminpack/cminpack.html ,May 2011.
variables because it occupies global data memory in PLC. [12] M. Jamil, and +% ='1#/12/#2/3#6,$
Cluttering global data space is not advised for PLC Benchmark Functions for Global Optimizat',+/, )#*0? arXiv
application because global variables are used for preprint arXiv:1308.4008.
initialization of data which can be shared by different [13] A. I. F. Vaz, and '!#+1# =-/1'!)#04/*-11#/+
0#/!&*#1&,"$,/ ,2+"!,+01/'+#"%), ),-1'*'71',+? Journal
processes and I/O data communication. of Global Optimization, 39(2), 197-219.
VI. CONCLUSION
PLC is a reliable and time tested platform for control of
industrial processes. Advances in PLC platform opens up
opportunity of optimization based advanced solutions on
PLC. Present work outlines systematic approach of open
source optimization solver deployment on PLC; different
hardware and application specific constraints are explored
for ABB AC500 PLC through test functions and practical
compressor load allocation case study. Feasibility analysis
results for four open source solvers are presented. Similar
analysis for other PLCs can provide guideline for
optimization based solution deployment in specific cases
of interest. Compressor load allocation optimization case
study demonstrate that open source optimization solvers
can be used to solve practical problems on PLC platform.
538
Authorized licensed use limited to: Amazon. Downloaded on May 15,2024 at 15:16:02 UTC from IEEE Xplore. Restrictions apply.