# Define Circuit Environment
class CircuitEnvironment:
    VERY_CLOSE_REWARD = 40
    LARGE_REWARD = 10
    VERY_HIGH_REWARD = 50
    PENALTY = 20
    SEVERE_PENALTY = 200
    REGULAR_PENALTY = 100

    def __init__(self, bounds_low, bounds_high):
        # Initialization code: setup bounds

    def calculate_reward(self, c_metrics, p_metrics):
        metrics_order = ['gain', 'bw', 'ugf', 'pm']
            
        reward = 0

        target_metrics = {k: self.target_metrics[i] for i, k in enumerate(metrics_order)}
        print("target_metrics", target_metrics)
        for metric_name in metrics_order:
            c_value = c_metrics[metric_name]
            p_value = p_metrics[metric_name]
            target_value = target_metrics[metric_name]
            
            # First condition: Penalty if 'gain' metric is negative, or lessthan 20 and 'pm' is beyond required limit
            if metric_name == 'gain':
                if c_value < 0:
                    reward -= self.SEVERE_PENALTY
                    return reward
                elif c_value < 20:
                    reward -= self.REGULAR_PENALTY
                    return reward
            elif metric_name == 'pm':
                if c_value < 60 or c_value > 75:
                    reward -= self.REGULAR_PENALTY
                    return reward

            # Second condition: Check if c_value is exactly the target value
            if c_value == target_value:
                reward += self.VERY_HIGH_REWARD
                continue

            # Third condition: Check if c_value is very close to the target value
            if metric_name == 'gain' and abs(c_value - target_value) <= 1:
                reward += self.VERY_CLOSE_REWARD
                continue
            elif metric_name == 'bw' and abs(c_value - target_value) <= 1000:
                reward += self.VERY_CLOSE_REWARD
                continue
            elif metric_name == 'ugf' and abs(c_value - target_value) <= 1000000:
                reward += self.VERY_CLOSE_REWARD
                continue
            elif metric_name == 'pm' and abs(c_value - target_value) <= 1:
                reward += self.VERY_HIGH_REWARD
                continue

            # Fourth condition: Check if c_value is closer to target value than p_value
            if abs(c_value - target_value) < abs(p_value - target_value):
                reward += self.LARGE_REWARD
            else:
                # Fifth condition: Apply penalty if none of the above conditions are met
                reward -= self.PENALTY
                
        return reward

I modified the first condition with the below conditions and after the modification i am not getting the expected reward as outputs
with in first condition i include additional checking logic,
here already i had on condition in the c_value, if the metric_name 'gain' is lessthan 0 then give severe penalty of 200 and return the reward without check any further condition below, along with this i added the additional conditions, if the 'gain' is lessthan 0 is true then return the reward without checking further conditions, if gain is not lessthan 0 need to check the two conditions if either one is true we need to give penalty of 100 and return the reward without checking any other further conditions,
in the c_value, either the metric_name 'gain' is lessthan 20, or if the metric_name 'pm' is not between 60 to 75, any one condition is true then we need to give penalty as 100. and return the reward no further conditions are need to be check.
if all the above first conditions are failed then need to check second, third, fourth and fifth conditions for reward generation.

Results of the above code
the condition was not properly satisfied in the results of the above code, please check the above code and update any conditions were not properly implemented

performance_metrics {'gain': 38, 'bw': 39000, 'ugf': 3000000, 'pm': 61}
target_metrics {'gain': 56.0, 'bw': 10000.0, 'ugf': 7000000.0, 'pm': 66.0}
Reward: 40
this condition is correct

performance_metrics {'gain': 56, 'bw': 6000, 'ugf': 12000000, 'pm': 145}
target_metrics {'gain': 56.0, 'bw': 10000.0, 'ugf': 7000000.0, 'pm': 66.0}
Reward: -60
here i need to get -100(because 'pm' is not satisfies in the first condition) but i am wrongly getting -60(because the further conditions are checking without returning the reward at the first condition is true)

performance_metrics {'gain': 55, 'bw': 32000, 'ugf': 16000000, 'pm': 11}
target_metrics {'gain': 56.0, 'bw': 10000.0, 'ugf': 7000000.0, 'pm': 66.0}
Reward: -100
this is correct

performance_metrics {'gain': 21, 'bw': 453000, 'ugf': 10000000, 'pm': 7}
target_metrics {'gain': 56.0, 'bw': 10000.0, 'ugf': 7000000.0, 'pm': 66.0}
Reward: -130
here i need to get -100(because 'pm' is not satisfies in the first condition) but i am wrongly getting -130(because the further conditions are checking without returning the reward at the first condition is true)

performance_metrics {'gain': 54, 'bw': 34000, 'ugf': 17000000, 'pm': 68}
target_metrics {'gain': 56.0, 'bw': 10000.0, 'ugf': 7000000.0, 'pm': 66.0}
Reward: 10
this is correct

performance_metrics {'gain': 16, 'bw': 432000, 'ugf': 3000000, 'pm': 74}
target_metrics {'gain': 56.0, 'bw': 10000.0, 'ugf': 7000000.0, 'pm': 66.0}
Reward: -100
this is correct

performance_metrics {'gain': 35, 'bw': 102000, 'ugf': 9000000, 'pm': 10}
target_metrics {'gain': 56.0, 'bw': 10000.0, 'ugf': 7000000.0, 'pm': 66.0}
Reward: -70
here i need to get -100(because 'pm' is not satisfies in the first condition) but i am wrongly getting -70(because the further conditions are checking without returning the reward at the first condition is true)