| import gradio as gr | |
| from utils import * | |
| def gap_func(demand,inventory,customer_1_proportion_percent,high_price,low_price): | |
| customer_1_prop = customer_1_proportion_percent / 100 | |
| model = ModelInfo(ARRIVAL_RATE=demand, | |
| STARTING_INVENTORY=inventory, | |
| CUSTOMER_1_PROP=customer_1_prop, | |
| CUSTOMER_2_PROP=1-customer_1_prop, | |
| HIGH_PRICE=high_price, | |
| LOW_PRICE=low_price) | |
| gap = gap_between_dynamic_and_static(model=model) | |
| dynamic = get_best_dynamic_threshold(model=model) | |
| dynamic_rev,inv_threshold = dynamic | |
| static_result= get_static_pricing(model=model) | |
| low_low,high_high,high_low = static_result | |
| return gap,dynamic_rev,inv_threshold,low_low,high_high,high_low | |
| demo = gr.Interface(fn=gap_func, | |
| inputs=[gr.Slider(0, 30,value=1,step=1), | |
| gr.Slider(0, 30,value=2,step=1), | |
| gr.Slider(0, 100,value=50,step=1), | |
| "number", | |
| "number"], | |
| outputs=[gr.Textbox(label='Gap'), | |
| gr.Textbox(label='Inventory_threshold'), | |
| gr.Textbox(label='Dynamic'), | |
| gr.Textbox(label='Low-Low'), | |
| gr.Textbox(label='High-High'), | |
| gr.Textbox(label='High-Low')]) | |
| if __name__ == "__main__": | |
| demo.launch() |