Skip to content

Commit

Permalink
SacessOptimizer: Update worker settings (#1202)
Browse files Browse the repository at this point in the history
* Most importantly fix default RefSet sizes (too big before)
* Add default settings for >10 workers
  • Loading branch information
dweindl authored Nov 21, 2023
1 parent 13e80c8 commit a6e300f
Showing 1 changed file with 95 additions and 18 deletions.
113 changes: 95 additions & 18 deletions pypesto/optimize/ess/sacess.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import multiprocessing
import os
import time
from math import ceil, sqrt
from multiprocessing import Manager, Process
from multiprocessing.managers import SyncManager
from pathlib import Path
Expand Down Expand Up @@ -700,90 +701,166 @@ def get_default_ess_options(num_workers: int, dim: int) -> List[Dict]:
Setting appropriate values for ``n_threads`` and ``local_optimizer`` is
left to the user. Defaults to single-threaded and no local optimizer.
Based on https://bitbucket.org/DavidPenas/sacess-library/src/508e7ac15579104731cf1f8c3969960c6e72b872/src/method_module_fortran/eSS/parallelscattersearchfunctions.f90#lines-929
Parameters
----------
num_workers: Number of configurations to return.
dim: Problem dimension.
"""
min_dimrefset = 3
min_dimrefset = 5

def dim_refset(x):
return max(min_dimrefset, ceil((1 + sqrt(4 * dim * x)) / 2))

settings = [
# settings for first worker
{
'dim_refset': 10 * dim,
'dim_refset': dim_refset(10),
'balance': 0.5,
'local_n2': 10,
},
# for the remaining workers, cycle through these settings
# 1
{
'dim_refset': max(min_dimrefset, dim),
'dim_refset': dim_refset(1),
'balance': 0.0,
'local_n1': 1,
'local_n2': 1,
},
# 2
{
'dim_refset': 3 * dim,
'dim_refset': dim_refset(3),
'balance': 0.0,
'local_n1': 4,
'local_n2': 4,
'local_n1': 1000,
'local_n2': 1000,
},
# 3
{
'dim_refset': 5 * dim,
'dim_refset': dim_refset(5),
'balance': 0.25,
'local_n1': 10,
'local_n2': 10,
},
# 4
{
'dim_refset': 10 * dim,
'dim_refset': dim_refset(10),
'balance': 0.5,
'local_n1': 20,
'local_n2': 20,
},
# 5
{
'dim_refset': 15 * dim,
'dim_refset': dim_refset(15),
'balance': 0.25,
'local_n1': 100,
'local_n2': 100,
},
# 6
{
'dim_refset': 12 * dim,
'dim_refset': dim_refset(12),
'balance': 0.25,
'local_n1': 50,
'local_n2': 50,
'local_n1': 1000,
'local_n2': 1000,
},
# 7
{
'dim_refset': int(7.5 * dim),
'dim_refset': dim_refset(7.5),
'balance': 0.25,
'local_n1': 15,
'local_n2': 15,
},
# 8
{
'dim_refset': 5 * dim,
'dim_refset': dim_refset(5),
'balance': 0.25,
'local_n1': 7,
'local_n2': 7,
},
# 9
{
'dim_refset': max(min_dimrefset, 2 * dim),
'dim_refset': dim_refset(2),
'balance': 0.0,
'local_n1': 2,
'local_n2': 2,
'local_n1': 1000,
'local_n2': 1000,
},
# 10
{
'dim_refset': max(min_dimrefset, int(0.5 * dim)),
'dim_refset': dim_refset(0.5),
'balance': 0.0,
'local_n1': 1,
'local_n2': 1,
},
# 11
{
'dim_refset': dim_refset(1.5),
'balance': 1.0,
'local_n1': 1,
'local_n2': 1,
},
# 12
{
'dim_refset': dim_refset(3.5),
'balance': 1.0,
'local_n1': 4,
'local_n2': 4,
},
# 13
{
'dim_refset': dim_refset(5.5),
'balance': 0.1,
'local_n1': 10,
'local_n2': 10,
},
# 14
{
'dim_refset': dim_refset(10.5),
'balance': 0.3,
'local_n1': 20,
'local_n2': 20,
},
# 15
{
'dim_refset': dim_refset(15.5),
'balance': 0.2,
'local_n1': 1000,
'local_n2': 1000,
},
# 16
{
'dim_refset': dim_refset(12.5),
'balance': 0.2,
'local_n1': 10,
'local_n2': 10,
},
# 17
{
'dim_refset': dim_refset(8),
'balance': 0.75,
'local_n1': 15,
'local_n2': 15,
},
# 18
{
'dim_refset': dim_refset(5.5),
'balance': 0.75,
'local_n1': 1000,
'local_n2': 1000,
},
# 19
{
'dim_refset': dim_refset(2.2),
'balance': 1.0,
'local_n1': 2,
'local_n2': 2,
},
# 20
{
'dim_refset': dim_refset(1),
'balance': 1.0,
'local_n1': 1,
'local_n2': 1,
},
]
return [
settings[0],
Expand Down

0 comments on commit a6e300f

Please sign in to comment.