简体   繁体   English

PuLP-Python-酒店收入优化

[英]PuLP - Python - Hotel Revenue Optimization

I'm trying to re-create a paper that uses linear programming to optimize hotel revenue. 我正在尝试重新创建一篇使用线性规划来优化酒店收入的论文。 I have many different x[i,j] that I am trying to solve for where x is bookings accepted and i is check in day and j is check out day. 我尝试解决许多不同的x [i,j],其中x是接受预订的地方,i是入住日,j是退房日。 I have demand for each of these [i,j] pairs that I am importing and that the bookings accepted must be <= demand. 我对我要导入的每对[i,j]都有需求,并且接受的预订必须为需求。 For the life of me I can't figure out how to program the constraint that on any given day k that the people already in the hotel + people checking in on day k - people checking out on day k must be <= capacity. 对于我自己的一生,我无法弄清楚如何编程在任何给定的k天已经在酒店的人+在k天入住的人-在k天退房的人必须<=容量的约束。 Here is what I'm trying to code up: 这是我要编写的代码: 约束

Here's my code so far: 到目前为止,这是我的代码:

import pandas as pd
import pulp

# Instantiate our problem class
model = pulp.LpProblem("Hotel revenue maximization", pulp.LpMaximize)

#Import demand info
demand= pd.DataFrame.from_csv("demandSAHRO.csv", index_col=
['Check_in_day_i', 'Check_out_day_j'])

#Will optimize for # bookings to accept for any i,j pairing
bookingsaccepted = pulp.LpVariable.dicts("bookingsaccepted",
                                 ((i, j) for i, j in demand.index), lowBound=0, cat='Integer')


# Objective Function - 0.84 is unit revenue per room
model += (
pulp.lpSum([
    0.84 * bookingsaccepted[i, j] for i, j in demand.index])
)

# Constraints
capacity = 400


#Accepted Check in before day k + accepted check in on day k - accepted check out on day k <= capacity
model +=
for i, j in demand.index:
    for k in range(1,10):
    #Day k between check in and check out dates
        while i<k<j:
            #Rooms already occupied during night k
            pulp.lpSum([bookingsaccepted[i, j] for i, j in demand.index]))
            +
            #Rooms checking in on day k

            -

            #Rooms checking out on day k

I'm new to coding in Python and brand new to using PuLP so any help is greatly appreciated. 我是使用Python编码的新手,也是使用PuLP的新手,因此非常感谢您的帮助。

I created some data to test some cases and I think the following should work. 我创建了一些数据来测试某些情况,并且我认为以下应该可行。 If it does not, please share your demandSAHRO.csv data and I will try to tweak it: 如果没有,请分享您的demandSAHRO.csv数据,我将尝试对其进行调整:

for k in range(1, T):
     model += pulp.lpSum([bookingsaccepted[i, j] \
                        + bookingsaccepted[k, j] \
                        - bookingsaccepted[i, k] \
                        for i, j in demand.index if i < k < j]) \
                        <= capacity

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM