or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

advanced-optimization.mdconfiguration.mdconstraints-boundaries.mdcore-optimization.mdfitness-functions.mdindex.mdlogging-analysis.mdsamplers-adaptation.md

configuration.mddocs/

0

# Configuration and Options

1

2

Comprehensive configuration management for CMA-ES through the CMAOptions class. This covers all available options for fine-tuning CMA-ES behavior across different problem types and requirements.

3

4

## CMAOptions Class

5

6

The central class for managing all CMA-ES configuration options with defaults, validation, and search capabilities.

7

8

## Complete Options Reference

9

10

### Key Option Categories

11

12

```python { .api }

13

# Major CMA-ES option categories with examples

14

15

# Population and sampling options

16

'popsize' # Population size (default: 4 + int(3*log(N)))

17

'popsize_factor' # Population size multiplier

18

'CMA_mu' # Parent population size

19

'CMA_mirrors' # Use mirrored sampling

20

'CMA_mirrormethod' # Mirroring method selection

21

22

# Termination criteria

23

'maxiter' # Maximum iterations

24

'maxfevals' # Maximum function evaluations

25

'ftarget' # Target function value

26

'tolfun' # Tolerance in function value

27

'tolfunhist' # Tolerance in function value history

28

'tolfunrel' # Relative tolerance in function value

29

'tolx' # Tolerance in parameter changes

30

'tolstagnation' # Tolerance for stagnation detection

31

'timeout' # Wall-clock time limit

32

33

# Step-size control

34

'CSA_dampfac' # Step-size damping factor

35

'CSA_damp_mueff_exponent' # Damping exponent

36

'CSA_disregard_length' # Disregard length of step

37

'CMA_dampsvec' # Individual step-size damping

38

39

# Covariance matrix adaptation

40

'CMA_active' # Use active covariance matrix update

41

'CMA_cmean' # Learning rate for mean update

42

'CMA_on' # Enable/disable covariance matrix adaptation

43

'CMA_rankmu' # Use rank-mu update

44

'CMA_rankone' # Use rank-one update

45

'CMA_recombination_weights' # Recombination weights method

46

47

# Boundaries and constraints

48

'bounds' # Box constraints [lower, upper]

49

'fixed_variables' # Fix certain variables

50

'scaling_of_variables' # Variable scaling factors

51

'typical_x' # Typical variable values

52

53

# Display and logging

54

'verb_disp' # Display verbosity level (0=none, 1=some, 2=much)

55

'verb_log' # Logging verbosity

56

'verb_plot' # Plotting verbosity

57

'verb_time' # Time display verbosity

58

'verb_append' # Append to existing log files

59

'output_filename' # Base filename for output files

60

61

# Advanced algorithmic options

62

'AdaptSigma' # Step-size adaptation method

63

'CMA_elitist' # Use elitist selection

64

'CMA_sampler' # Sampling method selection

65

'BoundaryHandler' # Boundary handling strategy

66

'ConditioningOfC' # Conditioning of covariance matrix

67

'MaxConditionNumber' # Maximum condition number

68

'NoEffectAxis' # Handle ineffective coordinate axes

69

'NoEffectCoord' # Handle ineffective coordinates

70

71

# Restart and multistart

72

'restarts' # Number of restarts

73

'restart_from_best' # Restart from best solution

74

'incpopsize' # Population size increment factor

75

'bipop' # Use bi-population strategy

76

77

# Noise handling

78

'noise_handling' # Enable noise handling

79

'noise_change_sigma_exponent' # Noise-dependent step-size change

80

'noise_evaluations_as_reward' # Treat noise evaluations as reward

81

```

82

83

### Class Definition

84

85

```python { .api }

86

class CMAOptions(dict):

87

"""

88

Dictionary of available CMA-ES options with defaults and documentation.

89

90

Inherits from dict and provides additional functionality for option

91

management, validation, and searching. Contains all available options

92

with their default values and descriptions.

93

"""

94

95

def __init__(self, s='', **kwargs):

96

"""

97

Initialize options dictionary.

98

99

Parameters:

100

-----------

101

s : str or dict, optional

102

Search string to filter options, or dict of options to set.

103

If string, returns options matching the substring in name,

104

value, or description.

105

106

**kwargs : dict

107

Direct option assignments as keyword arguments.

108

109

Examples:

110

---------

111

>>> import cma

112

>>>

113

>>> # All default options

114

>>> opts = cma.CMAOptions()

115

>>> len(opts) > 50 # Many options available

116

True

117

>>>

118

>>> # Search for tolerance options

119

>>> tol_opts = cma.CMAOptions('tol')

120

>>> print(list(tol_opts.keys()))

121

['tolfun', 'tolfunhist', 'tolfunrel', 'tolstagnation', 'tolx', ...]

122

>>>

123

>>> # Search for verbosity options

124

>>> verb_opts = cma.CMAOptions('verb')

125

>>> 'verb_disp' in verb_opts

126

True

127

>>>

128

>>> # Initialize with specific options

129

>>> opts = cma.CMAOptions({'popsize': 20, 'maxiter': 1000})

130

>>>

131

>>> # Using keyword arguments

132

>>> opts = cma.CMAOptions(popsize=20, maxiter=1000, ftarget=1e-8)

133

"""

134

pass

135

136

def init(self, dict_or_str, val=None, warn=True):

137

"""

138

Initialize one or several options.

139

140

Parameters:

141

-----------

142

dict_or_str : dict or str

143

Dictionary of options if val is None, otherwise option key.

144

145

val : any, optional

146

Option value if dict_or_str is a key.

147

148

warn : bool, optional

149

Whether to warn about unknown options (default True).

150

151

Examples:

152

---------

153

>>> opts = cma.CMAOptions()

154

>>> opts.init('popsize', 50)

155

>>> opts.init({'maxiter': 2000, 'ftarget': 1e-10})

156

"""

157

pass

158

159

def set(self, dic, val=None, force=False):

160

"""

161

Set versatile options that can be changed during optimization.

162

163

Parameters:

164

-----------

165

dic : dict or str

166

Dictionary of options or single option key.

167

168

val : any, optional

169

Option value if dic is a key.

170

171

force : bool, optional

172

Force setting of non-versatile options (default False).

173

174

Examples:

175

---------

176

>>> import cma

177

>>> es = cma.CMAEvolutionStrategy([0, 0], 0.5)

178

>>>

179

>>> # Change options during optimization

180

>>> es.opts.set('verb_disp', 50) # Change display frequency

181

>>> es.opts.set({'ftarget': 1e-6, 'maxfevals': 2000})

182

"""

183

pass

184

185

def match(self, s=''):

186

"""

187

Return options that match search string.

188

189

Parameters:

190

-----------

191

s : str

192

Search string to match in option names, values, or descriptions.

193

194

Returns:

195

--------

196

dict

197

Dictionary of matching options.

198

199

Examples:

200

---------

201

>>> opts = cma.CMAOptions()

202

>>>

203

>>> # Find all termination options

204

>>> term_opts = opts.match('termination')

205

>>>

206

>>> # Find population size related options

207

>>> pop_opts = opts.match('popsize')

208

>>>

209

>>> # Find boundary related options

210

>>> bound_opts = opts.match('bound')

211

"""

212

pass

213

214

@staticmethod

215

def defaults():

216

"""

217

Return dictionary of all default options.

218

219

Returns:

220

--------

221

dict

222

All available options with their default values.

223

"""

224

pass

225

226

def versatile_options(self):

227

"""

228

Return list of versatile options that can be changed during optimization.

229

230

Returns:

231

--------

232

list

233

List of option keys that can be modified after initialization.

234

"""

235

pass

236

```

237

238

## Option Categories

239

240

### Termination Options

241

242

