Check what is the problem in the below code, the below code is not executing…
- User
Check what is the problem in the below code, the below code is not executing
design_space_bounds = ['L1', 'L3', 'L5', 'L6', 'L7', 'W1', 'W3', 'W5', 'W6', 'W7', 'Io', 'CP', 'VCM'] bounds = { 'L1': (0.18e-6, 1e-6), 'L3': (0.18e-6, 1e-6), 'L5': (0.18e-6, 1e-6), 'L6': (0.18e-6, 1e-6), 'L7': (0.18e-6, 1e-6), 'W1': (1e-6, 12e-6), 'W3': (2.52e-6, 28e-6), 'W5': (2.16e-6, 24e-6), 'W6': (32e-6, 100e-6), 'W7': (13.5e-6, 100e-6), 'Io': (15e-6, 30e-6), 'CP': (0.44e-12, 3e-12), 'VCM': (0.8, 1.4) }
Define a function to adjust chromosome values based on transistor regions
def adjust_chromosome_value(chromosome, transistor_regions): adjusted_chromosome = chromosome.copy() # Check if any transistor region is NOT 2 if any(region != 2 for region in transistor_regions.values()): for transistor, region in transistor_regions.items(): if region == 1: # Increase "W" and decrease "L" for the corresponding transistor if transistor in ["M1", "M2"]: index_W1 = design_space_bounds.index('W1') index_L1 = design_space_bounds.index('L1') index_W3 = design_space_bounds.index('W3') index_L3 = design_space_bounds.index('L3') index_W5 = design_space_bounds.index('W5') index_L5 = design_space_bounds.index('L5') index_W6 = design_space_bounds.index('W6') index_L6 = design_space_bounds.index('L6') index_W7 = design_space_bounds.index('W7') index_L7 = design_space_bounds.index('L7') index_VCM = design_space_bounds.index('VCM') # Check if both W1 and L1 are at specific values
if (chromosome[index_W1] == 1e-6) and (chromosome[index_L1] == 1e-6): # Randomly choose new values for W1 and L1 within specified bounds adjusted_chromosome[index_W1] = random.uniform(*bounds['W1']) adjusted_chromosome[index_W3] = random.uniform(*bounds['W3']) adjusted_chromosome[index_W5] = random.uniform(*bounds['W5']) adjusted_chromosome[index_W6] = random.uniform(*bounds['W6']) adjusted_chromosome[index_W7] = random.uniform(*bounds['W7']) adjusted_chromosome[index_L1] = random.uniform(*bounds['L1']) adjusted_chromosome[index_L3] = random.uniform(*bounds['L3']) adjusted_chromosome[index_L5] = random.uniform(*bounds['L5']) adjusted_chromosome[index_L6] = random.uniform(*bounds['L6']) adjusted_chromosome[index_L7] = random.uniform(*bounds['L7']) adjusted_chromosome[index_VCM] = random.uniform(*bounds['VCM']) else: # Adjust W1 and L1 based on the original conditions adjusted_chromosome[index_W1] *= 0.9 # Decrease "W" by 2% changed to 3% adjusted_chromosome[index_L1] *= 1.1 # Increase "L" by 2% changed to 3% if transistor in ["M3", "M4"]: index_W3 = design_space_bounds.index('W3') index_L3 = design_space_bounds.index('L3') # Check if both W1 and L1 are at specific values if (chromosome[index_W1] == 28e-6) and (chromosome[index_L1] == 0.18e-6): # Randomly choose new values for W3 and L3 within specified bounds adjusted_chromosome[index_W3] = random.uniform(*bounds['W3']) adjusted_chromosome[index_L3] = random.uniform(*bounds['L3']) else: adjusted_chromosome[index_W3] *= 1.05 # Increase "W" by 5% adjusted_chromosome[index_L3] *= 0.95 # Decrease "L" by 5% if transistor in ["M5", "M8"]: index_W5 = design_space_bounds.index('W5') index_L5 = design_space_bounds.index('L5') # Check if both W1 and L1 are at specific values if (chromosome[index_W1] == 24e-6) and (chromosome[index_L1] == 0.18e-6): # Randomly choose new values for W5 and L5 within specified bounds adjusted_chromosome[index_W5] = random.uniform(*bounds['W5']) adjusted_chromosome[index_L5] = random.uniform(*bounds['L5']) else: adjusted_chromosome[index_W5] *= 1.05 # Increase "W" by 5% adjusted_chromosome[index_L5] *= 0.95 # Decrease "L" by 5% if transistor == "M6": index_W6 = design_space_bounds.index('W6') index_L6 = design_space_bounds.index('L6') # Check if both W1 and L1 are at specific values if (chromosome[index_W1] == 32e-6) and (chromosome[index_L1] == 1e-6): # Randomly choose new values for W6 and L6 within specified bounds adjusted_chromosome[index_W6] = random.uniform(*bounds['W6']) adjusted_chromosome[index_L6] = random.uniform(*bounds['L6']) else: adjusted_chromosome[index_W6] *= 0.9 # Decrease "W" by 10% adjusted_chromosome[index_L6] *= 1.1 # Increase "L" by 10% if transistor == "M7": index_W7 = design_space_bounds.index('W7') index_L7 = design_space_bounds.index('L7') # Check if both W1 and L1 are at specific values if (chromosome[index_W1] == 13.5e-6) and (chromosome[index_L1] == 1e-6): # Randomly choose new values for W7 and L7 within specified bounds adjusted_chromosome[index_W7] = random.uniform(*bounds['W7']) adjusted_chromosome[index_L7] = random.uniform(*bounds['L7']) else: adjusted_chromosome[index_W7] *= 0.7 # Decrease "W" by 10% change it to 0.9 adjusted_chromosome[index_L7] *= 1.1 # Increase "L" by 10% - Assistant