0

We now have a scenario where the cost of sending SMS channels is optimal. There are hundreds of channels, which support different types of SMS messages, different suppliers, and multiple operators. In addition, each channel has different prices and its daily sending volume is limited. I have substituted these constraints into the objective function, but what troubles me now is how to substituted the step-like conditions, such as the cost of sending a single message in different intervals is different.Currently using the linear programming package pulp

I'm just substituting the first ladder now, but it's obviously inappropriate

##TODO minimum price expression
    sentPrice=None
    SHlinkNum=None
    SZMoveNum=None
    for dictType in channel_vars:
        for typeKeys in dictType.keys():
            if supplier["SHlink"].__contains__(typeKeys):
                SHlinkNum+=dictType[typeKeys]
            elif  supplier["SZmove"].__contains__(typeKeys):
                SZMoveNum+=dictType[typeKeys]
            chanPrice=round(cost.get(typeKeys,0),2)
            sentPrice+=chanPrice*dictType[typeKeys]
    SHsuppNum=supplierSent.get("SHlink",0)
    SZsuppNum=supplierSent.get("SZmove",0)

##TODO Channel Minimum Cost Constraints
    prob+=SHlinkNum==int((supplierTarget["SHlink"]-SHsuppNum)/date_diff),"SHlinkLimitNum"
    prob+=SZMoveNum==int((supplierTarget["SZmove"]-SZsuppNum)/date_diff),"SZmoveLimitNum"
    prob+=(lpSum(sentPrice+SHsuppNum*0.0+SZMoveNum*0.0),
           "Total cost of channels per chan"
           )
  • It isn't clear what your question is. If you are having trouble modeling some concept, you have a better chance of getting helpful answers if you include some sample data and a clearer explanation of what you want the code to do and where it is failing. If it is a "generalized concept", a toy problem with fake data is just fine to illustrate the point. – AirSquid Jan 19 '23 at 19:43
  • Can you elaborate on how your code "doesn't work"? What were you expecting, and what actually happened? If you got an exception/error, post the line it occurred on and the exception/error details which can be done with a [mre]. Please [edit] your question to add these details into it or we may not be able to help. – Jim G. Jan 20 '23 at 19:02

0 Answers0