Options controlling when optimization stops.

243

244

```python { .api }

245

# Termination options and their usage

246

termination_options = {

247

'ftarget': '-inf', # Target function value (minimization)

248

'maxfevals': 'inf', # Maximum function evaluations

249

'maxiter': '100 + 150 * (N+3)**2 // popsize**0.5', # Maximum iterations

250

'timeout': 'inf', # Maximum time in seconds

251

'tolfun': '1e-11', # Function value tolerance

252

'tolfunhist': '1e-12', # Function value history tolerance

253

'tolfunrel': '0', # Relative function value tolerance

254

'tolx': '1e-11', # Solution tolerance

255

'tolstagnation': 'int(100 + 100 * N**1.5 / popsize)', # Stagnation tolerance

256

'tolconditioncov': '1e14', # Covariance matrix condition tolerance

257

'tolfacupx': '1e3', # Step-size increase tolerance

258

'tolupsigma': '1e20', # Sigma increase tolerance

259

'tolflatfitness': '1' # Flat fitness tolerance iterations

260

}

261

262

# Examples of termination configuration

263

examples = {

264

# Quick convergence for testing

265

'fast_convergence': {

266

'ftarget': 1e-6,

267

'maxfevals': 1000,

268

'tolfun': 1e-8

269

},

270

271

# Thorough optimization

272

'thorough': {

273

'maxfevals': 100000,

274

'ftarget': 1e-12,

275

'tolfun': 1e-15,

276

'tolx': 1e-12

277

},

278

279

# Time-limited optimization

280

'time_limited': {

281

'timeout': 3600, # 1 hour

282

'maxiter': float('inf'),

283

'maxfevals': float('inf')

284

},

285

286

# High-precision optimization

287

'high_precision': {

288

'ftarget': 1e-15,

289

'tolfun': 1e-18,

290

'tolx': 1e-15,

291

'tolconditioncov': 1e16

292

}

293

}

294

```

295

296

### Population and Selection Options

297

298

Options controlling population size and selection mechanisms.

299

300

```python { .api }

301

# Population and selection options

302

population_options = {

303

'popsize': '4 + 3 * math.log(N)', # Population size (lambda)

304

'popsize_factor': '1', # Multiplier for default popsize

305

'CMA_mu': 'None', # Parent selection parameter (mu)

306

'CMA_recombination_weights': 'None', # Custom recombination weights

307

'CMA_elitist': 'False', # Elitist selection

308

'CMA_mirrors': 'popsize < 6', # Mirrored sampling

309

'CMA_mirrormethod': '2' # Mirror method (0,1,2)

310

}

311

312

# Population configuration examples

313

population_examples = {

314

# Small population for fast convergence

315

'small_population': {

316

'popsize': 10,

317

'CMA_mu': 5

318

},

319

320

# Large population for difficult problems

321

'large_population': {

322

'popsize_factor': 3, # 3x default size

323

'CMA_mu': None # Will be popsize // 2

324

},

325

326

# Custom recombination weights

327

'custom_weights': {

328

'CMA_recombination_weights': [0.5, 0.3, 0.2], # Manual weights

329

'popsize': 10 # Must match weights length

330

},

331

332

# Mirrored sampling for small populations

333

'mirrored_sampling': {

334

'popsize': 8,

335

'CMA_mirrors': True, # Enable mirroring

336

'CMA_mirrormethod': 2 # Selective with delay

337

},

338

339

# Elitist strategy (use with caution)

340

'elitist': {

341

'CMA_elitist': 'initial', # Keep initial solution

342

'popsize': 20

343

}

344

}

345

```

346

347

### Adaptation Options

348

349

Options controlling step-size and covariance matrix adaptation.

350

351

