Skip to content

EDA Problems

Environment for Electronic Design Automation (EDA) problems

Decap Placement Problem (DPP)

DPPEnv

DPPEnv(
    generator: DPPGenerator = None,
    generator_params: dict = {},
    **kwargs
)

Bases: RL4COEnvBase

Decap Placement Problem (DPP) as done in DevFormer paper: https://arxiv.org/abs/2205.13225

The environment is a 10x10 grid with 100 locations containing either a probing port or a keepout region. The goal is to place decaps (decoupling capacitors) to maximize the impedance suppression at the probing port. Decaps cannot be placed in keepout regions or at the probing port and the number of decaps is limited.

Observations
  • locations of the probing port and keepout regions
  • current decap placement
  • remaining decaps
Constraints
  • decaps cannot be placed at the probing port or keepout regions
  • the number of decaps is limited
Finish Condition
  • the number of decaps exceeds the limit
Reward
  • the impedance suppression at the probing port

Parameters:

  • generator (DPPGenerator, default: None ) –

    DPPGenerator instance as the data generator

  • generator_params (dict, default: {} ) –

    parameters for the generator

Source code in rl4co/envs/eda/dpp/env.py
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
def __init__(
    self,
    generator: DPPGenerator = None,
    generator_params: dict = {},
    **kwargs,
):
    super().__init__(**kwargs)
    if generator is None:
        generator = DPPGenerator(**generator_params)
    self.generator = generator

    self.max_decaps = self.generator.max_decaps
    self.size = self.generator.size
    self.raw_pdn = self.generator.raw_pdn
    self.decap = self.generator.decap
    self.freq = self.generator.freq
    self.num_freq = self.generator.num_freq
    self.data_dir = self.generator.data_dir

    self._make_spec(self.generator)

DPPGenerator

DPPGenerator(
    min_loc: float = 0.0,
    max_loc: float = 1.0,
    num_keepout_min: int = 1,
    num_keepout_max: int = 50,
    max_decaps: int = 20,
    data_dir: str = "data/dpp/",
    chip_file: str = "10x10_pkg_chip.npy",
    decap_file: str = "01nF_decap.npy",
    freq_file: str = "freq_201.npy",
    url: str = None,
    **unused_kwargs
)

Bases: Generator

Data generator for the Decap Placement Problem (DPP).

Parameters:

  • min_loc (float, default: 0.0 ) –

    Minimum location value. Defaults to 0.

  • max_loc (float, default: 1.0 ) –

    Maximum location value. Defaults to 1.

  • num_keepout_min (int, default: 1 ) –

    Minimum number of keepout regions. Defaults to 1.

  • num_keepout_max (int, default: 50 ) –

    Maximum number of keepout regions. Defaults to 50.

  • max_decaps (int, default: 20 ) –

    Maximum number of decaps. Defaults to 20.

  • data_dir (str, default: 'data/dpp/' ) –

    Directory to store data. Defaults to "data/dpp/". This can be downloaded from this url.

  • chip_file (str, default: '10x10_pkg_chip.npy' ) –

    Name of the chip file. Defaults to "10x10_pkg_chip.npy".

  • decap_file (str, default: '01nF_decap.npy' ) –

    Name of the decap file. Defaults to "01nF_decap.npy".

  • freq_file (str, default: 'freq_201.npy' ) –

    Name of the frequency file. Defaults to "freq_201.npy".

  • url (str, default: None ) –

    URL to download data from. Defaults to None.

Returns:

  • A TensorDict with the following keys: locs [batch_size, num_loc, 2]: locations of each customer depot [batch_size, 2]: location of the depot demand [batch_size, num_loc]: demand of each customer capacity [batch_size]: capacity of the vehicle

Source code in rl4co/envs/eda/dpp/generator.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
def __init__(
    self,
    min_loc: float = 0.0,
    max_loc: float = 1.0,
    num_keepout_min: int = 1,
    num_keepout_max: int = 50,
    max_decaps: int = 20,
    data_dir: str = "data/dpp/",
    chip_file: str = "10x10_pkg_chip.npy",
    decap_file: str = "01nF_decap.npy",
    freq_file: str = "freq_201.npy",
    url: str = None,
    **unused_kwargs
):
    self.min_loc = min_loc
    self.max_loc = max_loc
    self.num_keepout_min = num_keepout_min
    self.num_keepout_max = num_keepout_max
    self.max_decaps = max_decaps
    self.data_dir = data_dir

    # DPP environment doen't have any other kwargs
    if len(unused_kwargs) > 0:
        log.error(f"Found {len(unused_kwargs)} unused kwargs: {unused_kwargs}")


    # Download and load the data from online dataset
    self.url = (
        "https://github.com/kaist-silab/devformer/raw/main/data/data.zip"
        if url is None
        else url
    )
    self.backup_url = (
        "https://drive.google.com/uc?id=1IEuR2v8Le-mtHWHxwTAbTOPIkkQszI95"
    )
    self._load_dpp_data(chip_file, decap_file, freq_file)

    # Check the validity of the keepout parameters
    assert (
        num_keepout_min <= num_keepout_max
    ), "num_keepout_min must be <= num_keepout_max"
    assert (
        num_keepout_max <= self.size**2
    ), "num_keepout_max must be <= size * size (total number of locations)"

Multi-port Decap Placement Problem (mDPP)

