Skip to content

About

A Multi-Objective Optimization Method for UI Interfaces Integrating NSGA-II and Simulated Annealing

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

13 Commits

Folders and files

Repository files navigation

Multi-Objective UI Layout Optimization System

Companion code for the paper A Multi-Objective Optimization Method for UI Interfaces Integrating NSGA-II and Simulated Annealing (reorganized version).

By default, the system uses the SNSGA-II hybrid algorithm, which combines the Non-Dominated Sorting Genetic Algorithm II (NSGA-II) with simulated annealing (SA). Fuzzy metric guidance constructs a shared dynamic search-objective context for each generation. The recommended layout, termination criteria, and exported scores use the fixed scoring model.

Installation and Usage

Python 3.10+ and NumPy 2.2.6 are required. Run the following commands in PowerShell from the source directory. The virtual environment and output directory are located outside the source directory:

py -3.10 -m venv ..\ui-layout-env
& '..\ui-layout-env\Scripts\python.exe' -m pip install -r .\requirements.txt
& '..\ui-layout-env\Scripts\python.exe' .\run_optimization.py --input '..\layout.json' --coordinate-space absolute --output-dir '..\results'

--input, --coordinate-space, and --output-dir are required. The input file must already exist. The output directory must be located outside the source directory, and each run creates a separate subdirectory. --coordinate-space accepts either absolute or parent-relative. Use --help to view all available options.

The system supports a flat elements array, as well as layout trees rooted at root_element, view_hierarchy, or activity.root. Geometry may be represented using position/size, bounds, or x/y/width/height. Child nodes are provided through a children array. Canvas dimensions may be included in the input; otherwise, they are inferred from the layout geometry, and the CLI records whether they were explicitly provided or inferred. --repair-parents repairs parent relationships for a flat elements input in absolute coordinates before the search begins.

Python API

import json
from pathlib import Path

from utils.layout_document import LayoutDocument
from utils.optimization_config import OptimizationConfig
from utils.optimization_process import OptimizationProcess

data = json.loads(Path("/path/to/layout.json").read_text(encoding="utf-8"))
document = LayoutDocument.from_dict(data, "absolute")
config = OptimizationConfig(population_size=100, generations=50, seed=42)
result = OptimizationProcess(config).optimize_document(document)
recommended = result.layout.to_dict()

optimize_document returns an OptimizationResult containing the recommended layout, initial and final scores, optimization history, Pareto solution candidates, and search statistics. It does not write files or modify the input object. Configuration is managed centrally through OptimizationConfig and can be serialized using to_dict().

Modules

Responsibility Entry Points
CLI, export, and reload validation run_optimization.py
Input processing, layout trees, and constraints layout_preparation.py, layout_document.py
API workflow and configuration optimization_process.py, optimization_config.py
Scoring, geometric metrics, and fixed factor-to-metric mapping layout_scoring.py, paper_corrected_metrics.py, paper_score_model.py
External factor models and dynamic search objectives search_inputs.py, search_objectives.py
Geometry and color metrics paper_geometry_metrics.py, color_metrics.py
Search, simulated annealing, adaptive policies, and metric-based neighborhoods hnsga2.py, annealing.py, search_policy.py, metric_neighborhood.py
Improvement thresholds, stagnation detection, and generation limit termination.py
Metric guidance, alignment, and Pareto archive metric_guidance.py, layout_alignment.py, hard_alignment.py, pareto_archive.py

About

A Multi-Objective Optimization Method for UI Interfaces Integrating NSGA-II and Simulated Annealing

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages