Component large screen automatic layout optimization method and system based on constraint genetic algorithm

By adopting a component-based automatic layout optimization method for large screens based on constraint genetic algorithms, the problems of low layout efficiency, complex constraint conflicts, and difficulty in multi-objective optimization in component-based large screen assembly are solved, achieving efficient and automated component layout that meets multi-dimensional constraints.

CN120911273APending Publication Date: 2025-11-07NANJING LES CYBERSECURITY & INFORMATION TECH RES INST CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511023141.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-24
Publication Date
2025-11-07

AI Technical Summary

Technical Problem

Existing technologies suffer from low layout efficiency, complex constraint conflicts, and difficulty in multi-objective optimization in modular large screen assembly. In particular, when the number of components exceeds 50, the time required for manual arrangement increases exponentially, and it is difficult to simultaneously meet the constraints of space, business logic, and specification indicators.

Method used

A component-based automatic layout optimization method for large screens based on constrained genetic algorithms is adopted. By constructing decision variables and constraints, optimization operations are performed using chromosome encoding and genetic operators, including selection, crossover, and mutation operators, to ensure automatic layout under multi-dimensional constraints.

Benefits of technology

It enables automated layout of large-scale components under complex business rules and specification requirements, improves layout efficiency, reduces manual arrangement time, meets constraints of space, business logic and specification requirements, and optimizes component distribution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120911273A_ABST
    Figure CN120911273A_ABST
Patent Text Reader

Abstract

The invention provides a modularized large screen automatic layout optimization method and system based on a constraint genetic algorithm. The method comprises the following steps: constructing decision variables and constraint conditions of modularized large screen layout optimization; encoding components in the large modularized screen to obtain different layout schemes corresponding to different chromosomes, and forming an initial layout group; performing optimization operation on each chromosome in the initial layout group by adopting a genetic operator to obtain a secondary layout group; and taking the secondary generation layout group as a new initial layout group, performing optimization operation again until a preset requirement is met, and outputting a final layout scheme. The system is used for implementing the method. The method is suitable for a visual platform in the fields of smart cities, industrial internet of things and the like, and solves the problem of automatic layout of large-scale components on the premise of meeting complex business rules and standard index requirements.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to a large screen automatic layout optimization method and system, in particular to a component-based large screen automatic layout optimization method and system based on a constraint genetic algorithm. BACKGROUND

[0002] The information provided in this section is merely background information related to the present disclosure and can not necessarily be prior art.

[0003] The current component-based large screen assembly mainly faces the following three technical bottlenecks:

[0004] First, the layout efficiency is low. When the number of components exceeds 50, the time-consuming of manual arrangement increases exponentially, and the empirical formula shows that:

[0005] T manual =0.15n 1.8 (unit: minutes)

[0006] Where n is the number of components, when n = 100, the layout time will exceed 9 hours.

[0007] Second, the constraint conflict is complex. Three types of constraints need to be met simultaneously: spatial constraints (no overlap, no out-of-boundary, etc.); business logic constraints (position locking, component association, etc.); specification index constraints (grid alignment, visual balance, etc.).

[0008] Third, multi-objective optimization is difficult. Conflict goals need to be balanced, including maximizing information density (ρ info ), minimizing position offset (Δ pos ), and balancing blank area distribution (σ blank ).

[0009] It should be noted that the information disclosed in the above background section is only used to strengthen the understanding of the background of the present disclosure, and therefore can include information that does not constitute prior art known to those of ordinary skill in the art. SUMMARY

[0010] The present application aims to solve the technical problems of the prior art and provides a component-based large screen automatic layout optimization method and system based on a constraint genetic algorithm.

[0011] In order to solve the above technical problems, a component-based large screen automatic layout optimization method and system based on a constraint genetic algorithm are disclosed, wherein the method comprises the following steps:

[0012] Step 1, constructing the decision variables and constraint conditions of the component-based large screen layout optimization;

[0013] Step 2, encode the components in the componentized large screen according to the decision variables and constraint conditions, to obtain different chromosomes corresponding to different layout schemes, and form an initial layout population;

[0014] Step 3, optimize each chromosome in the initial layout population using genetic operators to obtain a new layout scheme, i.e. a secondary generation layout population;

[0015] Step 4, take the secondary generation layout population as a new initial layout population, and re-execute step 3 until a preset requirement is reached, and output the final layout scheme.

[0016] Further, the decision variables and constraint conditions for constructing the componentized large screen layout optimization in step 1 include:

[0017] Step 1-1, define the decision variables as follows:

[0018]

[0019] where X is the decision variable of component layout, n is the total number of components, (x i ,y i ) represents the upper left corner coordinates of component i, (w i ,h i ) represents the width and height of component i;

[0020] Step 1-2, construct the constraint conditions, which are the dependent relationships that the decision variable X needs to follow from the space level, business logic level and specification index level.

[0021] Further, the construction of the constraint conditions in step 1-2 includes:

[0022] Step 1-2-1, spatial constraints, including non-overlapping constraints and boundary constraints; wherein,

[0023] Non-overlapping constraints, i.e. the intersection area of any two components is 0, are represented as follows:

[0024] Area(Rect i ∩Rect j )=0 (i≠j)

[0025] where Rect i represents component i, Rect j represents component j, and Area() represents an area calculation function;

[0026] Boundary constraints, i.e. components do not exceed the canvas range, are represented as follows:

[0027] 0≤x i ≤W-wi

[0028] 0≤y i ≤H-h i

