GirishaBuilds01 commited on
Commit
164221b
·
verified ·
1 Parent(s): 9a52aae

Create uei_core/policy.py

Browse files
Files changed (1) hide show
  1. uei_core/policy.py +26 -0
uei_core/policy.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class UEIPolicy:
2
+
3
+ def __init__(self, uncertainty_threshold=0.20, energy_ratio_threshold=0.5):
4
+ self.uncertainty_threshold = uncertainty_threshold
5
+ self.energy_ratio_threshold = energy_ratio_threshold
6
+
7
+ def decide(self, U_small, U_large, E_small, E_large):
8
+ """
9
+ Decide if escalation is needed based on uncertainty-energy marginal utility.
10
+ """
11
+
12
+ if float(U_small) < self.uncertainty_threshold:
13
+ return "small"
14
+
15
+ marginal_gain = float(U_small - U_large)
16
+ marginal_energy = float(E_large - E_small)
17
+
18
+ if marginal_gain <= 0:
19
+ return "small"
20
+
21
+ ratio = marginal_gain / (marginal_energy + 1e-8)
22
+
23
+ if ratio < self.energy_ratio_threshold:
24
+ return "small"
25
+ else:
26
+ return "large"