tpaviot / ProcessScheduler

A Python package for automatic and optimized resource scheduling
https://processscheduler.github.io/
GNU General Public License v3.0
59 stars 18 forks source link

Cost improvements #38

Closed tpaviot closed 3 years ago

tpaviot commented 3 years ago

This PR extends the concept of Cost for a resource. A new _Cost base class is created, and two derivates ConstantCostPerPeriod and PolynomialCostFunction. PolynomialCostFunction takes any python function expressed as a polynomial.

def cost_function(t):
            return 23 * t + 3

worker_1 = ps.Worker('Worker1', cost=ps.PolynomialCostFunction(cost_function))
tpaviot commented 3 years ago

The CumulativeWorker still has to be ported to the new API.

tpaviot commented 3 years ago

Regarding cost function optimization, see issue https://github.com/Z3Prover/z3/issues/5254

tpaviot commented 3 years ago

According to me, the penalty that has to be considered in the TODO list is actually a cost. But it's not a cost that is measured in euro or dollars per time period. The same base could be used for the penalty, and we could even imagine negative costs (or negative penalties). Negative penalties could be used to promote tasks or resources

codecov-commenter commented 3 years ago

Codecov Report

Merging #38 (afafa23) into master (c1a1e73) will decrease coverage by 0.40%. The diff coverage is 92.43%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #38      +/-   ##
==========================================
- Coverage   97.88%   97.47%   -0.41%     
==========================================
  Files          24       26       +2     
  Lines        2692     2891     +199     
==========================================
+ Hits         2635     2818     +183     
- Misses         57       73      +16     
Impacted Files Coverage Δ
test/test_indicator.py 98.87% <ø> (-0.14%) :arrow_down:
processscheduler/cost.py 83.33% <83.33%> (ø)
test/test_cost.py 93.75% <93.75%> (ø)
processscheduler/resource.py 97.53% <96.00%> (-0.89%) :arrow_down:
processscheduler/__init__.py 87.50% <100.00%> (+0.83%) :arrow_up:
processscheduler/problem.py 96.36% <100.00%> (+2.07%) :arrow_up:
test/test_cumulative.py 98.96% <100.00%> (-0.14%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c1a1e73...afafa23. Read the comment docs.