[0029] wherein, W and H are the width and height of the canvas where the component is located;

[0030] Step 1-2-2, business logic constraints, including position locking constraints, size locking constraints and component association constraints, wherein the position locking constraints are to fix the specified component coordinates, the size locking constraints are to fix the specified component size, and the component association constraints are to specify the adjacent components of strong association;

[0031] Step 1-2-3, specification index constraints, including minimum size constraints, grid alignment constraints and aspect ratio protection constraints; wherein,

[0032] The minimum size constraint is to limit the minimum size of the component, which is expressed as follows:

[0033] w i ≥w min

[0034] h i ≥h min

[0035] wherein, w min and h min represent the minimum width and height of the component;

[0036] The grid alignment constraint is to align the edges of the component with the preset grid lines;

[0037] The aspect ratio protection constraint is to set the aspect ratio range of the component, which is expressed as follows:

[0038]

[0039] wherein, r min represents the minimum value of the aspect ratio of the component, and r max represents the maximum value of the aspect ratio of the component.

[0040] Further, the encoding of the components in the componentized large screen in step 2 includes:

[0041] Step 2-1, using an extended coding scheme with business weight, the components in the componentized large screen are encoded, that is, the decision variables are encoded into a chromosome chain, which is expressed as follows:

[0042]

[0043] wherein, Chromosome is a chromosome chain, x n , yn ,w n ,h n ,λ n represents the gene of the nth component, the business weight factor λ n represents the importance level of the component;

[0044] Step 2-2, constructing a dynamic coding mechanism for dynamically coding the chromosome chain;

[0045] Step 2-3, according to the constraint rules, randomly dynamically coding the chromosome chain by using the dynamic coding mechanism to obtain different chromosome chains and form an initial layout population.

[0046] Further, the constructing a dynamic coding mechanism in step 2-2 comprises:

[0047] Step 2-2-1, constructing a dynamic mask variable according to the position locking constraint and the size locking constraint, and the dynamic mask variable represents as follows:

[0048]

[0049] wherein M is a mask variable matrix, represents the left top horizontal coordinate locking state of the nth component, represents the left top vertical coordinate locking state of the nth component, represents the width locking state of the nth component, represents the height locking state of the nth component;

[0050] whether the corresponding decision variable participates in optimization is controlled by the mask variable, then it represents that the decision variable located at the nth row and the hth column participates in optimization, represents a fixed value and does not participate in optimization, and the specific implementation is as follows:

[0051] when , the position parameter of the component n is locked and does not participate in optimization;

[0052] when , the size parameter of the component n is locked and only the position parameter participates in optimization;

[0053] Step 2-2-2, a grouping coding mechanism, according to the component association constraint, dividing the components with specified strong association into the same coding group, and optimizing the coding group in the subsequent optimization;

[0054] Step 2-2-3, an adaptive coding length mechanism, that is, when the number of components changes, the chromosome automatically adds or deletes a preset proportion of genes;

[0055] Further, the genetic operators in step 3, i.e. the selection operator, the crossover operator and the mutation operator; the optimization operation using the genetic operators comprises:

[0056] Step 3-1, the optimization operation using the selection operator, i.e. directional screening of the chromosomes based on the coding fitness;

[0057] Step 3-2, the optimization operation using the crossover operator, i.e. recombination of the chromosomes based on the grouping coding mechanism and the dynamic mask variable;

[0058] Step 3-3, the optimization operation using the mutation operator, i.e. fine-tuning of the chromosomes based on the weight and the adaptive coding length mechanism.

[0059] Further, the optimization operation using the selection operator in step 3-1 comprises:

[0060] Step 3-1-1, calculating the fitness of the chromosomes, in the following way:

[0061] fitness = a • Utilization + β • WeightScore - γ • ConstraintViolation

[0062] Wherein, a, β and γ represent the space utilization weight, the service score weight and the constraint violation penalty weight respectively; Utilization represents the space utilization, calculated in the following way:

[0063] (∑w i h i ) / (WH)

[0064] WeightScore represents the service weight score, calculated in the following way:

[0065] ∑λ i visibility i

[0066] Wherein, visibility i represents the visibility coefficient of component i;

[0067] ConstraintViolation represents the constraint violation penalty, including the out-of-bound penalty and the aspect ratio penalty;

[0068] Step 3-1-2, selecting according to the fitness of the chromosomes, and eliminating the chromosomes less than the threshold value.

[0069] Further, the optimization operation using the crossover operator in step 3-2 comprises:

[0070] Step 3-2-1, setting the crossover range, setting the range allowed to perform the crossover operation according to the mask variable matrix and the component association constraint;

[0071] Step 3-2-2, crossover operation, that is, for the component i with the service weight λ i , the offspring gene value after the crossover operation is generated by weighting the first parent gene and the second parent gene, and is expressed as follows:

[0072] g child,i =λ i *g parent1,i +(1-λ i )*g parent2,i

[0073] wherein g child,i represents the offspring gene, g parent1,i and g parent2,i represent the first parent gene and the second parent gene, respectively;

[0074] Step 3-2-3, constraint checking, repairing the offspring gene after the crossover operation according to the constraint condition set in step 1.

[0075] Further, the optimization operation using the mutation operator in step 3-3 includes:

[0076] Step 3-3-1, mutation object selection, selecting the gene with the service weight factor below the threshold value in the chromosome chain as the mutation object;

[0077] Step 3-3-2, mutation operation, randomly fine-tuning the position or size in the mutation object;

