Overview

AutoOptimizer enables you to load optimization algorithms with a single line of code, handling repository management, dependency installation, and algorithm instantiation automatically.

from qubots import AutoOptimizer

# Load an optimizer from a repository
optimizer = AutoOptimizer.from_repo("ileo/demo-ortools-maxcut-optimizer")

Key Features

Algorithm Loading

Automatically load optimization algorithms from repositories

Dependency Management

Handle solver dependencies and library requirements

Parameter Tuning

Override algorithm parameters for customization

Compatibility Checking

Verify compatibility between optimizers and problems

Basic Usage

Running Optimization

from qubots import AutoProblem, AutoOptimizer

# Load problem and optimizer
problem = AutoProblem.from_repo("ileo/demo-maxcut")
optimizer = AutoOptimizer.from_repo("ileo/demo-ortools-maxcut-optimizer")

# Run optimization
result = optimizer.optimize(problem)

# Access results
print(f"Best value: {result.best_value}")
print(f"Runtime: {result.runtime_seconds:.3f} seconds")
print(f"Solution: {result.best_solution}")

Parameter Override

Customize optimizer behavior by overriding parameters:

# Load with custom parameters
optimizer = AutoOptimizer.from_repo("ileo/demo-ortools-maxcut-optimizer", override_params={
    "time_limit": 60.0,           # 1 minute time limit
    "num_search_workers": 4,      # Use 4 parallel workers
    "log_search_progress": True,  # Enable detailed logging
    "use_symmetry": True         # Enable symmetry breaking
})

Optimizer Configuration

Each optimizer repository contains a config.json file:

{
  "type": "optimizer",
  "entry_point": "qubot",
  "class_name": "ORToolsMaxCutOptimizer",
  "default_params": {
    "time_limit": 300,
    "num_search_workers": 0,
    "log_search_progress": false,
    "use_symmetry": true
  },
  "metadata": {
    "name": "demo-ortools-maxcut-optimizer",
    "description": "Constraint programming solver for Maximum Cut problems using Google OR-Tools CP-SAT. Formulates MaxCut using binary variables with linearization techniques to handle the quadratic objective.",
    "domain": "graph_theory",
    "tags": [
      "ortools",
      "cp-sat",
      "constraint_programming",
      "exact",
      "maxcut",
      "binary",
      "optimization",
      "open_source",
      "linearization"
    ],
    "difficulty": "intermediate",
    "optimizer_type": "exact"
  },
  "parameters": {
    "time_limit": {
      "type": "number",
      "default": 300,
      "min": 1,
      "max": 3600,
      "description": "Maximum solving time in seconds"
    },
    "num_search_workers": {
      "type": "integer",
      "default": 0,
      "min": 0,
      "max": 16,
      "description": "Number of parallel search workers (0 = automatic)"
    },
    "max_time_in_seconds": {
      "type": "number",
      "default": 300,
      "min": 1,
      "max": 3600,
      "description": "Alternative time limit parameter for CP-SAT"
    },
    "log_search_progress": {
      "type": "boolean",
      "default": false,
      "description": "Enable detailed search progress logging"
    },
    "enumerate_all_solutions": {
      "type": "boolean",
      "default": false,
      "description": "Find all optimal solutions if multiple exist"
    },
    "use_symmetry": {
      "type": "boolean",
      "default": true,
      "description": "Enable symmetry breaking techniques"
    }
  }
}

Next Steps