```python { .api }

352

# Adaptation options

353

adaptation_options = {

354

'AdaptSigma': 'True', # Enable step-size adaptation

355

'CSA_dampfac': '1', # Step-size damping factor

356

'CSA_disregard_length': 'False', # Disregard path length

357

'CSA_squared': 'False', # Use squared length

358

'CMA_on': '1', # Covariance matrix update multiplier

359

'CMA_rankone': '1.0', # Rank-one update multiplier

360

'CMA_rankmu': '1.0', # Rank-mu update multiplier

361

'CMA_active': 'True', # Active covariance matrix update

362

'CMA_diagonal': '0*100*N/popsize**0.5', # Diagonal-only iterations

363

'updatecovwait': 'None' # Iterations without cov update

364

}

365

366

# Adaptation configuration examples

367

adaptation_examples = {

368

# Conservative adaptation

369

'conservative': {

370

'CSA_dampfac': 2.0, # Slower step-size adaptation

371

'CMA_rankone': 0.5, # Reduced rank-one update

372

'CMA_rankmu': 0.5 # Reduced rank-mu update

373

},

374

375

# Aggressive adaptation

376

'aggressive': {

377

'CSA_dampfac': 0.5, # Faster step-size adaptation

378

'CMA_rankone': 2.0, # Increased rank-one update

379

'CMA_active': True # Enable active update

380

},

381

382

# Diagonal-only for high dimensions

383

'diagonal_phase': {

384

'CMA_diagonal': '100', # 100 iterations diagonal-only

385

'CMA_rankmu': 0.0 # Disable rank-mu initially

386

},

387

388

# No covariance matrix adaptation

389

'no_covariance': {

390

'CMA_on': 0, # Disable all covariance updates

391

'AdaptSigma': True # Keep step-size adaptation

392

},

393

394

# Custom sigma adaptation

395

'custom_sigma': {

396

'AdaptSigma': 'cma.sigma_adaptation.CMAAdaptSigmaTPA',

397

'CSA_dampfac': 1.5

398

}

399

}

400

```

401

402

### Boundary and Constraint Options

403

404

Options for handling box constraints and boundaries.

405

406

```python { .api }

407

# Boundary and constraint options

408

boundary_options = {

409

'bounds': '[None, None]', # [lower, upper] boundaries

410

'BoundaryHandler': 'BoundTransform', # Boundary handling method

411

'fixed_variables': 'None', # Fixed variable indices

412

'integer_variables': '[]', # Integer variable indices

413

'is_feasible': 'is_feasible', # Feasibility function

414

'minstd': '0', # Minimal standard deviation

415

'maxstd': 'None', # Maximal standard deviation

416

'maxstd_boundrange': '1/3' # Max std relative to bounds

417

}

418

419

# Boundary configuration examples

420

boundary_examples = {

421

# Simple box constraints

422

'box_constraints': {

423

'bounds': [[-5, -5, -5], [5, 5, 5]], # 3D box [-5,5]^3

424

'BoundaryHandler': 'BoundTransform'

425

},

426

427

# Mixed bounds (some unbounded)

428

'mixed_bounds': {

429

'bounds': [[0, None, -10], [10, None, 10]], # [0,10] x R x [-10,10]

430

'BoundaryHandler': 'BoundTransform'

431

},

432

433

# Penalty-based bounds

434

'penalty_bounds': {

435

'bounds': [[-1, -1], [1, 1]],

436

'BoundaryHandler': 'BoundPenalty'

437

},

438

439

# Fixed variables

440

'fixed_variables': {

441

'fixed_variables': {0: 1.5, 2: 0.0}, # Fix x[0]=1.5, x[2]=0.0

442

'bounds': [[-5, -5, -5, -5], [5, 5, 5, 5]]

443

},

444

445

# Integer variables

446

'integer_optimization': {

447

'integer_variables': [0, 2], # x[0] and x[2] are integers

448

'bounds': [[0, -5, 0], [10, 5, 10]] # Appropriate bounds

449

},

450

451

# Standard deviation constraints

452

'std_constraints': {

453

'minstd': 0.01, # Minimum std per coordinate

454

'maxstd': 2.0, # Maximum std per coordinate

455

'bounds': [[-10, -10], [10, 10]]

456

}

457

}

458

```

459

460

### Verbosity and Logging Options

461

462

Options controlling output, logging, and visualization.

463

464

```python { .api }

465

# Verbosity and logging options

466

verbosity_options = {

467

'verbose': '3', # General verbosity level

468

'verb_disp': '100', # Console display frequency

469

'verb_log': '1', # File logging frequency

470

'verb_plot': '0', # Plotting frequency (fmin2 only)

471

'verb_time': 'True', # Show timing information

472

'verb_append': '0', # Append to existing files

473

'verb_filenameprefix': 'outcmaes', # Output filename prefix

474

'verb_log_expensive': 'N * (N <= 50)' # Expensive logging frequency

475

}

476

477

# Verbosity configuration examples

478

verbosity_examples = {

479

# Silent optimization

480

'silent': {

481

'verbose': -9, # Maximally quiet

482

'verb_disp': 0, # No console output

483

'verb_log': 0, # No file logging

484

'verb_time': False # No timing

485

},

486

487

# Detailed monitoring

488

'detailed': {

489

'verbose': 3, # Standard verbosity

490

'verb_disp': 10, # Display every 10 iterations

491

'verb_log': 1, # Log every iteration

492

'verb_plot': 50, # Plot every 50 iterations

493

'verb_time': True # Show timing

494

},

495

496

# Production logging

497

'production': {

498

'verbose': 1, # Minimal console output

499

'verb_disp': 100, # Rare display updates

500

'verb_log': 10, # Log every 10 iterations

501

'verb_filenameprefix': 'results/run_001', # Custom prefix

502

'verb_append': 0 # Overwrite files

503

},

504

505

# Debugging mode

506

'debug': {

507

'verbose': 3,

508

'verb_disp': 1, # Display every iteration

509

'verb_log': 1, # Log everything

510

'verb_log_expensive': 1 # Expensive operations too

511

}

512

}

513

```

514

515

### Advanced and Experimental Options

516

517

Advanced options for specialized use cases and experimental features.

518

519

```python { .api }

520

# Advanced and experimental options

521

advanced_options = {

522

'seed': 'time', # Random number seed

523

'randn': 'np.random.randn', # Random number generator

524

'CMA_eigenmethod': 'np.linalg.eigh', # Eigendecomposition method

525

'CMA_sampler': 'None', # Custom sampler class

526

'CMA_sampler_options': '{}', # Sampler options

527

'mean_shift_line_samples': 'False', # Line samples along mean shift

528

'pc_line_samples': 'False', # Line samples along evolution path

529

'signals_filename': 'cma_signals.in', # External signals file

530

'termination_callback': '[]', # Custom termination callbacks

531

'callback': 'None', # Iteration callbacks

532

'transformation': 'None', # Coordinate transformation

533

'CMA_stds': 'None' # Coordinate-wise standard deviations

534

}

535

536

# Advanced configuration examples

537

advanced_examples = {

538

# Reproducible results

539

'reproducible': {

540

'seed': 42, # Fixed seed

541

'randn': 'np.random.randn' # Standard generator

542

},

543

544

# Custom sampling

545

'custom_sampling': {

546

'CMA_sampler': 'cma.sampler.GaussFullSampler',

547

'CMA_sampler_options': {'eigenmethod': 'np.linalg.eigh'}

548

},

549

550

# Coordinate scaling

551

'coordinate_scaling': {

552

'CMA_stds': [1.0, 10.0, 0.1], # Different scales per coordinate

553

'bounds': [[-1, -10, -0.1], [1, 10, 0.1]]

554

},

555

556

# External control

557

'external_control': {

558

'signals_filename': 'optimization_control.in',

559

'termination_callback': [lambda es: es.countiter > 1000]

560

},

561

562

# Line sampling experiments

563

'line_sampling': {

564

'mean_shift_line_samples': True, # Sample along mean shift

565

'pc_line_samples': True, # Sample along evolution path

566

'popsize_factor': 1.5 # Larger population for extra samples

567

}

568

}

569

```

570

571

## Usage Patterns

572

573

### Basic Configuration

574

575

```python { .api }

576

import cma

577

578

# Pattern 1: Using options dictionary

579

def basic_configuration():

580

"""Basic option configuration examples."""

581

582

# Simple configuration

583

options = {

584

'popsize': 20,

585

'maxfevals': 5000,

586

'ftarget': 1e-8,

587

'verb_disp': 50

588

}

589

590

x, es = cma.fmin2(cma.ff.sphere, [0, 0, 0], 0.5, options=options)

591

return x, es

592

593

# Pattern 2: Using CMAOptions for exploration

594

def explore_options():

595

"""Explore and configure options systematically."""

596

597

# Find all tolerance options

598

tol_opts = cma.CMAOptions('tol')

599

print("Tolerance options:")

600

for key, value in tol_opts.items():

601

print(f" {key}: {value}")

602

603

# Find verbosity options

604

verb_opts = cma.CMAOptions('verb')

605

print("\nVerbosity options:")

606

for key in sorted(verb_opts.keys()):

607

print(f" {key}: {verb_opts[key]}")

608

609

# Create custom configuration

610

custom_opts = cma.CMAOptions({

611

'maxfevals': 2000,

612

'popsize': 15,

613

'verb_disp': 25

614

})

615

616

return custom_opts

617

618

# Pattern 3: Runtime option changes

619

def runtime_configuration():

620

"""Change options during optimization."""

621

622

def objective(x):

623

return sum(x**2)

624

625

es = cma.CMAEvolutionStrategy([1, 2, 3], 0.5)

626

627

iteration = 0

628

while not es.stop():

629

solutions = es.ask()

630

fitness_values = [objective(x) for x in solutions]

631

es.tell(solutions, fitness_values)

632

633

iteration += 1

634

635

# Change verbosity after 100 iterations

636

if iteration == 100:

637

es.opts.set('verb_disp', 10) # More frequent display

638

639

# Change target after 200 iterations

640

if iteration == 200:

641

es.opts.set('ftarget', 1e-10) # Stricter target

642

643

# Add timeout after 500 iterations

644

if iteration == 500:

645

es.opts.set('timeout', 60) # 1 minute timeout

646

647

return es.result

648

649

basic_configuration()

650

explore_options()

651

runtime_configuration()

652

```

653

654

### Problem-Specific Configurations

655

656

