🌐 EN | 🇯🇵 JP

Chapter 2: NIMO Architecture

Understanding the Modular Design

📖 Reading Time: 20-25 minutes 📊 Difficulty: Beginner 💻 Code Examples: 5 📝 Exercises: 2

Learning Objectives

2.1 The Three-Layer Architecture

NIMO is designed with a clean separation of concerns into three main layers. This modular approach allows researchers to mix and match different AI algorithms with various robotic systems.

graph TB subgraph Layer1[Layer 1: AI Optimization] AI1[PHYSBO
Bayesian Opt] AI2[BLOX
Random Forest] AI3[PDC
Phase Diagram] AI4[RE
Random] AI5[... 7 more] end subgraph Layer2[Layer 2: Robot Interface] R1[STAN
Standard] R2[NAREE
Electrochemistry] R3[COMBAT
Custom] end subgraph Layer3[Layer 3: Visualization] V1[History Plot] V2[Distribution] V3[Phase Diagram] end Layer1 -->|CSV| Layer2 Layer2 -->|CSV| Layer1 Layer1 --> Layer3 Layer2 --> Layer3 style Layer1 fill:#667eea,color:#fff style Layer2 fill:#11998e,color:#fff style Layer3 fill:#f093fb,color:#fff

Modular Architecture

A software design approach where the system is divided into independent, interchangeable modules. Each module has a well-defined interface, allowing components to be replaced or upgraded without affecting others.

Layer 1: AI Optimization Module

This layer contains 11 different algorithms for selecting the next experiment candidates:

Algorithm Full Name Best For
RE Random Exploration Initial data collection
PHYSBO Bayesian Optimization General optimization (recommended)
BLOX Random Forest High-dimensional spaces
PDC Phase Diagram Construction Multi-phase materials
SLESA Single-Loop Efficient Selection Fast exploration
PTR Pareto-based Thompson Ranking Multi-objective optimization
BOMP Bayesian Opt. Multi-Phase Complex phase diagrams
ES Evolutionary Strategy Global optimization
COMBI Combination Search Discrete combinations
RSVM Ranking SVM Preference learning
WAM Weighted Average Model Ensemble predictions

Layer 2: Robot Interface Module

This layer handles communication with physical robotic systems:

Layer 3: Visualization Module

This layer provides tools for monitoring and analyzing optimization progress:

2.2 CSV-Based Data Flow

NIMO uses CSV files as the universal interface between all components. This design choice provides several benefits:

graph LR A[candidates.csv] -->|selection| B[proposals.csv] B -->|preparation_input| C[robot_input.csv] C -->|Robot Execution| D[robot_output.csv] D -->|analysis_output| E[updated_candidates.csv] E -->|Next Cycle| A style A fill:#f8f9fa style B fill:#667eea,color:#fff style C fill:#11998e,color:#fff style D fill:#f093fb,color:#fff style E fill:#28a745,color:#fff

CSV File Format

All CSV files in NIMO follow a consistent format:

Example: candidates.csv
x1,x2,x3,objective
0.1,0.5,0.4,NaN
0.2,0.4,0.4,NaN
0.3,0.3,0.4,1.25
0.4,0.2,0.4,NaN
0.5,0.1,0.4,2.31

Key Points

  • Descriptor columns (x1, x2, x3): Define the search space
  • Objective column(s): Values to optimize (NaN = not yet tested)
  • Rows with NaN objectives are candidates for future experiments
  • Rows with values have already been tested

2.3 Core Workflow Functions

NIMO provides four main functions that form the complete optimization loop:

1. selection() - Choose Next Experiments

This function uses an AI algorithm to select the most promising candidates from the untested pool.

Code Example 1: Using selection()
import nimo

# Select candidates using Bayesian Optimization
nimo.selection(
    method="PHYSBO",           # AI algorithm to use
    input_file="candidates.csv",   # File with all candidates
    output_file="proposals.csv",   # Selected candidates output
    num_objectives=1,          # Number of objective functions
    num_proposals=3            # How many candidates to select
)

Parameters explained:

2. preparation_input() - Prepare for Robot

This function converts the selected proposals into the format required by the robot system.

Code Example 2: Using preparation_input()
import nimo

# Prepare proposals for the STAN robot interface
nimo.preparation_input(
    machine="STAN",            # Robot system type
    input_file="proposals.csv",    # Selected candidates
    output_file="robot_input.csv"  # Robot-ready format
)

3. analysis_output() - Process Robot Results

After the robot executes experiments, this function processes the results back into NIMO format.

Code Example 3: Using analysis_output()
import nimo

# Process results from the robot
nimo.analysis_output(
    machine="STAN",            # Robot system type
    input_file="robot_output.csv", # Raw robot results
    output_file="results.csv"      # Processed results
)

4. history() - Track Progress

This function provides a record of the optimization history.

Code Example 4: Using history()
import nimo

# Get optimization history
history_data = nimo.history(
    input_file="candidates.csv",
    num_objectives=1
)

print("Best value found:", history_data['best_objective'])
print("Number of experiments:", history_data['num_experiments'])

2.4 Complete Workflow Example

Let's see how all the pieces fit together in a typical optimization cycle:

Code Example 5: Complete Optimization Cycle
import nimo
import pandas as pd

# Configuration
NUM_CYCLES = 10
PROPOSALS_PER_CYCLE = 3

# Initialize: create candidates file with search space
candidates = pd.DataFrame({
    'x1': [i/10 for i in range(11)],
    'x2': [1 - i/10 for i in range(11)],
    'objective': [float('nan')] * 11
})
candidates.to_csv('candidates.csv', index=False)

# Main optimization loop
for cycle in range(NUM_CYCLES):
    print(f"\n=== Cycle {cycle + 1} ===")

    # Step 1: Select candidates
    if cycle == 0:
        # First cycle: use random selection
        method = "RE"
    else:
        # Later cycles: use Bayesian Optimization
        method = "PHYSBO"

    nimo.selection(
        method=method,
        input_file="candidates.csv",
        output_file="proposals.csv",
        num_objectives=1,
        num_proposals=PROPOSALS_PER_CYCLE
    )

    # Step 2: Prepare for robot
    nimo.preparation_input(
        machine="STAN",
        input_file="proposals.csv",
        output_file="robot_input.csv"
    )

    # Step 3: [Robot executes experiments here]
    # In simulation, we would calculate objective values
    # In real experiments, robot_output.csv is generated by the robot

    # Step 4: Process results
    nimo.analysis_output(
        machine="STAN",
        input_file="robot_output.csv",
        output_file="results.csv"
    )

    # Step 5: Update candidates file with new results
    # (NIMO handles this internally)

    print(f"Completed {PROPOSALS_PER_CYCLE} experiments")

Workflow Summary

  1. selection(): AI picks the best candidates to test
  2. preparation_input(): Format data for robot
  3. [Robot Execution]: Physical experiments happen
  4. analysis_output(): Process results back to NIMO format
  5. Repeat: Use new data to make better selections

Exercises

Exercise 1: Trace the Data Flow

Given this initial candidates.csv:

x1,x2,objective
0.2,0.8,NaN
0.5,0.5,1.5
0.8,0.2,NaN

If NIMO's selection() chooses row 0 (x1=0.2, x2=0.8) for the next experiment:

  1. What would proposals.csv look like?
  2. After the robot measures objective=2.1 for this sample, what would the updated candidates.csv look like?

Exercise 2: Architecture Matching

Match each NIMO component to its role:

  1. PHYSBO
  2. STAN
  3. plot_history
  4. RE

Roles: A) Robot interface, B) Bayesian Optimization, C) Random sampling, D) Visualization

Summary

Disclaimer

This content is provided for educational purposes. NIMO is developed and maintained by NIMS.