[0078] Step 3-3-3, constraint checking, repairing the offspring gene after the mutation operation according to the constraint condition set in step 1.

[0079] Further, the system includes:

[0080] a decision variable and constraint condition construction module, an encoding module, a fitness calculation module and an optimization module; wherein,

[0081] the decision variable and constraint condition construction module is used to construct the decision variable and constraint condition of the layout optimization of the componentized large screen;

[0082] the encoding module encodes the components in the componentized large screen to obtain the chromosomes corresponding to different layout schemes;

[0083] the fitness calculation module calculates the fitness of each chromosome according to the decision variable and constraint condition of the layout optimization;

[0084] An optimization module performs an optimization operation according to the fitness of each chromosome to obtain a new layout scheme.

[0085] Beneficial effects:

[0086] The component-based large-screen automatic layout optimization method and system based on the constraint genetic algorithm are particularly suitable for visual platforms in the fields of smart cities and industrial Internet of Things, and solve the problem of automatic layout of large-scale components (n>50) under the premise of meeting complex business rules and standard index requirements. BRIEF DESCRIPTION OF DRAWINGS

[0087] The above and / or other aspects of the present application will become more apparent by describing in detail the preferred embodiments thereof with reference to the attached drawings.

[0088] Figure 1 The automatic layout step based on the constraint genetic algorithm of the present application is shown in the schematic diagram.

[0089] Figure 2 The chromosome coding structure of the present application is shown in the schematic diagram.

[0090] Figure 3 The schematic diagram of one embodiment of the present application is shown. DETAILED DESCRIPTION

[0091] The overall technical solution of the present application is shown in the following figure, which includes the following parts: Figure 1

[0092] I. Multi-dimensional constraint modeling system

[0093] A constraint mechanism is constructed from three dimensions of space, business logic and standard index (for example, aesthetic index), and the dependency relationship between decision variables and constraints is determined:

[0094] 1. Decision variable definition

[0095] In the problem of component-based large-screen automatic layout, the decision variable needs to accurately describe the following key elements: position information (the accurate coordinates of each component on the canvas), size information (the width and height of each component), layout state (the relative position relationship between components), and constraint satisfaction degree (the ability to meet various constraint conditions). The basic decision variable is defined by a matrix as follows:

[0096]

[0097] Or

[0098]

[0099] Wherein, n is the total number of components, (x i ,y i ​) represents the upper-left coordinate of component i (unit: pixel), (w i ,h i ) represents the width and height of component i (unit: pixel).

[0100] 2. Constraint mechanism

[0101] The system requires the decision variables to follow the following dependency relationships from the aspects of space, business logic, and specification index:

[0102] (1) Spatial constraint

[0103] Non-overlapping constraint: the intersection area of any two components is 0, i.e.,

[0104] Area(Rect i ∩Rect j )=0(i≠j)

[0105] where Rect i represents component i, Rect j represents component j, and Area() represents the area calculation function;

[0106] Boundary constraint: the component does not exceed the canvas range, i.e.,

[0107] 0≤x i ≤W-w i

[0108] 0≤y i ≤H-h i

[0109] where W and H are the width and height of the canvas where the component is located;

[0110] (2) Business logic constraint

[0111] Position locking: specify that the component coordinates are fixed (such as key monitoring components);

[0112] Component association: strongly associated components need to be adjacent (such as "traffic flow" and "road network status" components).

[0113] (3) Specification index constraint

[0114] Minimum size constraint: limit the minimum size of the component, i.e.,

[0115] w i ≥w min ,h i ≥h min

[0116] where w min and h min represent the minimum width and height of the component

[0117] Grid alignment constraint: component edges are aligned with preset grid lines;

[0118] Aspect ratio protection constraint: component aspect ratio is kept within a reasonable range, i.e.,

[0119]

[0120] where r min represents the minimum value of the component aspect ratio, r max represents the maximum value of the component aspect ratio.

[0121] II. Chromosome coding mechanism with business weight

[0122] By gene structure design and dynamic coding technology, component attributes and constraints are embedded in genetic algorithm coding to ensure that the optimization process meets business needs.

[0123] 1. Gene structure design

[0124] In the genetic algorithm, the present application adopts an extended coding scheme with business weight. The following is a chromosome chain Chromosome carrying a weight factor λ Figure 2 as shown in:

[0125]

[0126] where the business weight factor λ i ∈ [0, 1] (normalized value), represents the importance level of the component, which can be defined as:

[0127]

[0128] 2. Dynamic coding mechanism

[0129] Dynamic coding includes mask technology, grouping coding and adaptive coding length mechanism. The three mechanisms work together: mask technology ensures that constraints are not broken, grouping coding ensures that associations are not broken, and adaptive coding length realizes dynamic adaptation of scale, together building a dynamic coding system with constraint compatibility and scene flexibility.

[0130] (1) Mask technology

[0131] Mask technology controls the "activation / locking" of decision variables through binary mask variable M (dimension 4n, n is the total number of components). The core function is to directly embed "fixed constraints" (such as position locking, size locking) in the coding process to avoid breaking key constraints during genetic operations.

[0132] Dynamic mask variable definition:

[0133]

[0134] where, represents the left-top x-coordinate lock state of the nth component, represents the left-top y-coordinate lock state of the nth component, represents the width lock state of the nth component, represents the height lock state of the nth component.

[0135] Mask variables can control whether variables participate in optimization:

[0136]

[0137] where, represents any element in the mask variable matrix;

[0138] When , the position parameter of component n is locked and does not participate in genetic optimization (corresponding to the "position locking mechanism" in the business logic constraint);

[0139] When , the size parameter of component n is locked, and only the position can be adjusted (applicable to business components with fixed size, such as map components);

[0140] When , the corresponding parameter (position or size) participates in the crossover and mutation operations of the genetic algorithm, maintaining optimization flexibility.

[0141] (2) Group Encoding

[0142] Group encoding divides strongly associated components into the same encoding group for "component association constraints" (such as "traffic flow" and "road network status" components in smart cities that need to be displayed adjacently), and genetic operations such as crossover and mutation are only performed at the "overall level" within or between groups, ensuring that the association relationship is not destroyed in genetic operations.

[0143] (3) Adaptive Encoding Length

[0144] The adaptive encoding length mechanism realizes real-time matching of chromosome length and component scale for scenarios where the number of components changes dynamically (such as adding or deleting components), solving the problem of "redundancy or deficiency" in fixed encoding length in dynamic layout.

[0145] When the number of components changes (such as adding k components), the chromosome automatically appends 4k (or 5k) gene segments (corresponding to the position, size, and weight of the added components); if k components are deleted, the corresponding gene segments are automatically removed, keeping the encoding structure compact.

[0146] Three, Adaptive Genetic Optimization Engine

[0147] The core function of the adaptive genetic optimization engine is to achieve population iterative evolution through genetic operations based on the constructed multi-dimensional constraint model and chromosome coding system, and finally output the optimal layout scheme that meets the constraint conditions. It should be noted that all genetic operations are based on chromosome coding as the operation object, and strictly follow the constraint rules. The specific processing flow is as follows:

[0148] 1. Cooperative operation of constraint processing mechanism and coding

[0149] The constraint processing mechanism is essentially a "directional repair" based on coding information, that is, using gene information such as mask, grouping, and business weight in chromosome coding to accurately identify the object to be repaired and the repair priority, avoiding blind adjustment that damages the core constraints.

[0150] (1) Linkage logic of hierarchical repair and coding

[0151] The execution of the hierarchical repair strategy needs to take chromosome coding as the basic data source:

[0152] Spatial constraint repair: preferentially read the mask matrix M in the coding to identify the locked components and the optimizable components In one embodiment, for map components with position and size locks, configure When repairing, directly skip the adjustment of their position and size genes, and only operate on the genes of the optimizable components, ensuring that the business lock constraints are not violated.

[0153] Business constraint repair: based on grouping coding information, repair all components in the strongly associated group when one component in the group is out of bounds, triggering the coordinated translation of all components in the group to avoid the association relationship being broken by individual repair. In one embodiment, there is a "traffic flow-road network state" group, when the position of the traffic flow component changes, the road network state components will be translated by the same pixel size to maintain the relative position unchanged.

[0154] Standard index constraint repair: combined with the business weight gene λ i , preferentially adjust the position / size of low-weight components (λ i = 0.2) to meet the grid alignment, visual balance, and other standard indexes, reducing the interference with high-weight components (λ i = 0.8).

[0155] (2) Coding-driven logic of overlap repair algorithm

[0156] The overlap repair algorithm calculates the adjustment amount based on the gene values in the chromosome coding, and the specific flow is as follows:

[0157] Overlap determination condition: traverse all chromosomes in the population, if the following four conditions are satisfied simultaneously according to the position genes (x n ,y n ) and size genes (w n ,h n ) in the encoding, then it is determined that components i and j have an overlap, triggering overlap repair:

[0158] x i +w i >x j

[0159] x j +w j >x i

[0160] y i +h i >y j

[0161] y j +h j >y i

[0162] Translation amount calculation: based on the position genes and size genes in the encoding, calculate the translation vectors Δx, Δy:

[0163] 1) Calculate the relative translation vector:

[0164] Since the goal is to have no overlapping area between components, then translate one component to the side of the other component. Since translating component i to the left of component j is different from translating component j to the right of component i only in the opposite direction of translation, the modulus is equal, so fixing the position of component j can get the relative translation vector of component i, there are the following cases:

[0165] Translate component i to the left of component j: (Δx temp ,Δy temp ) = -(x i +w i -x j ,0)

[0166] Translate component i to the right of component j: (Δx temp ,Δy temp ) = (x j +w j -x i ,0)

[0167] Translate component i to the top of component j: (Δx temp ,Δy temp ) = -(0,y i +h i -yj )

[0168] Translate component i to the underside of component j: (Δx temp ,Δy temp ) = (0,y j +h j -y i )

[0169] To meet the purpose of minimizing translation to eliminate overlap, it is stipulated to move in the direction of smaller overlap, so the vector with the smallest modulus in the above four cases is the final relative translation vector.

[0170] 2) Weight correction vector:

[0171] Weight correction is associated with the service weight gene λ i ,λ j in the chromosome code, which ensures that components with high weight

[0172] have smaller translation. In an embodiment, the weight correction vector is defined as:

[0173]

[0174] where λ is larger, the weight correction vector is smaller, and always holds, thereby ensuring that component translation eliminates overlap and the stability of the position of key components (high λ value).

[0175] 3) Mask correction parameter:

[0176] Mask correction is associated with the mask variable M, and when an element in the mask variable is 0, the weight correction is ignored. There are 16 cases in total, and the corrected weight vector is shown in Table 1:

[0177] Table 1 Corrected weight vector table

[0178]

[0179] 4) Calculate translation:

[0180] Combining the relative translation vector and the weight correction vector after mask correction, the final result is:

[0181] Translation vector of component i:

[0182]

[0183] Translation vector of component j:

[0184]

[0185] Where the unit vector determines the direction, and the weight decides the distribution proportion of the moving distance between components.

[0186] 5) Encoding update: after the above overlap repair is completed, directly update the position gene of the corresponding component in the chromosome encoding (x n ,y n ).

[0187] In one embodiment, the chromosome gene of component i is [5, 1, 2, 2, 0.2], and the position mask The chromosome gene of component j is [1, 0, 6, 4, 0.8], and the position mask As shown in 3.

[0188] First, judge whether the two components have overlapping areas, and the four judgments all meet the conditions:

[0189] x i +w i =7>x j =1

[0190] x j +w j =7>x i =5

[0191] y i +h i =3>y j =0

[0192] y j +h j =4>y i =1

[0193] Relative translation vector:

[0194] Translate component i to the left of component j: (Δx temp ,Δy temp )=(-6,0)

[0195] Translate component i to the right of component j: (Δx temp ,Δy temp )=(2,0)

[0196] Translate component i to the top of component j: (Δx temp ,Δy temp )=(0,-3)

[0197] Translate component i to the bottom of component j: (Δx temp ,Δy temp )=(0,3)

[0198] Where the modulus of the vector of translating component i to the right of component j should be the smallest, and the relative translation vector is obtained:

[0199] (Δx temp ,Δy temp )=(2,0)

[0200] Weight and mask correction:

[0201] Weight and mask correction of component i:

[0202]

[0203] Weight and mask correction of component j:

[0204]

[0205] The translation amount at this time should be:

[0206] Translation vector of component i:

[0207]

[0208] Translation vector of component j:

[0209]

[0210] Chromosome gene after translation:

[0211] Chromosome gene of component i:

[0212] [5,1,2,2,0.2]=>[6.6,1,2,2,0.2]

[0213] Chromosome gene of component j:

[0214] [1,0,6,4,0.8]=>[0.6,0,6,4,0.8]

[0215] At this time

[0216] x j +w j =x i =6.6

[0217] Does not meet the overlap determination condition, and the overlap repair ends.

[0218] (3) Boundary repair and the closed-loop logic of encoding

[0219] Boundary repair needs to be combined with the size gene in encoding and the canvas parameters (W, H) to achieve accurate correction:

[0220] 1) When component i is out of bounds, calculate the corrected position gene according to the size gene (w i ,h i ) in encoding:

[0221] Left-overshoot: x i = 0 (align component left edge to canvas left border)

[0222] Right-overshoot: x i = W-w i (align component right edge to canvas right border)

[0223] Top-overshoot: y i = 0 (align component top edge to canvas top border)

[0224] Bottom-overshoot: y i = H-h i (align component bottom edge to canvas bottom border)

[0225] 2) If a new overlap is triggered after the repair, for example, component i overlaps with component k after being pulled back to the boundary in one embodiment, read the grouping code first: if component i and component k belong to the same associated group, trigger the overall translation within the group; if they belong to different groups, repeat the overlap repair process, forming a closed loop of "boundary repair-overlap detection-code update".

[0226] 3) If the chromosome code after repair is consistent with a certain code in the population, no additional processing is needed, avoiding the program from falling into an infinite loop.

[0227] 2. Directional iteration of genetic operators on coding

[0228] Genetic operators (selection, crossover, mutation) all take chromosome coding as the operation unit, and strictly follow the dynamic constraint rules in the coding (mask locking, grouping association, adaptive length), ensuring that the evolution process does not deviate from the constraint framework.

[0229] (1) Selection operator: directional screening based on coding fitness

[0230] The selection operator retains high fitness chromosomes through the "elite reservation mechanism", while the calculation of fitness directly depends on the gene information in the coding, and the fitness function is calculated as follows:

[0231] fitness = a • Utilization + β • WeightSscore - γ • ConstraintViolation

[0232] Where a, β, γ represent the space utilization weight, the service score weight, and the constraint violation penalty weight, respectively, which have obvious differences in different service scenarios, and the value examples are shown in Table 2:

[0233] Table 2 Weight value table

[0234] Scenario type α β Gamma Monitor large screen 0.4 0.3 (0.4+0.3)*10 Report large screen 0.2 0.5 (0.2+0.5)*10 Emergency command large screen 0.3 0.4 (0.3+0.4)*10

[0235] Utilization represents the space utilization rate: (∑w i h i ) / (WH).

[0236] WeightScore represents the business weight score:

[0237] ∑λ i visbility i

[0238] Where, visibility i represents the visibility coefficient of component i, and is calculated as follows:

[0239] (Proportion of component area to canvas area)

[0240]

[0241] ConstraintViolation represents the constraint violation penalty: such as high penalty for out-of-boundary behavior based on location genes, and whether the aspect ratio is compliant based on size genes:

[0242] Out-of-boundary penalty:

[0243] BoundaryPenalty i = k boundary *(Δx over +Δy over )

[0244] Where:

[0245] x-axis out-of-boundary distance: Δx overr = max(0,x i +w i -W)+max(0,-x i )

[0246] y-axis out-of-boundary distance: Δy over = max(0,y i +h i -H)+max(0,-y i )

[0247] Out-of-boundary penalty coefficient: k boundary > 1

[0248] Aspect ratio penalty:

[0249] If the aspect ratio requirement is met, then:

[0250] AspectRatioPenalty i = 0

[0251] Otherwise:

[0252] AspectRatioPenalty i = k aspect >>1

[0253] The constraint violation penalty is the sum of all component penalties:

[0254]

[0255] where n is the number of components and i represents the ith component.

[0256] During selection, chromosomes with "low constraint violation + high traffic weight score" in the encoding are preferentially retained, and chromosomes with low or even negative fitness are removed to ensure that high-quality genes are passed on to offspring. Therefore, γ needs to be much larger than α and β to ensure that solutions that violate constraints are strongly eliminated. For example, in one embodiment:

[0257] γ≥10*(α+β)

[0258] (2) Crossover operator: secure recombination based on grouping and masking

[0259] The crossover operator is used to realize the recombination of chromosome genes to produce offspring with the advantages of the parents. In the present application, its operation strictly follows the grouping association and masking locking rules in the encoding, as follows.

[0260] Crossover range: crossover is only performed on the optimizable genes (genes in the masking matrix M) in the chromosome, and the genes in the same associated group participate in the crossover as a whole to avoid splitting strongly associated components.

[0261] Operation steps: for component i with traffic weight λ i , the offspring gene value is generated by weighting the corresponding genes of parent 1 and parent 2:

[0262] g child,i = λ i *g paren,i +(1-λ i )*g parent2,i

[0263] where g represents the optimizable gene (such as position x i , y i or size w i , h i );

[0264] λ i ∈[0,1] is the traffic weight of component i (the higher the value, the closer the offspring gene is to the high-quality gene of parent 1); ​

[0265] g paren,i ,g parent2,i are the corresponding gene values of component i in parent 1 and parent 2 respectively.

[0266] In an embodiment of the present application, take the "traffic flow (A)-road network status (B)" association group as an example (λ A = 0.8, λ B = 0.7, both are high-weight components, position can be optimized, size is locked):

[0267] Parent genes (only show the position genes x, y that can be optimized):

[0268] Parent 1: A (100, 200), B (420, 200)

[0269] Parent 2: A (150, 220), B (480, 220)

[0270] Crossing range: A and B belong to the same group, and the whole participates in crossing; because the size gene is locked (mask is 0), only the position gene is recombined.

[0271] Crossing calculation: high-weight components use weighted crossing (weight is the weight of itself λ):

[0272] x = λ A * A1 + (1 - λ A ) * A2 = 110

[0273] y = λ A * A1 + (1 - λ A ) * A2 = 204

[0274] Child position of A:

[0275] x = 0.8 * 100 + 0.2 * 150 = 110

[0276] y = 0.8 * 200 + 0.2 * 220 = 204

[0277] Child position of B:

[0278] x = 0.7 * 420 + 0.3 * 480 = 438

[0279] y = 0.7 * 200 + 0.3 * 220 = 206

[0280] Result: in the child gene, A (110, 204), B (438, 206), not only the association relationship of the parent is preserved, but also the position is optimized through recombination, and the locking constraint is not violated.

[0281] Constraint verification: If component overlap or out-of-bounds occurs after crossover, a repair mechanism will be triggered to ensure that the offspring genes meet all constraints.

[0282] (3) Mutation operator: Fine-tuning based on weights and adaptive coding

[0283] The mutation operator performs random fine-tuning on the encoded position and size genes, and ensures the effectiveness of the mutation through "weight priority + constraint verification":

[0284] Mutation target selection: Prioritize gene components with low business weight in the encoding, and fine-tune their position genes or size genes (such as λ in chromosome encoding). i x of the component = 0.2 i Randomly add or remove 5-10 pixels); for high-weight components, only make small variations when the constraint satisfaction is extremely low (such as in chromosome encoding λ). i x of the component = 0.8 i Randomly increase or decrease by 1-2 pixels).

[0285] Post-mutation constraint verification: Immediately after mutation, the constraints of the chromosome in terms of space, business logic, and normative indicators are verified and repaired to ensure the validity of the mutated individual.

[0286] 3. Dynamic coordination between multi-objective optimization and coding

[0287] The core of multi-objective optimization is to guide the population to evolve towards "high constraint satisfaction + excellent business adaptability" through a fitness function, and this process relies entirely on the dynamic adjustment of the coding genes:

[0288] (1) Dynamic Coordination of Fitness Function and Encoding

[0289] When space utilization needs to be improved, the α (space utilization weight) in the fitness function is increased, and the algorithm will preferentially mutate the size gene (w) of low-weight components in the encoding. i ,h i ), increasing the area (e.g., w) while meeting minimum size constraints. i (Increased from 100px to 120px), while recombinating gene fragments with high utilization layout through crossover operators.

[0290] When key components need to be highlighted, β (business weight score weight) is increased, and the algorithm will adjust the position gene (x) of high λ-value components through mutation operators. i ,y i This moves it towards the center area (improving visibility). i ), while locking its size gene (through masking) Avoid compression.

[0291] In practice, it is found that the design of the genetic algorithm function directly determines the functionality (whether the constraints are met) and commercial value (whether the key data is prominently displayed) of the final layout. In practice, the weight coefficients (α, β, γ) in the formula need to be repeatedly calibrated through A / B testing to achieve the most suitable situation for the business scenario.

[0292] (2) Genetic algorithm termination condition and solution set output

[0293] The termination condition is the "end point determination criterion" of the genetic algorithm iteration process, used to balance optimization quality and efficiency, as follows:

