Scipy Minimize Not Varying Optimization Variables as Supposed to

I am trying to optimize for a given date of deposit and withdrawal of a given commodity in a storage considering that the storage max capacity is 50 and the rate of injection/withdrawal is 5/day. Assume that it costs 0.01 per month to store the commodity. My commodity prices list is equally spaced in monthly dates.
At first I want to try to optimize for a single injection and withdrawn and next extend for multiples injections and withdrawns for the given timeframe i am analyzing.

So I created few constraint functions

i. withdrawal date > deposit date

ii. total volume injected – total volume withdrawn < 50

iii. volume injected = volume withdrawn

iv. withdrawn <= 5 per day

v. deposit <= 5 per day

The profit function is given by
i. volume withdrawn * commodity_price[date_withdrawn] – volume injected * commodity_price[date injected] – cost*(date withdrawn – date injected)

The code is as follows:

    ##Volume in mm BBTUs
    max_volume = 50
    ##Volume in mm BBTUs per day
    rate = 5
    ##Cost in million dollars per day
    costs = 0.01

    commodity_prices = hw_nat_gas['Complete'].to_list()


    from scipy.optimize import minimize


    def constraint1(dates):
        deposit_date, withdrawal_date, volume_deposit, volume_withdrawal = dates
        return withdrawal_date - deposit_date

    # Define constraint function for volume constraint
    def constraint_volume(dates):
        deposit_date, withdrawal_date, volume_deposit, volume_withdrawal = dates  
        total_volume = volume_deposit - volume_withdrawal 
        return max_volume - total_volume 

    def constraint_volume2(dates):
        deposit_date, withdrawal_date, volume_deposit, volume_withdrawal = dates  
        return volume_deposit - volume_withdrawal

    def profit_function(dates):
        deposit_date, withdrawal_date, volume_deposit, volume_withdrawal = map(int, dates)
        profit = volume_withdrawal*commodity_prices[withdrawal_date] -     volume_deposit*commodity_prices[deposit_date] - costs*(deposit_date-withdrawal_date)
        return -profit

    def withdrawal(dates):
        deposit_date, withdrawal_date, volume_deposit, volume_withdrawal = map(int, dates)
        return rate - volume_withdrawal

    def deposit(dates):
        deposit_date, withdrawal_date, volume_deposit, volume_withdrawal = map(int, dates)
        return rate - volume_deposit

    constraints = [{'type': 'ineq', 'fun': constraint1},
                   {'type': 'ineq', 'fun': constraint_volume},
                   {'type': 'ineq', 'fun': withdrawal},
                   {'type': 'ineq', 'fun': deposit},
                   {'type': 'eq', 'fun' : constraint_volume2}]

    bounds = [(0, 58), (0, 58), (0,5), (0,5)]

    initial_guess = [7, 12, 0, 0]

    result = minimize(profit_function, initial_guess, bounds=bounds, constraints=constraints)

At first what I am getting is that there is no variation in the dates of deposit and withdrawal, it simply optimizes for the initial guess, the value i am inserting in the scipy.minimize function. Second, it is not varying as well the volumes for injection.

If I instead of using initial guess of [7, 12, 0, 0] use [7, 12, 5, 5] the value of the profit increases, but i wanted the function to perform this analysis by itself, by varying the parameters and obtaining the combination of values that get the max profit.

Any suggestions?

New contributor

Arthur is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật