I am trying to solve a hypothetical linear problem using PuLP. The problem aims at minimizing the costs of an operation over a 5 year horizon while maximizing product shape and condition. The problem must generate 5 costs, one for each year while optimizing the system as a whole and the operations of each year.
total_cost = [(var_cost[year] + fix_cost[year] + cost_new_sensors[year]) for year in range(0,5)]
The total_cost
involves maintaining three types of sensors:
# units price_new fixed_cost_per_unit_per_yr variable_costs_pr_yr_pr_unit
sensor_type_a 300 $50 rent + insurance power + maint
sensor_type_b 900 $75 rent + insurance power + maint
sensor_type_c 1500 $90 maint + insurance -
- The problem must consider that for each year, the sensors are in
better condition than the year before as well as there can't be more
than 12% of sensors with a condition of
"Very poor"
. - The system should be able to replace a sensor type with another or downgrade a new sensor purchase if the exposure isn't high. (This statement isn't related to this post)
For sensor_type_a
:
- Fixed costs:
- the rent for years 1 to 5 per unit are
[50, 55, 55, 55, 60]
- the insurance per unit for years 1 to 5 are
[ 1.0, 1.2, 1.2, 1.8, 2.0]
- the rent for years 1 to 5 per unit are
- Variable costs:
- power is based on number of items the sensor measured:
10+.05*each_measurement
. Price goes up by 1% per year - maintenance is based on
$500 for the total number of sensors + each_measurement*2.45
. Price goes up by 2% year
- power is based on number of items the sensor measured:
- exposure index indicates the status of each sensor and is based on the following table:
_
exposure(# of measurements) category
<=100 excellent
250 good
400 poor
>=400 very poor
For sensor_type_b
:
- Fixed costs:
- the rent for years 1 to 5 per unit are
[60, 65, 65, 70, 75]
- the insurance per unit for years 1 to 5 are
[ 1.1, 1.3, 1.4, 1.7, 2.0]
- the rent for years 1 to 5 per unit are
- Variable costs:
- power is based on number of items the sensor measured:
10+.08*each_measurement
. Price goes up by 1% per year - maintenance is based on
$500 for the total number of sensors + each_measurement*2.65
. Price goes up by 1.5% year
- power is based on number of items the sensor measured:
- Exposure index indicates the status of each sensor and is based on the following table:
_
exposure(# of measurements) category
<=200 excellent
350 good
500 poor
>=500 very poor
For sensor_type_c
:
- Fixed costs:
- Maintenance for all units for years 1 to 5 are
[5000, 5100, 5200, 5300, 5400]
- the insurance per unit for years 1 to 5 are
[ 1.1, 1.3, 1.4, 1.7, 2.0]
- Maintenance for all units for years 1 to 5 are
- Exposure index indicates the status of each sensor and is based on the following table:
_
exposure(# of measurements) category
<=300 excellent
450 good
600 poor
>=600 very poor
My objective function/equation is one of minimization:
problem = pulp.LpProblem(’Cost Minimization’, pulp.LpMinimize)
My constraints:
I am having troubles setting up the constraint functions. Here is what I am conceptually thinking of doing (mix of pseudo and python):
problem += sum([fixed_costs[yr][a] + var_costs[yr][a]
for a in sensor_type_a
for yr in years])
problem += sum([fixed_costs[yr][b] + var_costs[yr][b]
for a in sensor_type_b
for yr in years])
problem += sum([fixed_costs[yr][c] + var_costs[yr][c]
for a in sensor_type_c
for yr in years])
problem += sum(sensor_type_[a].condition('very poor') + \
sensor_type_[b].condition('very poor') + \
sensor_type_[c].condition('very poor')) <= 12%
problem += sum(sensor_type_[a].average_condition(yr) + \
sensor_type_[b].average_condition(yr) + \
sensor_type_[c].average_condition(yr) >=
sensor_type_[a].average_condition(yr-1) + \
sensor_type_[b].average_condition(yr-1) + \
sensor_type_[c].average_condition(yr-1)
Question:
If I'm not on the right track with my pseudo+python, how can I setup my constraints properly to solve the problem?
Note that I have a table for each item filled in for each variables with the proper categories and data points
Edit to reflect on the comments below:
In total there are 2,700 units or locations to be measured. I have a table of the following nature:
unit_ID actual_2013 forecasted_2014 forecasted_2015 forecasted_2016 forecasted_2017
1 25 30 40 35 50
2 400 430 460 480 50
n x_1 x_2 x_3 x_4 x_5
The model cannot change the make up of sensor types for this year however, it should be able to model it adequately for future years. Meaning that include the cost of replacement etc, to get better sensors and a reduced overall cost.
Units are interchangeable.