# XOR Binary Gravitational Search Algorithm with Repository: Industry 4.0 Applications
## 5 Simulation Results
### Application to Knapsack  
As the second class of benchmark optimization problem, the multi knapsack problem is considered. The problem formulation of 0/1 knapsack problem is discussed in summary in this part. Let there be \(n\) items with each having a positive profit \(p_{i}>0\) and a positive resource consumption \(r_{i}>0\). The main objective is to fill several knapsacks with resource capacity of \(C_{j}\) such that the accumulated profit of the items is maximized. Considering the constraints imposed by capacity of knapsacks, this problem is a constrained binary optimization problem. Such problems arises in various real-world applications such as in a distributed computer systems, warehouse optimization, cargo loading and stock problems [5,26]. This problem is explicitly formulated as follows:  
\[\mathrm{f}\left(\mathbf{x}\right)=\max\ \sum_{i=1}^{n}p_{i}x_{i} \tag{70}\]  
\[\mathrm{s.t.}\ \ \sum_{i=1}^{n}r_{i}x_{i}\leq C_{j},\ j=1,\ldots,m \tag{71}\]  
\[x_{i}\mathbf{\in}\left\{0,\ 1\right\}\ \forall i\mathbf{\in}\left\{1,\ldots,n\right\}\]  
where \(n\) represents the item number, \(m\) is the number of constrains, \(p_{i}\geq 0\) represents the profit value for each item, resource consumption is expressed by \(r_{ij}\geq 0\) and the capacity is denoted by another positive value \(C_{j}\geq 0\). The cost function is multiplied by negative value of \(-1\) to change maximization to minimization problem. The constraints are added as penalty terms to the cost function to obtain an unconstrained optimization problem as follows:  
\[f_{uc}\left(\mathbf{x}\right)=-\sum_{i=1}^{n}p_{i}x_{i}+\beta\sum_{i=1}^{n}\sum _{j=1}^{m}min\left(C_{j}-r_{ij}x_{i},0\right) \tag{72}\] \begin{table}
\begin{tabular}{l c c c c c c c} \hline \hline
**Function** & **n** & **d** & **Proposed** & **BGSA** & **IBPSO** & **BPSO** & **BGWO** & **BDA** \\
**Number** & & & [16] & [17] & [15] & [18] & [19] \\ \hline \(f_{1}\left(X\right)\) & 1 & 1 & 3.64E-10 & 6.55E-10 & 0.003499 & 2.98E-07 & 0.079185 & **9.09E-11** \\ \hline \(f_{7}\left(X\right)\) & 7 & 10 & \(-8.83999\) & \(-\)**9.00763** & \(-5.11393\) & \(-3.84276\) & \(-5.97745\) & \(-7.38148\) \\ \hline \(f_{8}\left(X\right)\) & 8 & 1 & 7.63E-05 & 7.63E-05 & 0.17688 & 0.001563 & 1.270744 & **3.82E-05** \\ \hline \(f_{8}\left(X\right)\) & 8 & 2 & **7.63E-05** & 0.002378 & 0.873989 & 0.346521 & 3.054737 & 0.00026 \\ \hline \(f_{8}\left(X\right)\) & 8 & 5 & **7.63E-05** & 0.497182 & 4.210083 & 4.515039 & 9.078786 & 0.311861 \\ \hline \(f_{8}\left(X\right)\) & 8 & 10 & **0.07325** & 1.479706 & 6.721189 & 8.003571 & 11.92714 & 2.243791 \\ \hline \(f_{9}\left(X\right)\) & 9 & 1 & 3.64E-10 & 3.64E-10 & 0.000344 & 2.89E-07 & 0.052176 & **9.09E-11** \\ \hline \(f_{9}\left(X\right)\) & 9 & 2 & **1.09E-09** & **1.09E-09** & 0.285221 & 0.005263 & 3.989166 & 2.82E-08 \\ \hline \(f_{9}\left(X\right)\) & 9 & 5 & **5.46E-09** & 0.267058 & 10.71721 & 7.755365 & 108.3779 & 0.011655 \\ \hline \(f_{9}\left(X\right)\) & 9 & 10 & **3.09E-07** & 7.555599 & 125.9897 & 176.937 & 1128.728 & 5.058231 \\ \hline \(f_{10}\left(X\right)\) & 10 & 1 & 4.63E-06 & **2.32E-06** & 0.000547 & 2.03E-05 & 0.008308 & 2.88E-06 \\ \hline \(f_{10}\left(X\right)\) & 10 & 2 & 0.000948 & 0.000326 & 0.015704 & 0.003854 & 0.111948 & **0.000223** \\ \hline \(f_{10}\left(X\right)\) & 10 & 5 & 0.045093 & **0.021953** & 0.898418 & 1.041691 & 1.199264 & 0.080774 \\ \hline \(f_{10}\left(X\right)\) & 10 & 10 & **0.189655** & 0.304581 & 3.68566 & 6.668867 & 5.377988 & 0.748952 \\ \hline \(f_{11}\left(X\right)\) & 11 & 1 & **–400.1** & **–400.1** & \(-99.9787\) & \(-100.093\) & \(-398.391\) & \(-100.1\) \\ \hline \(f_{11}\left(X\right)\) & 11 & 2 & **–800.2** & \(-799.77\) & \(-196.958\) & \(-198.57\) & \(-786.66\) & \(-200.195\) \\ \hline \(f_{11}\left(X\right)\) & 11 & 5 & **–2000.5** & \(-1996.02\) & \(-461.362\) & \(-442.035\) & \(-1900.74\) & \(-498.794\) \\ \hline \(f_{11}\left(X\right)\) & 11 & 10 & **–4000.99** & \(-3983.41\) & \(-839.887\) & \(-740.219\) & \(-3875.63\) & \(-974.665\) \\ \hline \hline \end{tabular}
\end{table}