Increasing the Creativity of ENGINO Toy Sets and Generating Automatic Building Instructions

During the First Study Group with Industry which was held in Limassol, Cyprus, the ENGINO TOY SYSTEM introduced two challenging problems. The first is to get bounds on the number of possible models/toys which can be constructed using a given package of building blocks. And the second is to generate automatically the assembly instructions for a given toy. In this report we summarize our insights and provide preliminary results for the two challenges.


Introduction
ENGINO R TOY SYSTEM was founded by Costas Sisamos in 2004 in order to commercialize his invention of a new system of multi-functional plastic connectors.After successfully receiving research funding, Costas left his full-time job as an educator to fully engage in R&D, and after 3 years of designing, prototyping and testing, in 2007 he launched the first sets of ENGINO construction toys.The ENGINO toys are created by assembling small pieces together, with the purpose of helping pupils build technological models creatively and easily so that they can experiment and learn about science and technology in a playful way.The products grasped the attention of global buyers and toy experts and by now more than 60 different toy sets are manufactured in his production facility in Limassol, Cyprus, covering various age levels and price ranges, from simple sets to solar energy and robotics.The company has experienced steady growth, reaching presence in more than 40 countries by now.
Each of the 60 toy sets produced by ENGINO has a specific number of blocks that can be assembled into many different models.Based on experience, it has been observed that the creative potential of the system increases geometrically as the number of blocks in the set increase.This is due to the patented design of the ENGINO blocks that allow connectivity from many directions simultaneously.

Description of the challenges
For this 125th European Study Group with Industry, that took place in Limassol, Cyprus, from 5-9 December 2016, the company proposed two challenges.
1. Given a package of blocks, evaluate the number of possible models/toys using the package's blocks.With this "creativity measure" the company is able to know if the sets have indeed been optimized or if more models are also possible.Also, by substituting some blocks with others maybe the level of creativity can be increased.Furthermore it will provide a marketing tool to explain the creativity of the system.
2. Another big challenge for the company is to be able to generate the assembly instructions for each toy automatically.For most of the toy sets the instructions are currently being created manually.The developers attempted to create an automatic disassembly module in a proprietary 3D builder software which is based on the UNITY 3D-Game Engine.However, the system cannot predict which block needs to be connected first during the assembly instructions.The priority of parts is random and incorrect, making the generated instructions not usable.
It is important to find a solution to this problem and have an algorithm that will be able to prioritize the different parts of the structure or substructure, which we can feed in the software so that we shall optimize the de-structuring of a model with physically correct priority sequence.There may be endless possibilities that can work so a solution may seem impossible, however there some solutions that definitely will not work and those are the ones we need to be able to identify and remove from the possible assembly sequence.
The main goal of this report is to give an answer to second challenge.Nevertheless, we will give a partial answer for the first one, considering the particular case where we just have constructions obtained by linearly assembling the blocks.We may define a linear assembly construction as a model obtained by an ordered sequence of blocks such that each block is connected only to the previous (if it exists) and to the following (if it exists) ones.
where t j is the number of blocks of type j and v(B ij ) is the valency of a block B ij , defined as the maximal number of possible connections of B ij .
Proof.The first piece offers a number of connections equal to its valency.Other pieces can be connected to the previous one in a number of ways equal to their valencies.Except the last one, they also offer a number of possible connections to the following piece equal to their valencies minus one.
During the meeting P. Hjorth and H. Ockendon proposed a formulation of optimization problem whose solution could help the company build packages able to produce a maximal number of models under given constraints.The optimization model was developed by A. Riseth and its results can be found in Appendix A of the present report.

