import pandas as pd
import numpy as np

def generate_price_schedule():
    records = []
    # 假设一天分为三个时段：谷时、平时、峰时
    times = [('00:00', '06:00', 0.25),  
             ('06:00', '18:00', 0.3),  
             ('18:00', '24:00', 0.35)]  
    
    # 随机调整每天的电价以增加现实性
    for time_start, time_end, base_price in times:
        # 随机浮动5%以内
        fluctuation = np.random.uniform(-0.005, 0.005)
        price = round(base_price + fluctuation, 3)
        records.append({'time_start': time_start, 'time_end': time_end, 'price': price})
    
    return pd.DataFrame(records)

# 生成电价计划
price_schedule = generate_price_schedule()
price_schedule.to_csv('price_schedule.csv', index=False)
print("Price schedule generated and saved to price_schedule.csv.")
print(price_schedule)