Code Documentation¶
-
class
inventory.
InventoryOptim
(df, units_costs, date_fld='date', start_date=None, num_intrvl=(0.0, 10.0), projection_date=None, c_limit=0.95, min_samples=5, error_tol=0.0001)[source]¶ Parameters: - df – the DataFrame containing data point
- units_costs – a list of pairs \((G_i, C_i)\).
- date_fld – string the name of the column keeping each row’s date
- start_date – None or datetime`the start date of the analysis; if `None the minimum date found in date_fld is used.
- num_intrvl – 2-tuple the numerical range to be used for converting dates to numbers
- projectioni_date – datetime the target date of the analysis
- c_limit – float between 0 and 1, the confidence interval
- min_samples – int minimum number of samples to perform Monte Carlo sampling
- error_tol – float error tolerance
-
adjust_system
(tbo='u')[source]¶ Forms and solves the optimization problem for trend adjustment
Parameters: tbo – char if ‘u’ only trends will be adjusted regardless of unit costs. if ‘b’ costs of units will be used to adjust trends
-
constraint
(fld, value, dt)[source]¶ Suggest a constraint for future.
Parameters: - fld – str the column whose values is about to be adjusted
- value – float the suggested value for the given date
- dt – datetime the suggested date for adjustment
-
date2num
(dt)[source]¶ Converts a datetime to a number according to self.num_intrvl
Parameters: dt – datetime
-
make_date_interval_val
(dt, n_days)[source]¶ Converts the outcome of self.make_date_interval into a list of floats
-
refit
(fld, val, dt, n_points)[source]¶ Refits the regressor of the fld after producing n_points samples points around dt using a normal distribution centered at val
Parameters: - fld – the regression associated to fld will be refitted
- val – the suggested value for the regression curve at dt
- dt – the suggested datetime to make adjustments to the values of fld
- n_points – number of samples to be generated for refitting