Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SacessOptimizer: Update worker settings #1202

Merged
merged 5 commits into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this also based on the reference. Could not find the function MOD(ids...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The MOD is replaced by cycle at the end of this function.


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