[0294] 1) Maximum iteration termination: configure the maximum number of iterations, and stop iteration after reaching the maximum number of iterations;

[0295] 2) Convergence termination: if the continuous 10 generations improvement is <1%, it is considered as the optimal solution;

[0296] 3) Optimal solution termination: find a zero-penalty solution and space utilization >95%.

[0297] After the algorithm triggers the termination condition (such as reaching the maximum number of iterations or convergence), the system extracts all non-dominated solutions from the current population, forms a Pareto solution set and outputs, providing users with multiple options for selection; if the "optimal solution termination" is triggered, the Pareto solution set can be simplified to the optimal solution. Users can select an initial layout from the Pareto solution set and fine-tune it through drag-and-drop, locking, and other operations.

[0298] (3) Correspondence between Pareto solution set and encoding

[0299] The Pareto solution set output by the algorithm termination is essentially a set of "different constraint satisfaction degrees + different business priorities" chromosome encodings:

[0300] Each solution corresponds to a chromosome encoding, which contains complete position genes (x i ,y i ), size genes (w i ,h i ), business weight genes (λ i ), and mask information (M).

[0301] After the user selects a solution, the system can directly generate a layout based on the gene values in the encoding (such as positioning components according to x i ,y i , setting size according to w i ,h i , and marking key components according to λ i ), and supports fine-tuning based on the encoding (such as real-time updating of corresponding position genes after drag-and-drop adjustment, and updating the mask M synchronously with the locking operation).

[0302] In specific implementations, the present application provides a computer storage medium and a corresponding data processing unit, wherein the computer storage medium can store a computer program, and the computer program can run the invention content of a component-based large-screen automatic layout optimization method and system based on a constraint genetic algorithm and some or all steps in each embodiment when executed by the data processing unit. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), or the like.

[0303] Those skilled in the art can clearly understand that the technical solutions in the embodiments of the present application can be realized by means of a computer program and its corresponding general hardware platform. Based on such understanding, the technical solutions in the embodiments of the present application can be embodied in the form of a computer program, i.e., a software product, which can be stored in a storage medium and includes a plurality of instructions for causing a device (which can be a personal computer, a server, a single-chip microcomputer, an MCU, or a network device) containing a data processing unit to execute the method described in each embodiment or some parts of the embodiments of the present application.

[0304] The present application provides a component-based large-screen automatic layout optimization method and system based on a constraint genetic algorithm, and there are many methods and approaches to realize the technical solutions. The above description is only the preferred embodiment of the present application, and it should be pointed out that for ordinary skilled persons in the technical field, some improvements and refinements can be made without departing from the principles of the present application, and these improvements and refinements should also be considered as the protection scope of the present application. The components not explicitly described in the embodiments can be realized by using existing technology.

Claims

1. A component-based large-screen automatic layout optimization method based on a constraint genetic algorithm, characterized in that, The method comprises the following steps: Step 1, constructing the decision variables and constraint conditions of the componentized large-screen layout optimization; Step 2, encoding the components in the componentized large screen according to the decision variables and constraint conditions to obtain different chromosomes corresponding to different layout schemes and form an initial layout population; Step 3, optimizing each chromosome in the initial layout population by using genetic operators to obtain a new layout scheme, i.e. a secondary generation layout population; Step 4, taking the secondary generation layout population as a new initial layout population to re-execute step 3 until a preset requirement is reached, and outputting a final layout scheme.

2. The component-based automatic layout optimization method based on the constraint genetic algorithm according to claim 1, characterized in that, The step 1 of constructing the decision variables and constraint conditions of the componentized large-screen layout optimization comprises: Step 1-1, defining the decision variables, specifically as follows: where X is the decision variable of component layout, n is the total number of components, (x i ,y i ) represents the upper left corner coordinates of component i, (w i ,h i ) represents the width and height of component i; Step 1-2, constructing constraint conditions, i.e. dependency relationships required to be followed by the decision variables X from the spatial level, the business logic level and the specification index level.

3. The component-based automatic layout optimization method based on the constrained genetic algorithm according to claim 2, characterized in that, The step 1-2 of constructing constraint conditions comprises: Step 1-2-1, spatial constraints, including non-overlapping constraints and boundary constraints; wherein, The non-overlapping constraint is that the intersection area of any two components is 0, which is represented as follows: Area(Rect i ∩Rect j ) = 0 (i≠j) where Rect i represents component i, Rect j represents component j, and Area() represents an area calculation function. The boundary constraint is that the component does not exceed the canvas range, which is represented as follows: 0 < x i ≤ W - w i 0 < y i ≤ H - h i Wherein, W and H are the width and height of the canvas where the component is located; Step 1-2-2, business logic constraints, including position locking constraints, size locking constraints and component association constraints, wherein the position locking constraint is to fix the coordinates of a specified component, the size locking constraint is to fix the size of a specified component, and the component association constraint is to specify that strongly associated components are adjacent; Step 1-2-3, specification index constraints, including minimum size constraints, grid alignment constraints and aspect ratio protection constraints; wherein, The minimum size constraint is to limit the minimum size of the component, which is represented as follows: w i ≥w min h i ≥h min where w min and h min represent the minimum width and height of the component; The grid alignment constraint is to align the edges of the component with the preset grid lines; The aspect ratio protection constraint is to set the aspect ratio range of the component, which is represented as follows: wherein r min represents the minimum component aspect ratio, r max represents the maximum component aspect ratio.

4. The component-based automatic layout optimization method based on the constrained genetic algorithm according to claim 3, characterized in that, The step 2 of encoding the components in the componentized large screen comprises: Step 2-1, using an extended coding scheme with business weight to encode the components in the componentized large screen, i.e. encoding the decision variables into a chromosome chain, which is represented as follows: where Chromosome is a chromosome chain, x n ,y n ,w n ,h n ,λ n represents the gene of the nth component, the business weight factor λ n represents the importance level of the component; Step 2-2, constructing a dynamic coding mechanism for dynamically coding the chromosome chain; Step 2-3, randomly dynamically coding the chromosome chain by using the dynamic coding mechanism according to the constraint rules to obtain different chromosome chains and form an initial layout population.

5. The component-based automatic layout optimization method based on the constrained genetic algorithm according to claim 4, characterized in that, The step 2-2 of constructing a dynamic coding mechanism comprises: Step 2-2-1, constructing a dynamic mask variable according to the position locking constraint and the size locking constraint, which is represented as follows: wherein M is a mask variable matrix, represents a left top horizontal coordinate lock state of the nth component, represents a left top vertical coordinate lock state of the nth component, represents a width lock state of the nth component, represents a height lock state of the nth component; whether the corresponding decision variable participates in optimization is controlled by a mask variable, indicates that the decision variable located at the nth row and the hth column participates in optimization, indicates that the decision variable is a fixed value and does not participate in optimization, and the specific implementation is as follows: When the position parameter of component n is locked and does not participate in optimization. When the size parameter of component n is locked, only the position parameter participates in the optimization; Step 2-2-2, a grouping coding mechanism, which divides specified strongly associated components into the same coding group according to the component association constraint, and optimizes the coding group in subsequent optimization; Step 2-2-3, an adaptive coding length mechanism, i.e. when the number of components changes, the chromosome automatically adds or deletes a preset proportion of genes.

6. The component-based automatic layout optimization method based on the constrained genetic algorithm according to claim 5, characterized in that, The genetic operators in step 3, namely the selection operator, the crossover operator and the mutation operator; the optimization operation using the genetic operators comprises: Step 3-1, the optimization operation using the selection operator, that is, directional screening of the chromosome based on the coding fitness; Step 3-2, the optimization operation using the crossover operator, that is, recombination of the chromosome based on the grouping coding mechanism and the dynamic mask variable; Step 3-3, the optimization operation using the mutation operator, that is, fine tuning of the chromosome based on the weight and the adaptive coding length mechanism.

7. The component-based automatic layout optimization method based on the constrained genetic algorithm according to claim 6, characterized in that, The optimization operation using the selection operator in step 3-1 comprises: Step 3-1-1, calculating the fitness of the chromosome, the method being as follows: fitness = a·Utilization + β·WeightScore - γ·ConstraintViolation Wherein, a, β and γ respectively represent the space utilization weight, the service score weight and the constraint violation penalty weight; Utilization represents the space utilization, the calculation method being as follows: (∑w i h i ) / (WH) WeightScore represents the service weight score, the calculation method being as follows: ∑λ i visibility i wherein visibility i represents the visibility coefficient of component i; ConstraintViolation represents the constraint violation penalty, including the boundary violation penalty and the aspect ratio penalty; Step 3-1-2, selecting according to the fitness of the chromosome, and removing the chromosome less than the threshold value.

8. The component-based automatic layout optimization method based on the constrained genetic algorithm according to claim 7, characterized in that, The optimization operation using the crossover operator in step 3-2 comprises: Step 3-2-1, setting the crossover range, and setting the range allowed to perform the crossover operation according to the mask variable matrix and the component association constraint; Step 3 - 2 - 2, cross operation, i.e. for a component i with service weight λ i The offspring gene value after cross operation is generated by weighting the first parent gene and the second parent gene, which is expressed as follows: g child,i = λ i *g parent1,i +(1-λ i )*g parent2,i wherein g child,i represents a child gene, g parent1,i and g parent2,i represent a first parent gene and a second parent gene, respectively; Step 3-2-3, constraint verification, repairing the child gene after the crossover operation according to the constraint conditions set in step 1.

9. The component-based automatic layout optimization method based on the constrained genetic algorithm according to claim 8, characterized in that, The optimization operation using the mutation operator in step 3-3 comprises: Step 3-3-1, mutation object selection, selecting the gene with the service weight factor lower than the threshold value in the chromosome chain as the mutation object; Step 3-3-2, mutation operation, randomly fine tuning the position or size of the mutation object; Step 3-3-3, constraint verification, repairing the child gene after the mutation operation according to the constraint conditions set in step 1.

10. A component-based large-screen automatic layout optimization system based on a constrained genetic algorithm, used to implement the method of any one of claims 1-9, characterized in that, Comprise: The decision variable and constraint condition construction module, the coding module, the fitness calculation module and the optimization module; wherein, The decision variable and constraint condition construction module is used to construct the decision variable and constraint condition of the layout optimization of the componentized large screen; The coding module encodes the components in the componentized large screen to obtain the chromosome corresponding to different layout schemes; The fitness calculation module calculates the fitness of each chromosome according to the decision variable and constraint condition of the layout optimization; The optimization module performs optimization operation according to the fitness of each chromosome to obtain a new layout scheme.

Citation Information

Cited By

  • Public service facility construction evaluation and site selection decision-making method and system based on community life circle

    CN121581444A