MDPPEnv

MDPPEnv(
    generator: MDPPGenerator = None,
    generator_params: dict = {},
    reward_type: str = "minmax",
    **kwargs
)

Bases: DPPEnv

Multiple decap placement problem (mDPP) environment This is a modified version of the DPP environment where we allow multiple probing ports

Observations
  • locations of the probing ports and keepout regions
  • current decap placement
  • remaining decaps
Constraints
  • decaps cannot be placed at the probing ports or keepout regions
  • the number of decaps is limited
Finish Condition
  • the number of decaps exceeds the limit
Reward
  • the impedance suppression at the probing ports

Parameters:

  • generator (MDPPGenerator, default: None ) –

    DPPGenerator instance as the data generator

  • generator_params (dict, default: {} ) –

    parameters for the generator

  • reward_type (str, default: 'minmax' ) –

    reward type, either minmax or meansum

    • minmax: min of the max of the decap scores
    • meansum: mean of the sum of the decap scores
Note

The minmax is more challenging as it requires to find the best decap location for the worst case

Source code in rl4co/envs/eda/mdpp/env.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
def __init__(
    self,
    generator: MDPPGenerator = None,
    generator_params: dict = {},
    reward_type: str = "minmax",
    **kwargs,
):
    super().__init__(**kwargs)
    if generator is None:
        generator = MDPPGenerator(**generator_params)
    self.generator = generator

    assert reward_type in [
        "minmax",
        "meansum",
    ], "reward_type must be minmax or meansum"
    self.reward_type = reward_type

    self._make_spec(self.generator)

MDPPGenerator

MDPPGenerator(
    min_loc: float = 0.0,
    max_loc: float = 1.0,
    num_keepout_min: int = 1,
    num_keepout_max: int = 50,
    num_probes_min: int = 2,
    num_probes_max: int = 5,
    max_decaps: int = 20,
    data_dir: str = "data/dpp/",
    chip_file: str = "10x10_pkg_chip.npy",
    decap_file: str = "01nF_decap.npy",
    freq_file: str = "freq_201.npy",
    url: str = None,
    **unused_kwargs
)

Bases: Generator

Data generator for the Multi Decap Placement Problem (MDPP).

Parameters:

  • min_loc (float, default: 0.0 ) –

    Minimum location value. Defaults to 0.

  • max_loc (float, default: 1.0 ) –

    Maximum location value. Defaults to 1.

  • num_keepout_min (int, default: 1 ) –

    Minimum number of keepout regions. Defaults to 1.

  • num_keepout_max (int, default: 50 ) –

    Maximum number of keepout regions. Defaults to 50.

  • max_decaps (int, default: 20 ) –

    Maximum number of decaps. Defaults to 20.

  • data_dir (str, default: 'data/dpp/' ) –

    Directory to store data. Defaults to "data/dpp/". This can be downloaded from this url.

  • chip_file (str, default: '10x10_pkg_chip.npy' ) –

    Name of the chip file. Defaults to "10x10_pkg_chip.npy".

  • decap_file (str, default: '01nF_decap.npy' ) –

    Name of the decap file. Defaults to "01nF_decap.npy".

  • freq_file (str, default: 'freq_201.npy' ) –

    Name of the frequency file. Defaults to "freq_201.npy".

  • url (str, default: None ) –

    URL to download data from. Defaults to None.

Returns:

  • A TensorDict with the following keys: locs [batch_size, num_loc, 2]: locations of each customer depot [batch_size, 2]: location of the depot demand [batch_size, num_loc]: demand of each customer capacity [batch_size]: capacity of the vehicle

Source code in rl4co/envs/eda/mdpp/generator.py
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
def __init__(
    self,
    min_loc: float = 0.0,
    max_loc: float = 1.0,
    num_keepout_min: int = 1,
    num_keepout_max: int = 50,
    num_probes_min: int = 2,
    num_probes_max: int = 5,
    max_decaps: int = 20,
    data_dir: str = "data/dpp/",
    chip_file: str = "10x10_pkg_chip.npy",
    decap_file: str = "01nF_decap.npy",
    freq_file: str = "freq_201.npy",
    url: str = None,
    **unused_kwargs
):
    self.min_loc = min_loc
    self.max_loc = max_loc
    self.num_keepout_min = num_keepout_min
    self.num_keepout_max = num_keepout_max
    self.num_probes_min = num_probes_min
    self.num_probes_max = num_probes_max
    self.max_decaps = max_decaps
    self.data_dir = data_dir

    # DPP environment doen't have any other kwargs
    if len(unused_kwargs) > 0:
        log.error(f"Found {len(unused_kwargs)} unused kwargs: {unused_kwargs}")


    # Download and load the data from online dataset
    self.url = (
        "https://github.com/kaist-silab/devformer/raw/main/data/data.zip"
        if url is None
        else url
    )
    self.backup_url = (
        "https://drive.google.com/uc?id=1IEuR2v8Le-mtHWHxwTAbTOPIkkQszI95"
    )
    self._load_dpp_data(chip_file, decap_file, freq_file)

    # Check the validity of the keepout parameters
    assert (
        num_keepout_min <= num_keepout_max
    ), "num_keepout_min must be <= num_keepout_max"
    assert (
        num_keepout_max <= self.size**2
    ), "num_keepout_max must be <= size * size (total number of locations)"