I am working on a Copper payables problem where the objective function is to maximise the sum of copper payable over a time period, T.
The total amount of payable tonnes i.e. what the customer will pay for is dependent on the copper content of the sales material.
- Each customer has a number of payable terms expressed as copper specification operable bounds, as per the below example data:
Customer data
import io
import pandas as pd
customer_payables = """customer, tier, specvalue_1, specoperator_1, specvalue_2, \
specoperator_2, coeff
'abc', 1, 0, '>=', 20, '<=', 96.0
'abc', 2, 20, '>', 24, '<=', 96.5
'abc', 3, 24, '>', 100, '<=', 96.65
'def', 1, 0, '>=', 20, '<=', 96.0
'def', 2, 20, '>=', 22, '<=', 96.66
'def', 3, 22, '>=', 100', '<=', 97.0
"""
_cust_data = io.StringIO(customer_payables)
cust_df = pd.read_csv(_cust_data, sep=",")
cust_df = cust_df.set_index('customer')
cust_df
- I have a dataframe of available material, in tonnes, with specific copper content in two warehouse with two stockpiles. Note that the quality of this material changes over time:
Stockpile Data
stockpile_data_dict = {
'Warehouse 1': {
'Stockpile 1': {'cu': 27},
'Stockpile 2': {'cu': 18}
},
'Warehouse 2': {
'Stockpile 1': {'cu': 22},
'Stockpile 2': {'cu': 16}
}
}
stockpile_df = pd.concat(
{k: pd.DataFrame(v).T for k, v in stockpile_data_dict.items()}, axis=0)
stockpile_df
Question I have created a variable to represent the copper concentration for each warehouse, stockpile (and time period, but this is not reflected here for simplicities sake).
How can I create a linear constraint that returns the correct payable coefficient with respect to the copper concentration VALUE of this variable?
I do not use Pulp very often, so please bear with me.
All help gratefully received, thank you.