```python { .api }

657

import cma

658

import numpy as np

659

660

# Configuration for different problem types

661

def problem_specific_configs():

662

"""Configurations tailored to specific problem characteristics."""

663

664

# High-dimensional problems (N > 100)

665

high_dim_config = {

666

'CMA_diagonal': '50 + N//2', # Longer diagonal phase

667

'popsize_factor': 0.5, # Smaller population

668

'verb_log_expensive': 0, # Disable expensive logging

669

'maxiter': 1000, # Reasonable iteration limit

670

'tolstagnation': 200 # More patience for stagnation

671

}

672

673

# Noisy functions

674

noisy_config = {

675

'popsize_factor': 2, # Larger population

676

'tolflatfitness': 10, # More tolerance for flat fitness

677

'CSA_dampfac': 2, # Conservative step-size adaptation

678

'CMA_active': False, # Disable active update

679

'verb_disp': 20 # More frequent monitoring

680

}

681

682

# Multi-modal functions

683

multimodal_config = {

684

'popsize_factor': 2, # Larger population for exploration

685

'CMA_elitist': False, # Avoid premature convergence

686

'tolstagnation': 500, # Long stagnation tolerance

687

'tolfacupx': 1e5, # Allow large step increases

688

'maxfevals': 100000 # Large evaluation budget

689

}

690

691

# Fast functions (cheap to evaluate)

692

fast_function_config = {

693

'verb_log': 1, # Log every iteration

694

'verb_disp': 100, # Regular display

695

'verb_log_expensive': 10, # Allow expensive logging

696

'maxfevals': 1000000, # Large budget allowed

697

'popsize_factor': 1.5 # Slightly larger population

698

}

699

700

# Expensive functions (costly to evaluate)

701

expensive_function_config = {

702

'maxfevals': 1000, # Strict evaluation limit

703

'verb_log': 10, # Reduce logging frequency

704

'verb_log_expensive': 0, # No expensive operations

705

'popsize_factor': 0.5, # Smaller population

706

'tolfun': 1e-6, # Relaxed tolerance

707

'tolx': 1e-6 # Relaxed tolerance

708

}

709

710

return {

711

'high_dimensional': high_dim_config,

712

'noisy': noisy_config,

713

'multimodal': multimodal_config,

714

'fast': fast_function_config,

715

'expensive': expensive_function_config

716

}

717

718

configs = problem_specific_configs()

719

720

# Example usage with different problem types

721

def sphere_high_dim():

722

"""100D sphere function."""

723

def objective(x):

724

return sum(x**2)

725

726

x, es = cma.fmin2(

727

objective,

728

100 * [0.1],

729

0.3,

730

options=configs['high_dimensional']

731

)

732

return x, es

733

734

def noisy_rosenbrock():

735

"""Noisy Rosenbrock function."""

736

def objective(x):

737

true_val = sum(100*(x[1:] - x[:-1]**2)**2 + (1 - x[:-1])**2)

738

noise = 0.1 * np.random.randn()

739

return true_val + noise

740

741

x, es = cma.fmin2(

742

objective,

743

5 * [0.1],

744

0.5,

745

options=configs['noisy']

746

)

747

return x, es

748

```

749

750

### Configuration Validation and Debugging

751

752

```python { .api }

753

import cma

754

755

def validate_and_debug_config():

756

"""Validate configuration and debug option issues."""

757

758

def validate_options(options):

759

"""Validate option dictionary."""

760

# Create CMAOptions instance to check validity

761

try:

762

opts = cma.CMAOptions(options)

763

print("✓ All options are valid")

764

return True

765

except Exception as e:

766

print(f"✗ Invalid options: {e}")

767

return False

768

769

def debug_option_conflicts():

770

"""Check for common option conflicts."""

771

772

# Test conflicting options

773

conflicting_options = {

774

'popsize': 10,

775

'CMA_mu': 8, # mu should be <= popsize//2

776

'CMA_mirrors': True # Conflicts with small popsize

777

}

778

779

print("Testing conflicting options...")

780

validate_options(conflicting_options)

781

782

# Corrected options

783

corrected_options = {

784

'popsize': 20, # Larger population

785

'CMA_mu': 10, # popsize//2

786

'CMA_mirrors': True # Now compatible

787

}

788

789

print("Testing corrected options...")

790

validate_options(corrected_options)

791

792

def find_option_info(search_term):

793

"""Find and display information about options."""

794

opts = cma.CMAOptions(search_term)

795

796

print(f"Options matching '{search_term}':")

797

for key, value in opts.items():

798

print(f" {key}: {value}")

799

800

return opts

801

802

# Run validation tests

803

debug_option_conflicts()

804

805

# Search for specific options

806

find_option_info('timeout')

807

find_option_info('bound')

808

find_option_info('sigma')

809

810

# Comprehensive option listing

811

all_opts = cma.CMAOptions()

812

versatile_opts = [k for k, v in all_opts.items() if ' #v ' in str(v)]

813

814

print(f"\nTotal options: {len(all_opts)}")

815

print(f"Versatile options (can be changed during optimization): {len(versatile_opts)}")

816

print("Sample versatile options:", versatile_opts[:10])

817

818

validate_and_debug_config()

819

```