Mathematical model and analysis
Let us now focus on the second challenge.As we mentioned before, currently, for most toys, the instructions are being created manually.Our goal is to develop an automatic assembly instruction manual for each toy.To do this we actually follow the reverse process, that is, given a description of a toy model, which is available in the company's database, we develop a method to check whether a disconnection between particular blocks of the model is physically possible.In what follows we call this procedure a Physically Feasible Decomposition (PFD) of the model.The result of such a decomposition would be a collection of sub-models, on which the method can be recursively applied until no further decompositions are possible.Once the model has been decomposed to its constituent blocks, the steps of the decomposition can be reversed to produce its assembly instructions manual.
We now present the proposed framework for the solution of the decomposition problem discussed above, based on a graph theoretic approach.Given a toy model M , we associate to it a directed graph G(V, E), where is the edge set of G, with each directed edge representing a connection between two blocks of the model.
Every physical connection between two blocks of the model can be aligned in space to one particular direction vector, chosen out of a finite collection of directions.For instance, if a model uses only perpendicular connections between its blocks in 3D space, we can identify three direction vectors î, ĵ, k along which all connections can be aligned.A connection between two blocks of the model u, v, aligned to a particular direction d in physical space, gives rise to a directed edge (u, v) 2 E, if the vector from u to v points towards the same direction with d.
Assuming that all the connections of the model M correspond to p distinct spatial directions, we can partition the edge set E into a family of p mutually disjoint sets E i , i = 1, 2, . . ., p, each of which contains the edges associated to connections sharing the same direction in space.
Principle of Physically Feasible Disconnection: In order to disconnect two blocks corresponding to vertices v s , v t 2 V , connected via an edge (v s , v t ) 2 E aligned to a given spatial direction d, the blocks v s , v t must be able to be displaced along the directions d, d respectively, when appropriate opposite forces are applied on the blocks.
The idea behind the above principle is illustrated in the following example.
Example 1.Consider the two blocks shown in the following figure (Fig. 2) Figure 2: Two blocks that can be disconnected The blocks 1, 2 can be disconnected using two opposite horizontal forces, since their application on the two blocks will result in displacements along the horizontal direction.
If a third block is added as shown in the following picture (Fig. 3) Figure 3: Blocks 1, 2 cannot be disconnected then the blocks 1, 2 cannot be disconnected by applying on them opposite horizontal forces, since their displacement is blocked by their vertical connections to the block number 3.
Our aim is to identify a set of connections between the blocks of the model that can be disconnected simultaneously without violating the Principle of Physically Feasible Disconnection stated above.We call this a Physically Feasible Decomposition (PFD) of the model.The problem of finding a PFD of a toy model can be stated as follows: Problem 1. Find a subset of edges Ēi ✓ E i , for some i = 1, 2, . . ., p, whose removal imply a PFD of the model into two or more submodels.
To obtain a PFD we propose the following procedure: 1. Choose a subset of edges Ēi ✓ E i , whose connections are aligned in the same spatial direction.
2. Remove all edges of Ēi from G and all directions from edges to obtain the undirected graph G 0 (V, E \ Ēi ).Input: Undirected version of the graph G(V, E) and a subset of edges Ēi ✓ E on a given direction to be removed.

Apply some connectivity search algorithm (see
// Run a Depth First Search starting // from vertex s.The result // is a connected component The following theorem provides a criterion to decide whether the removal of a set of edges along a given direction gives rise to PFD of the model.Proof.We shall use induction on the number of components, in and there are no directed cycles, the CCG can have no edges.Thus, no disconnections between blocks take place and the component C 1 can be trivially considered as a PFD of the model, since the PFD principle is not violated.
• Assuming that the theorem holds for any CCG with k components, where k 1, we shall prove it for any CCG with k + 1 components.
Let ḠC ( VC , ĒC ) be a CCG, with k + 1 components which contains no directed cycles.We first show that if ḠC contains no directed cycles, then there exists a vertex (component) C1 2 VC , with no incoming edges.Since ḠC has no directed cycles, all its paths will be of finite length.Thus, let the sequence P = ( C1 , C2 , . . ., Cm ), m  k + 1, be a path of maximal length in ḠC .Clearly, if there was an incoming edge on C1 , there should be a vertex C0 2 VC connected to C1 through the edge ( C0 , C1 ).In such a case the path P 0 = ( C0 , C1 , C2 , . . ., Cm ), would be longer than P , which has been assumed to be maximal.Thus, C1 has no incoming edges.
Using this fact, since C1 has only outgoing edges, the underlying physical connections between C1 and the rest of the components of VC , will point towards the direction di .In other words, the component C1 is connected to the rest of the model only on the one side, leaving its other side free.Thus, applying opposite forces on C1 and the rest of the model, will result in a PFD of the model, since C1 is free to move towards the direction di (see Fig. 4).The key idea behind the proof of the above theorem is the well known fact (see for instance [1,2]) that every directed acyclic graph has a topological ordering.
According to the above theorem if the CCG of a model contains no directed cycles then a PFD is implied.In the case where directed cycles are present in a CCG, we may easily eliminate them by removing all the edges of Ēi that give rise to edges of E C lying on the directed cycles of the CCG.The resulting CCG will no longer have directed cycles, since the constituent components of each cycle will collapse to a single component.Thus, according to the theorem this new CCG will imply of PFD of the model.Moreover, if the new CCG contains two or more components the implied PFD will be a non trivial one.

Examples
Let us now consider three illustrative examples.
Example 2. Consider the following model (Fig. 5) The edges to be removed are (2, 3), (1, 5), (4, 5).After the removal, the graph becomes Next, the CCG is formed by associating to each of the removed edges an edge between the components which it was connecting, i.e.
According to Theorem 2, the edges participating to the loop on C 1 are not physically removable, hence the only PFD can be obtained from the edges (1,5), (4,5).

Case 2 Removal of edges in the direction ĵ:
The edges to be removed are (2, 1), (4, 2), (3, 1), (4, 3).After the removal, the graph becomes The CCG is formed by associating to each of the removed edges an edge between the components which it was connecting, i.e.
(2, 1) Thus, the CCG is All removed edges are participating the directed cycle between C 1 and C 2 , no disconnection is physically feasible in this direction.
Example 3. Consider the following model The edges to be removed are (1, 2), (2, 3), (3, 4).After the removal, the graph becomes in which the following components can be identified The CCG is formed by associating to each of the removed edges an edge between the components which it was connecting, i.e.
The edges participating to the loop on C 2 are not physically removable, hence the only physically feasible disconnection can be obtained from the edges (1,2), (3,4).
Case 2 Removal of edges in the direction ĵ: The edges to be removed are (2, 5), (5, 7), (3, 6), (6, 7).After the removal, the graph becomes in which the following components can be identified The CCG is formed by associating to each of the removed edges an edge between the components which it was connecting, i.e.
(2, 5) Since there is not a directed cycle in the connectivity graph all edges are physically removable.The edges to be removed are (1, 2), (2, 3), (3, 4).After the removal, the graph becomes in which the following components can be identified The CCG is formed by associating to each of the removed edges an edge between the components which it was connecting, i.e.
(1, 2) Thus, the CCG is All edges participate the directed cycle between C 1 , C 2 , C 3 , hence none of them is physically removable.
Case 2 Removal of edges in the direction ĵ: The edges to be removed are (1, 5), (4, 5).After the removal, the graph becomes in which the following components can be identified The CCG is formed by associating to each of the removed edges an edge between the components which it was connecting, i.e.
Since there are no directed cycles, all edges are physically removable.

Conclusions and recommendations to the company
A systematic procedure for the Physically Feasible Decomposition (PFD) of an ENGINO R TOY SYSTEM model has been proposed.A directed graph using as vertices the blocks of the model, and as edges, connections between them, is used to capture the structure of the model.The edges of the graph are labeled with a direction vector used to identify geometric direction of the underlying connection between blocks on the original model.Removing groups of edges sharing the same direction vector, we identify the resulting connected components of the graph, which in turn are used to construct a higher -level, structure -graph called the Components Connectivity Graph (CCG).The absence of directed cycles in the CCG is in turn shown to play a key role in the determination of the subset of edges whose removal implies a PFD of the model.We strongly advise ENGINO to do a pilot-test before implementing this model.In order to have an effective implementation, the model will need further developments, tests and implementation issues with respect to its adherence to the company particular needs and related problems.Even though the model yield good preliminary results, it must be validated using more complicated toys.This is a crucial step that can be carried by a shortterm project (MSc) or an internship in a close collaboration with the industrial partner.The company should also consider offering a PhD Scholarship and/or a Postdoc Fellowship.We believe that the model here described can provide some useful hints with interest for the optimization of production process.pieces.The part costs per piece are all set to the same number, c j = 1 for j = 1, 2 . . ., N, and we look for box sets with a total cost no more than C = 70.This can easily be formulated in Julia, and an example code is included in Listing 1.The optimisation problem takes less than two minutes to complete on a 32 core machine, and produces a box set that can generate 554 models of the 1000 models, using 70 pieces.

Figure 1 :
Figure 1: Linear assembly Theorem 1.Given a set of n blocks (B i,1 , . . ., B i,n ), the number of possible linear assemblies with this set is given by

Theorem 2 .
Let M be a toy model and its associated directed graph G(V, E).Let furtherG C (V C , E C) be the CCG resulting after the removal of a subset of edges Ēi ✓ E i , where E i is the set of all edges of G(V, E) along the direction di .If G C contains no directed cycles, then the removal of the edges Ēi implies a PFD of the model M .

Figure 4 :
Figure 4: Physical disconnection of C1 from G C

FigureCase 1
Figure 5: Model 1 following two components can be identified

Listing 1 : 4 #
Simple Julia code that can formulate and run optimisation problem with the Gurobi solver.u s i n g JuMP, Gurobi # The r e q u i r e d J u l i a packages # Assume we are given a matrix P of s i z e M \ times N c = ones (N) # The cost array C = 70 # The maximum cost # Require at l e a s t D_l models of s i z e >= 42 models_l = ( 1 : s i z e (P , 1 ) ) [ sum (P, 2 ) .>= 4 2 ] D_l = Set up optimisation model problem m = Model ( s o l v e r=GurobiSolver ( ) ) @ v a r i a b l e s m begin y [ i =1:M] , ( Bin , s t a r t =0) # Models , binary v a r i a b l e s x [ j =1:N] , ( Int , s t a r t =0) # Parts , i n t e g e r v a r i a b l e s end @ o b j e c t i v e (m, Max, sum( y ) ) # Maximize number o f models @ c o n s t r a i n t s m begin dot ( c , x ) <= C [ i =1: models , j =1: parts ] , x [ j ] >= P[ i , j ] ⇤ y [ i ] sum ( y [ i ] f o r i i n models_l ) >= D_l end # The optimisation problem i s solved by the solve (m) c a l l s t a t u s = s o l v e (m) # The box set and models that can be created b o x p i e c e s = g e t v a l u e ( x ) boxmodels = f i n d ( g e t v a l u e ( y ) ) Algorithm 1)on G 0 to identify its connected components C j , j = 1, 2, . . ., k. 4. For each (s, t) 2 Ēi , identify the pair of components (C as vertices and the (distinct) pairs of components resulting from step 4 as directed edges, create the directed Components Connectivity Graph (CCG).We denote the directed CCG by G s , C t ) such that s 2 C j , j = 1, 2, . .., k, C (V C , E C ), where V C = {C 1 , C 2 , . .., C k } and EC is the set of (distinct) pairs of components resulting from step 4 as directed edges.