most-queue 1.63__tar.gz → 2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of most-queue might be problematic. Click here for more details.
- most_queue-2.2/.pre-commit-config.yaml +47 -0
- {most_queue-1.63 → most_queue-2.2}/PKG-INFO +66 -10
- {most_queue-1.63 → most_queue-2.2}/README.md +65 -9
- {most_queue-1.63 → most_queue-2.2}/docs/source/conf.py +10 -13
- {most_queue-1.63/most_queue/general → most_queue-2.2/most_queue/distr_utils}/__init__.py +0 -0
- most_queue-1.63/most_queue/general/interfaces.py → most_queue-2.2/most_queue/distr_utils/base_distribution.py +2 -2
- {most_queue-1.63/most_queue/general → most_queue-2.2/most_queue/distr_utils}/distribution_fitting.py +28 -41
- most_queue-1.63/most_queue/rand_distribution.py → most_queue-2.2/most_queue/distributions.py +52 -47
- {most_queue-1.63 → most_queue-2.2}/most_queue/general/plots.py +1 -1
- most_queue-2.2/most_queue/general/results_structs.py +163 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/general/tables.py +7 -21
- {most_queue-1.63 → most_queue-2.2}/most_queue/misc/approx_cdf_make.py +4 -8
- {most_queue-1.63 → most_queue-2.2}/most_queue/misc/calc_v_pls.py +27 -17
- {most_queue-1.63 → most_queue-2.2}/most_queue/misc/compare_fj_calc.py +3 -1
- {most_queue-1.63 → most_queue-2.2}/most_queue/misc/flow_sum.py +13 -16
- {most_queue-1.63 → most_queue-2.2}/most_queue/misc/run_mgn_with_h2_delay_cold_warm.py +81 -81
- {most_queue-1.63 → most_queue-2.2}/most_queue/misc/test_fj_delta.py +10 -12
- {most_queue-1.63 → most_queue-2.2}/most_queue/misc/test_network_opt_approx.py +8 -7
- {most_queue-1.63 → most_queue-2.2}/most_queue/misc/test_network_opt_plus.py +7 -7
- {most_queue-1.63 → most_queue-2.2}/most_queue/misc/vacations_paper_utils.py +5 -5
- {most_queue-1.63/most_queue/sim/networks → most_queue-2.2/most_queue/sim}/__init__.py +0 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/base.py +24 -31
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/batch.py +3 -1
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/finite_source.py +1 -1
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/flow_sum.py +15 -10
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/fork_join.py +1 -1
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/fork_join_delta.py +4 -6
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/negative.py +21 -17
- most_queue-2.2/most_queue/sim/networks/base_network_sim.py +103 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/networks/network.py +86 -51
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/networks/priority_network.py +125 -89
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/priority.py +83 -76
- {most_queue-1.63/most_queue/theory → most_queue-2.2/most_queue/sim/utils}/__init__.py +0 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/utils/distribution_utils.py +17 -15
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/utils/servers.py +11 -12
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/utils/tasks.py +5 -7
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/vacations.py +27 -8
- {most_queue-1.63/most_queue/theory/batch → most_queue-2.2/most_queue/theory}/__init__.py +0 -0
- most_queue-2.2/most_queue/theory/base_queue.py +75 -0
- most_queue-2.2/most_queue/theory/batch/mm1.py +158 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/calc_params.py +5 -6
- most_queue-2.2/most_queue/theory/closed/engset.py +193 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/fifo/ek_d_n.py +80 -48
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/fifo/gi_m_1.py +92 -35
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/fifo/gi_m_n.py +92 -40
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/fifo/m_d_n.py +45 -13
- most_queue-2.2/most_queue/theory/fifo/mg1.py +132 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/fifo/mgn_takahasi.py +102 -50
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/fifo/mmnr.py +61 -11
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/fork_join/m_m_n.py +98 -19
- most_queue-2.2/most_queue/theory/fork_join/split_join.py +135 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/impatience/mm1.py +62 -15
- most_queue-2.2/most_queue/theory/negative/mg1_disasters.py +129 -0
- most_queue-2.2/most_queue/theory/negative/mg1_rcs.py +117 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/negative/mgn_disaster.py +221 -185
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/negative/mgn_rcs.py +144 -107
- most_queue-2.2/most_queue/theory/negative/structs.py +1 -0
- most_queue-2.2/most_queue/theory/networks/base_network_calc.py +123 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/networks/network_viewer.py +2 -6
- most_queue-2.2/most_queue/theory/networks/open_network.py +165 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/networks/open_network_prty.py +69 -31
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/networks/opt/transition.py +28 -34
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/networks/opt/transition_approx.py +18 -18
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/networks/opt/transition_plus.py +12 -12
- most_queue-2.2/most_queue/theory/priority/mgn_invar_approx.py +180 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/priority/non_preemptive/mg1.py +60 -7
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/priority/preemptive/m_ph_n_busy_approx.py +131 -60
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/priority/preemptive/mg1.py +48 -29
- most_queue-1.63/most_queue/theory/priority/preemptive/mmn_3cls_busy_approx.py → most_queue-2.2/most_queue/theory/priority/preemptive/mm2_3cls_busy_approx.py +226 -157
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/priority/preemptive/mmn_2cls_pr_busy_approx.py +183 -115
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/utils/busy_periods.py +3 -7
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/utils/conditional.py +5 -12
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/utils/diff5dots.py +3 -9
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/utils/flow_sum.py +8 -16
- most_queue-2.2/most_queue/theory/utils/max_dist.py +196 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/utils/passage_time.py +29 -41
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/utils/q_poisson_arrival_calc.py +4 -16
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/utils/student_stat.py +1 -5
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/utils/transforms.py +2 -4
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/utils/utilization_approx.py +4 -1
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/vacations/m_h2_h2warm.py +185 -140
- most_queue-2.2/most_queue/theory/vacations/mg1_warm_calc.py +120 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/vacations/mgn_with_h2_delay_cold_warm.py +160 -122
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/vacations/mmn_with_h2_cold_and_h2_warmup.py +258 -192
- most_queue-2.2/pyproject.toml +69 -0
- {most_queue-1.63 → most_queue-2.2}/requirements.txt +0 -1
- most_queue-2.2/setup.py +31 -0
- most_queue-2.2/tests/Dockerfile +13 -0
- most_queue-2.2/tests/run.sh +5 -0
- {most_queue-1.63 → most_queue-2.2}/tests/test_base_qs_sim.py +17 -12
- {most_queue-1.63 → most_queue-2.2}/tests/test_batch.py +10 -6
- {most_queue-1.63 → most_queue-2.2}/tests/test_ek_d_n.py +21 -16
- {most_queue-1.63 → most_queue-2.2}/tests/test_engset.py +14 -29
- {most_queue-1.63 → most_queue-2.2}/tests/test_fj_sim.py +35 -29
- {most_queue-1.63 → most_queue-2.2}/tests/test_gi_m_1_calc.py +22 -24
- {most_queue-1.63 → most_queue-2.2}/tests/test_gi_m_n_calc.py +25 -24
- {most_queue-1.63 → most_queue-2.2}/tests/test_impatience.py +12 -11
- {most_queue-1.63 → most_queue-2.2}/tests/test_m_d_n_calc.py +20 -10
- {most_queue-1.63 → most_queue-2.2}/tests/test_m_h2_h2warm.py +19 -23
- {most_queue-1.63 → most_queue-2.2}/tests/test_m_ph_n_prty.py +28 -42
- {most_queue-1.63 → most_queue-2.2}/tests/test_mg1_calc.py +19 -16
- {most_queue-1.63 → most_queue-2.2}/tests/test_mg1_disaster.py +16 -20
- {most_queue-1.63 → most_queue-2.2}/tests/test_mg1_rcs.py +16 -17
- {most_queue-1.63 → most_queue-2.2}/tests/test_mg1_warmup.py +17 -12
- {most_queue-1.63 → most_queue-2.2}/tests/test_mgn_disaster.py +22 -35
- {most_queue-1.63 → most_queue-2.2}/tests/test_mgn_rcs.py +18 -31
- {most_queue-1.63 → most_queue-2.2}/tests/test_mgn_tt.py +21 -27
- {most_queue-1.63 → most_queue-2.2}/tests/test_mgn_with_h2_delay_cold_warm.py +30 -34
- most_queue-2.2/tests/test_mm2_3cls_prty_busy.py +112 -0
- {most_queue-1.63 → most_queue-2.2}/tests/test_mmn_h2cold_h2warm.py +22 -39
- most_queue-1.63/tests/test_mmn_prty_pnz_approx.py → most_queue-2.2/tests/test_mmn_prty_busy_approx.py +28 -21
- {most_queue-1.63 → most_queue-2.2}/tests/test_network_im_prty.py +31 -45
- {most_queue-1.63 → most_queue-2.2}/tests/test_network_no_prty.py +16 -13
- {most_queue-1.63 → most_queue-2.2}/tests/test_network_opt.py +7 -6
- {most_queue-1.63 → most_queue-2.2}/tests/test_qs_sim.py +16 -7
- {most_queue-1.63 → most_queue-2.2}/tests/test_qs_sim_prty.py +12 -6
- {most_queue-1.63 → most_queue-2.2}/tests/units/test_busy_moments_calc.py +3 -4
- {most_queue-1.63 → most_queue-2.2}/tests/units/test_conditionals.py +6 -5
- {most_queue-1.63 → most_queue-2.2}/tests/units/test_h2_params_cv.py +3 -3
- {most_queue-1.63 → most_queue-2.2}/tests/units/test_queue_types.py +9 -7
- {most_queue-1.63 → most_queue-2.2}/tests/units/test_tt_up_probs.py +5 -4
- {most_queue-1.63 → most_queue-2.2}/tests/units/test_v1_on_channels.py +8 -2
- {most_queue-1.63 → most_queue-2.2}/tests/units/test_v1_utlization_approx.py +3 -1
- most_queue-2.2/tests/units/test_weibull.py +34 -0
- most_queue-2.2/tutorials/m_h2_h2warm.ipynb +310 -0
- most_queue-2.2/tutorials/mgn_takahasi_takami.ipynb +234 -0
- most_queue-2.2/tutorials/network_with_priorities.ipynb +381 -0
- most_queue-2.2/tutorials/priority_queue.ipynb +378 -0
- most_queue-2.2/tutorials/queue_sim.ipynb +387 -0
- {most_queue-1.63 → most_queue-2.2}/works/negative_queues/work_mgn_negatives.py +67 -97
- most_queue-2.2/works/vacations/__init__.py +0 -0
- most_queue-2.2/works/vacations/channels.py +80 -0
- most_queue-2.2/works/vacations/cooling.py +182 -0
- most_queue-2.2/works/vacations/cooling_delay.py +181 -0
- {most_queue-1.63 → most_queue-2.2}/works/vacations/main.py +9 -9
- most_queue-2.2/works/vacations/results/exp_2/cooling/cooling_probs_vs_cool_ave.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/cooling/cooling_probs_vs_cool_cv.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/cooling/w1_error_vs_cool_ave.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/cooling/w1_error_vs_cool_cv.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/cooling/w1_vs_cool_ave.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/cooling/w1_vs_cool_cv.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/cooling_delay/cooling_delay_probs_vs_cool_delay_ave.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/cooling_delay/cooling_delay_probs_vs_cool_delay_cv.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/cooling_delay/w1_error_vs_cool_delay_ave.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/cooling_delay/w1_error_vs_cool_delay_cv.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/cooling_delay/w1_vs_cool_delay_ave.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/cooling_delay/w1_vs_cool_delay_cv.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/parameters.yaml +51 -0
- most_queue-2.2/works/vacations/results/exp_2/w1_errors_vs_channels.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/w1_errors_vs_service_cv.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/w1_errors_vs_utilization.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/w1_vs_channels.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/w1_vs_service_cv.png +0 -0
- most_queue-2.2/works/vacations/results/exp_2/w1_vs_utilization.png +0 -0
- {most_queue-1.63 → most_queue-2.2}/works/vacations/run_one_calc_vs_sim.py +61 -34
- most_queue-2.2/works/vacations/service.py +86 -0
- most_queue-2.2/works/vacations/utilization.py +75 -0
- most_queue-2.2/works/vacations/warmup.py +180 -0
- most_queue-1.63/most_queue/theory/batch/mm1.py +0 -111
- most_queue-1.63/most_queue/theory/closed/engset.py +0 -141
- most_queue-1.63/most_queue/theory/fifo/mg1.py +0 -90
- most_queue-1.63/most_queue/theory/fork_join/split_join.py +0 -314
- most_queue-1.63/most_queue/theory/negative/mg1_disasters.py +0 -77
- most_queue-1.63/most_queue/theory/negative/mg1_rcs.py +0 -90
- most_queue-1.63/most_queue/theory/negative/structs.py +0 -90
- most_queue-1.63/most_queue/theory/networks/open_network.py +0 -126
- most_queue-1.63/most_queue/theory/priority/mgn_invar_approx.py +0 -131
- most_queue-1.63/most_queue/theory/vacations/mg1_warm_calc.py +0 -67
- most_queue-1.63/pyproject.toml +0 -51
- most_queue-1.63/setup.py +0 -29
- most_queue-1.63/tests/units/test_weibull.py +0 -29
- most_queue-1.63/tutorials/m_h2_h2warm.ipynb +0 -334
- most_queue-1.63/tutorials/mgn_takahasi_takami.ipynb +0 -300
- most_queue-1.63/tutorials/network_with_priorities.ipynb +0 -374
- most_queue-1.63/tutorials/priority_queue.ipynb +0 -376
- most_queue-1.63/tutorials/queue_sim.ipynb +0 -378
- most_queue-1.63/works/vacations/channels.py +0 -69
- most_queue-1.63/works/vacations/cooling.py +0 -164
- most_queue-1.63/works/vacations/cooling_delay.py +0 -173
- most_queue-1.63/works/vacations/service.py +0 -75
- most_queue-1.63/works/vacations/utilization.py +0 -74
- most_queue-1.63/works/vacations/warmup.py +0 -166
- {most_queue-1.63 → most_queue-2.2}/.gitignore +0 -0
- {most_queue-1.63 → most_queue-2.2}/LICENSE +0 -0
- {most_queue-1.63 → most_queue-2.2}/assets/1.gif +0 -0
- {most_queue-1.63 → most_queue-2.2}/assets/2.gif +0 -0
- {most_queue-1.63 → most_queue-2.2}/assets/3.gif +0 -0
- {most_queue-1.63 → most_queue-2.2}/assets/queue_long.png +0 -0
- {most_queue-1.63 → most_queue-2.2}/deploy.txt +0 -0
- {most_queue-1.63 → most_queue-2.2}/docs/Makefile +0 -0
- {most_queue-1.63 → most_queue-2.2}/docs/make.bat +0 -0
- {most_queue-1.63 → most_queue-2.2}/docs/source/index.rst +0 -0
- {most_queue-1.63 → most_queue-2.2}/docs/source/modules.rst +0 -0
- {most_queue-1.63 → most_queue-2.2}/docs/source/most_queue.rst +0 -0
- {most_queue-1.63 → most_queue-2.2}/docs/source/most_queue.sim.rst +0 -0
- {most_queue-1.63 → most_queue-2.2}/docs/source/most_queue.theory.rst +0 -0
- {most_queue-1.63 → most_queue-2.2}/doctest-output/QS.gv +0 -0
- {most_queue-1.63 → most_queue-2.2}/googleb31d3dccb40f969f.html +0 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/__init__.py +0 -0
- {most_queue-1.63/most_queue/general → most_queue-2.2/most_queue/distr_utils}/distribution_params.py +0 -0
- {most_queue-1.63/most_queue/sim → most_queue-2.2/most_queue/general}/__init__.py +0 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/impatient.py +0 -0
- {most_queue-1.63/most_queue/sim/utils → most_queue-2.2/most_queue/sim/networks}/__init__.py +0 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/utils/distributions.yaml +0 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/utils/exceptions.py +0 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/utils/phase.py +0 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/utils/qs_queue.py +0 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/sim/utils/stats_update.py +0 -0
- {most_queue-1.63/most_queue/theory/closed → most_queue-2.2/most_queue/theory/batch}/__init__.py +0 -0
- {most_queue-1.63/most_queue/theory/fifo → most_queue-2.2/most_queue/theory/closed}/__init__.py +0 -0
- {most_queue-1.63/most_queue/theory/fork_join → most_queue-2.2/most_queue/theory/fifo}/__init__.py +0 -0
- {most_queue-1.63/most_queue/theory/impatience → most_queue-2.2/most_queue/theory/fork_join}/__init__.py +0 -0
- {most_queue-1.63/most_queue/theory/networks → most_queue-2.2/most_queue/theory/impatience}/__init__.py +0 -0
- {most_queue-1.63/most_queue/theory/networks/opt → most_queue-2.2/most_queue/theory/networks}/__init__.py +0 -0
- {most_queue-1.63/most_queue/theory/priority → most_queue-2.2/most_queue/theory/networks/opt}/__init__.py +0 -0
- {most_queue-1.63/most_queue/theory/priority/non_preemptive → most_queue-2.2/most_queue/theory/priority}/__init__.py +0 -0
- {most_queue-1.63/most_queue/theory/priority/preemptive → most_queue-2.2/most_queue/theory/priority/non_preemptive}/__init__.py +0 -0
- {most_queue-1.63/most_queue/theory/utils → most_queue-2.2/most_queue/theory/priority/preemptive}/__init__.py +0 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/r_example.gexf +0 -0
- {most_queue-1.63/most_queue/theory/vacations → most_queue-2.2/most_queue/theory/utils}/__init__.py +0 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/utils/binom_probs.py +0 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/utils/conv.py +0 -0
- {most_queue-1.63 → most_queue-2.2}/most_queue/theory/utils/residual.py +0 -0
- {most_queue-1.63/tests → most_queue-2.2/most_queue/theory/vacations}/__init__.py +0 -0
- {most_queue-1.63/works → most_queue-2.2/tests}/__init__.py +0 -0
- {most_queue-1.63 → most_queue-2.2}/tests/default_params.yaml +0 -0
- {most_queue-1.63 → most_queue-2.2}/tests/units/h2_params_cv_greater_than_exp.png +0 -0
- {most_queue-1.63 → most_queue-2.2}/tests/units/h2_params_cv_less_than_exp.png +0 -0
- {most_queue-1.63 → most_queue-2.2}/tests/units/v1_on_channels.png +0 -0
- {most_queue-1.63 → most_queue-2.2}/tests/units/v1_on_utilization_approx.png +0 -0
- {most_queue-1.63/works/negative_queues → most_queue-2.2/works}/__init__.py +0 -0
- {most_queue-1.63/works/vacations → most_queue-2.2/works/negative_queues}/__init__.py +0 -0
- {most_queue-1.63 → most_queue-2.2}/works/negative_queues/base_parameters.yaml +0 -0
- {most_queue-1.63 → most_queue-2.2}/works/vacations/base_parameters.yaml +0 -0
- {most_queue-1.63 → most_queue-2.2}/works/vacations/utils.py +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# See https://pre-commit.com for more information
|
|
2
|
+
# See https://pre-commit.com/hooks.html for more hooks
|
|
3
|
+
repos:
|
|
4
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
5
|
+
rev: v3.2.0
|
|
6
|
+
hooks:
|
|
7
|
+
- id: check-yaml
|
|
8
|
+
- id: check-added-large-files
|
|
9
|
+
- id: check-json
|
|
10
|
+
- id: check-toml
|
|
11
|
+
|
|
12
|
+
# - repo: https://github.com/pycqa/isort
|
|
13
|
+
# rev: 6.0.1
|
|
14
|
+
# hooks:
|
|
15
|
+
# - id: isort
|
|
16
|
+
# name: isort (python)
|
|
17
|
+
# args: [ --profile, black ]
|
|
18
|
+
|
|
19
|
+
- repo: https://github.com/psf/black
|
|
20
|
+
rev: 25.1.0
|
|
21
|
+
hooks:
|
|
22
|
+
- id: black
|
|
23
|
+
language_version: python3.12
|
|
24
|
+
|
|
25
|
+
# - repo: local
|
|
26
|
+
# hooks:
|
|
27
|
+
# - id: pylint
|
|
28
|
+
# name: pylint
|
|
29
|
+
# entry: ./.venv/bin/pylint
|
|
30
|
+
# language: system
|
|
31
|
+
# types: [ python ]
|
|
32
|
+
# require_serial: true
|
|
33
|
+
# args:
|
|
34
|
+
# [
|
|
35
|
+
# "-rn", # Only display messages
|
|
36
|
+
# "-sn"
|
|
37
|
+
# ] # Don't display the score
|
|
38
|
+
|
|
39
|
+
# - repo: https://github.com/christophmeissner/pytest-pre-commit
|
|
40
|
+
# rev: 1.0.0
|
|
41
|
+
# hooks:
|
|
42
|
+
# - id: pytest
|
|
43
|
+
# entry: ./.venv/bin/pytest
|
|
44
|
+
# pass_filenames: false
|
|
45
|
+
# always_run: true
|
|
46
|
+
# args:
|
|
47
|
+
# - "tests"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: most_queue
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.2
|
|
4
4
|
Summary: Software package for calculation and simulation of queuing systems
|
|
5
5
|
Project-URL: Homepage, https://github.com/xabarov/most-queue
|
|
6
6
|
Author-email: Xabarov Roman <xabarov1985@gmail.com>
|
|
@@ -43,10 +43,66 @@ Description-Content-Type: text/markdown
|
|
|
43
43
|
|
|
44
44
|

|
|
45
45
|
|
|
46
|
-
A Python package for simulating and analyzing queueing systems (QS) and networks.
|
|
46
|
+
A Python package for simulating and analyzing queueing systems (QS) and networks.
|
|
47
47
|
|
|
48
48
|

|
|
49
49
|
|
|
50
|
+
---
|
|
51
|
+
### Most-Queue 2.0 Release Notes
|
|
52
|
+
|
|
53
|
+
New unified API for both simulation and calculation classes:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from most_queue.general.distribution_fitting import gamma_moments_by_mean_and_cv
|
|
57
|
+
from most_queue.general.tables import probs_print, times_print
|
|
58
|
+
from most_queue.rand_distribution import GammaDistribution
|
|
59
|
+
from most_queue.sim.base import QsSim
|
|
60
|
+
from most_queue.theory.fifo.mgn_takahasi import MGnCalc
|
|
61
|
+
|
|
62
|
+
# initialize constatants
|
|
63
|
+
NUM_OF_CHANNELS = 3
|
|
64
|
+
|
|
65
|
+
ARRIVAL_RATE = 1.0
|
|
66
|
+
SERVICE_TIME_CV = 1.2
|
|
67
|
+
|
|
68
|
+
NUM_OF_JOBS = 300_000 # number of jobs to simulate
|
|
69
|
+
|
|
70
|
+
UTILIZATION_FACTOR = 0.7
|
|
71
|
+
|
|
72
|
+
# calc service time moments using gamma distribution fitting
|
|
73
|
+
b1 = NUM_OF_CHANNELS * UTILIZATION_FACTOR / ARRIVAL_RATE # average service time
|
|
74
|
+
b = gamma_moments_by_mean_and_cv(b1, SERVICE_TIME_CV)
|
|
75
|
+
gamma_params = GammaDistribution.get_params([b[0], b[1]]) # gamma distribution parameters
|
|
76
|
+
|
|
77
|
+
# run Takahasi-Takami calc method
|
|
78
|
+
tt = MGnCalc(n=NUM_OF_CHANNELS)
|
|
79
|
+
|
|
80
|
+
tt.set_sources(l=ARRIVAL_RATE)
|
|
81
|
+
tt.set_servers(b=b)
|
|
82
|
+
|
|
83
|
+
calc_results = tt.run()
|
|
84
|
+
|
|
85
|
+
# run simulation
|
|
86
|
+
qs = QsSim(NUM_OF_CHANNELS)
|
|
87
|
+
|
|
88
|
+
qs.set_sources(ARRIVAL_RATE, "M")
|
|
89
|
+
qs.set_servers(gamma_params, "Gamma")
|
|
90
|
+
|
|
91
|
+
sim_results = qs.run(NUM_OF_JOBS)
|
|
92
|
+
|
|
93
|
+
print(f"Simulation duration: {sim_results.duration:.5f} sec")
|
|
94
|
+
print(f"Calculation duration: {calc_results.duration:.5f} sec")
|
|
95
|
+
|
|
96
|
+
probs_print(sim_results.p, calc_results.p, 10)
|
|
97
|
+
times_print(sim_results.v, calc_results.v, False)
|
|
98
|
+
times_print(sim_results.w, calc_results.w, True)
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
See more examples in [tests](https://github.com/xabarov/most-queue/blob/main/tests/) and [tutorials](https://github.com/xabarov/most-queue/tree/main/tutorials/) folders.
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
50
106
|
---
|
|
51
107
|
|
|
52
108
|
### 🔍 Key Features
|
|
@@ -76,13 +132,13 @@ Or install from the repository:
|
|
|
76
132
|
pip install -e .
|
|
77
133
|
```
|
|
78
134
|
|
|
79
|
-
---
|
|
135
|
+
---
|
|
80
136
|
|
|
81
137
|
## 📚 Project Overview
|
|
82
138
|
|
|
83
139
|
Most_queue consists of two main parts:
|
|
84
|
-
- **most_queue.theory** contains programs that implement methods for calculating queueing theory models.
|
|
85
|
-
- **most_queue.sim** contains simulation programs.
|
|
140
|
+
- **most_queue.theory** contains programs that implement methods for calculating queueing theory models.
|
|
141
|
+
- **most_queue.sim** contains simulation programs.
|
|
86
142
|
|
|
87
143
|
## 🧪 Example Use Cases
|
|
88
144
|
|
|
@@ -103,7 +159,7 @@ Most_queue consists of two main parts:
|
|
|
103
159
|
| # | Kendall Notations | Description | Example | Tutorial |
|
|
104
160
|
|-----|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
|
|
105
161
|
| 1. | M/Ph/c/PR | Numerical calculation of QS M/Ph/c with 2 classes and PR - priority. Based on the approximation of busy periods | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_m_ph_n_prty.py) | |
|
|
106
|
-
| 2. | M/M/c/PR | Numerical calculation of QS M/M/c with 2 classes, PR - priority by the Takahashi-Takami numerical method based on the approximation of the busy period by the Cox distribution | [link](https://github.com/xabarov/most-queue/blob/main/tests/
|
|
162
|
+
| 2. | M/M/c/PR | Numerical calculation of QS M/M/c with 2 classes, PR - priority by the Takahashi-Takami numerical method based on the approximation of the busy period by the Cox distribution | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mmn_prty_busy_approx.py) | |
|
|
107
163
|
| 3. | M/G/1/PR | Calculating QS with preemtive priorities (single-channel). | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_qs_sim_prty.py) |[link](https://github.com/xabarov/most-queue/blob/main/tutorials/priority_queue.ipynb) |
|
|
108
164
|
| 4. | M/G/1/NP | Calculating QS with non-preemtive priorities (single-channel). | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_qs_sim_prty.py) |[link](https://github.com/xabarov/most-queue/blob/main/tutorials/priority_queue.ipynb) |
|
|
109
165
|
| 5. | M/G/c/Priority | Calculating QS with NP and PR (multi-channel) by method of relation | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_qs_sim_prty.py) |[link](https://github.com/xabarov/most-queue/blob/main/tutorials/priority_queue.ipynb) |
|
|
@@ -160,10 +216,10 @@ Most_queue consists of two main parts:
|
|
|
160
216
|
---
|
|
161
217
|
|
|
162
218
|
### 📁 Examples & Tutorials
|
|
163
|
-
- Look [
|
|
164
|
-
- Look [
|
|
219
|
+
- Look [tests](https://github.com/xabarov/most-queue/tree/main/tests) for examples with comparison of theoretical and simulation results.
|
|
220
|
+
- Look [tutorials](https://github.com/xabarov/most-queue/tree/main/tutorials) for jupyter tutorials
|
|
165
221
|
|
|
166
|
-
---
|
|
222
|
+
---
|
|
167
223
|
|
|
168
224
|
### 👥 Contributing
|
|
169
225
|
|
|
@@ -171,4 +227,4 @@ Contributions are welcome!
|
|
|
171
227
|
|
|
172
228
|
- Open an [issue](https://github.com/xabarov/most-queue/issues) for bugs or suggestions.
|
|
173
229
|
- Submit a pull request for feature enhancements.
|
|
174
|
-
- Contact me at xabarov1985@gmail.com for questions.
|
|
230
|
+
- Contact me at xabarov1985@gmail.com for questions.
|
|
@@ -2,10 +2,66 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
A Python package for simulating and analyzing queueing systems (QS) and networks.
|
|
5
|
+
A Python package for simulating and analyzing queueing systems (QS) and networks.
|
|
6
6
|
|
|
7
7
|

|
|
8
8
|
|
|
9
|
+
---
|
|
10
|
+
### Most-Queue 2.0 Release Notes
|
|
11
|
+
|
|
12
|
+
New unified API for both simulation and calculation classes:
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
from most_queue.general.distribution_fitting import gamma_moments_by_mean_and_cv
|
|
16
|
+
from most_queue.general.tables import probs_print, times_print
|
|
17
|
+
from most_queue.rand_distribution import GammaDistribution
|
|
18
|
+
from most_queue.sim.base import QsSim
|
|
19
|
+
from most_queue.theory.fifo.mgn_takahasi import MGnCalc
|
|
20
|
+
|
|
21
|
+
# initialize constatants
|
|
22
|
+
NUM_OF_CHANNELS = 3
|
|
23
|
+
|
|
24
|
+
ARRIVAL_RATE = 1.0
|
|
25
|
+
SERVICE_TIME_CV = 1.2
|
|
26
|
+
|
|
27
|
+
NUM_OF_JOBS = 300_000 # number of jobs to simulate
|
|
28
|
+
|
|
29
|
+
UTILIZATION_FACTOR = 0.7
|
|
30
|
+
|
|
31
|
+
# calc service time moments using gamma distribution fitting
|
|
32
|
+
b1 = NUM_OF_CHANNELS * UTILIZATION_FACTOR / ARRIVAL_RATE # average service time
|
|
33
|
+
b = gamma_moments_by_mean_and_cv(b1, SERVICE_TIME_CV)
|
|
34
|
+
gamma_params = GammaDistribution.get_params([b[0], b[1]]) # gamma distribution parameters
|
|
35
|
+
|
|
36
|
+
# run Takahasi-Takami calc method
|
|
37
|
+
tt = MGnCalc(n=NUM_OF_CHANNELS)
|
|
38
|
+
|
|
39
|
+
tt.set_sources(l=ARRIVAL_RATE)
|
|
40
|
+
tt.set_servers(b=b)
|
|
41
|
+
|
|
42
|
+
calc_results = tt.run()
|
|
43
|
+
|
|
44
|
+
# run simulation
|
|
45
|
+
qs = QsSim(NUM_OF_CHANNELS)
|
|
46
|
+
|
|
47
|
+
qs.set_sources(ARRIVAL_RATE, "M")
|
|
48
|
+
qs.set_servers(gamma_params, "Gamma")
|
|
49
|
+
|
|
50
|
+
sim_results = qs.run(NUM_OF_JOBS)
|
|
51
|
+
|
|
52
|
+
print(f"Simulation duration: {sim_results.duration:.5f} sec")
|
|
53
|
+
print(f"Calculation duration: {calc_results.duration:.5f} sec")
|
|
54
|
+
|
|
55
|
+
probs_print(sim_results.p, calc_results.p, 10)
|
|
56
|
+
times_print(sim_results.v, calc_results.v, False)
|
|
57
|
+
times_print(sim_results.w, calc_results.w, True)
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
See more examples in [tests](https://github.com/xabarov/most-queue/blob/main/tests/) and [tutorials](https://github.com/xabarov/most-queue/tree/main/tutorials/) folders.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
9
65
|
---
|
|
10
66
|
|
|
11
67
|
### 🔍 Key Features
|
|
@@ -35,13 +91,13 @@ Or install from the repository:
|
|
|
35
91
|
pip install -e .
|
|
36
92
|
```
|
|
37
93
|
|
|
38
|
-
---
|
|
94
|
+
---
|
|
39
95
|
|
|
40
96
|
## 📚 Project Overview
|
|
41
97
|
|
|
42
98
|
Most_queue consists of two main parts:
|
|
43
|
-
- **most_queue.theory** contains programs that implement methods for calculating queueing theory models.
|
|
44
|
-
- **most_queue.sim** contains simulation programs.
|
|
99
|
+
- **most_queue.theory** contains programs that implement methods for calculating queueing theory models.
|
|
100
|
+
- **most_queue.sim** contains simulation programs.
|
|
45
101
|
|
|
46
102
|
## 🧪 Example Use Cases
|
|
47
103
|
|
|
@@ -62,7 +118,7 @@ Most_queue consists of two main parts:
|
|
|
62
118
|
| # | Kendall Notations | Description | Example | Tutorial |
|
|
63
119
|
|-----|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
|
|
64
120
|
| 1. | M/Ph/c/PR | Numerical calculation of QS M/Ph/c with 2 classes and PR - priority. Based on the approximation of busy periods | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_m_ph_n_prty.py) | |
|
|
65
|
-
| 2. | M/M/c/PR | Numerical calculation of QS M/M/c with 2 classes, PR - priority by the Takahashi-Takami numerical method based on the approximation of the busy period by the Cox distribution | [link](https://github.com/xabarov/most-queue/blob/main/tests/
|
|
121
|
+
| 2. | M/M/c/PR | Numerical calculation of QS M/M/c with 2 classes, PR - priority by the Takahashi-Takami numerical method based on the approximation of the busy period by the Cox distribution | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mmn_prty_busy_approx.py) | |
|
|
66
122
|
| 3. | M/G/1/PR | Calculating QS with preemtive priorities (single-channel). | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_qs_sim_prty.py) |[link](https://github.com/xabarov/most-queue/blob/main/tutorials/priority_queue.ipynb) |
|
|
67
123
|
| 4. | M/G/1/NP | Calculating QS with non-preemtive priorities (single-channel). | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_qs_sim_prty.py) |[link](https://github.com/xabarov/most-queue/blob/main/tutorials/priority_queue.ipynb) |
|
|
68
124
|
| 5. | M/G/c/Priority | Calculating QS with NP and PR (multi-channel) by method of relation | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_qs_sim_prty.py) |[link](https://github.com/xabarov/most-queue/blob/main/tutorials/priority_queue.ipynb) |
|
|
@@ -119,10 +175,10 @@ Most_queue consists of two main parts:
|
|
|
119
175
|
---
|
|
120
176
|
|
|
121
177
|
### 📁 Examples & Tutorials
|
|
122
|
-
- Look [
|
|
123
|
-
- Look [
|
|
178
|
+
- Look [tests](https://github.com/xabarov/most-queue/tree/main/tests) for examples with comparison of theoretical and simulation results.
|
|
179
|
+
- Look [tutorials](https://github.com/xabarov/most-queue/tree/main/tutorials) for jupyter tutorials
|
|
124
180
|
|
|
125
|
-
---
|
|
181
|
+
---
|
|
126
182
|
|
|
127
183
|
### 👥 Contributing
|
|
128
184
|
|
|
@@ -130,4 +186,4 @@ Contributions are welcome!
|
|
|
130
186
|
|
|
131
187
|
- Open an [issue](https://github.com/xabarov/most-queue/issues) for bugs or suggestions.
|
|
132
188
|
- Submit a pull request for feature enhancements.
|
|
133
|
-
- Contact me at xabarov1985@gmail.com for questions.
|
|
189
|
+
- Contact me at xabarov1985@gmail.com for questions.
|
|
@@ -9,27 +9,24 @@ import os
|
|
|
9
9
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
|
10
10
|
import sys
|
|
11
11
|
|
|
12
|
-
project =
|
|
13
|
-
copyright =
|
|
14
|
-
author =
|
|
15
|
-
release =
|
|
12
|
+
project = "most-queue"
|
|
13
|
+
copyright = "2025, xabarov"
|
|
14
|
+
author = "xabarov"
|
|
15
|
+
release = "1.51"
|
|
16
16
|
|
|
17
17
|
# -- General configuration ---------------------------------------------------
|
|
18
18
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
|
19
|
-
sys.path.insert(0,
|
|
19
|
+
sys.path.insert(0, os.path.abspath("../most_queue"))
|
|
20
20
|
|
|
21
|
-
extensions = [
|
|
22
|
-
'sphinx.ext.napoleon',
|
|
23
|
-
'autodocsumm',
|
|
24
|
-
'sphinx.ext.coverage']
|
|
21
|
+
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon", "autodocsumm", "sphinx.ext.coverage"]
|
|
25
22
|
|
|
26
|
-
auto_doc_default_options = {
|
|
27
|
-
templates_path = [
|
|
23
|
+
auto_doc_default_options = {"autosummary": True}
|
|
24
|
+
templates_path = ["_templates"]
|
|
28
25
|
exclude_patterns = []
|
|
29
26
|
|
|
30
27
|
|
|
31
28
|
# -- Options for HTML output -------------------------------------------------
|
|
32
29
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
|
33
30
|
|
|
34
|
-
html_theme =
|
|
35
|
-
html_static_path = [
|
|
31
|
+
html_theme = "sphinx_book_theme"
|
|
32
|
+
html_static_path = ["_static"]
|
|
File without changes
|
|
@@ -55,10 +55,10 @@ class Distribution(ABC):
|
|
|
55
55
|
|
|
56
56
|
@staticmethod
|
|
57
57
|
@abstractmethod
|
|
58
|
-
def
|
|
58
|
+
def get_params_by_mean_and_cv(f1: float, cv: float):
|
|
59
59
|
"""
|
|
60
60
|
:param f1: mean of the distribution.
|
|
61
|
-
:param
|
|
61
|
+
:param cv: coefficient of variation (std_dev / mean).
|
|
62
62
|
:return: Parameters for the distribution that correspond
|
|
63
63
|
to the given mean and coefficient of variation.
|
|
64
64
|
"""
|
{most_queue-1.63/most_queue/general → most_queue-2.2/most_queue/distr_utils}/distribution_fitting.py
RENAMED
|
@@ -8,10 +8,14 @@ from dataclasses import dataclass
|
|
|
8
8
|
|
|
9
9
|
import numpy as np
|
|
10
10
|
|
|
11
|
-
from most_queue.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
from most_queue.distr_utils.distribution_params import (
|
|
12
|
+
Cox2Params,
|
|
13
|
+
ErlangParams,
|
|
14
|
+
GammaParams,
|
|
15
|
+
H2Params,
|
|
16
|
+
ParetoParams,
|
|
17
|
+
WeibullParams,
|
|
18
|
+
)
|
|
15
19
|
|
|
16
20
|
|
|
17
21
|
@dataclass
|
|
@@ -98,28 +102,22 @@ def fit_h2_clx(moments: list[float], fitting_params: FittingParams | None = None
|
|
|
98
102
|
|
|
99
103
|
if fitting_params.is_fitting:
|
|
100
104
|
# проверка на близость распределения к экспоненциальному
|
|
101
|
-
|
|
102
|
-
if math.fabs(
|
|
105
|
+
cv = cmath.sqrt(moments[1] - moments[0] ** 2) / moments[0]
|
|
106
|
+
if math.fabs(cv.real - 1.0) < fitting_params.ee:
|
|
103
107
|
if fitting_params.verbose:
|
|
104
|
-
print(
|
|
105
|
-
f"H2 is close to Exp. Multiply moments to (1+je)"
|
|
106
|
-
f"coev = {coev:5.3f}, e = {fitting_params.e:5.3f}."
|
|
107
|
-
)
|
|
108
|
+
print(f"H2 is close to Exp. Multiply moments to (1+je)" f"cv = {cv:5.3f}, e = {fitting_params.e:5.3f}.")
|
|
108
109
|
f = []
|
|
109
110
|
for i, mom in enumerate(moments):
|
|
110
111
|
f.append(mom * complex(1, (i + 1) * fitting_params.e))
|
|
111
112
|
|
|
112
113
|
return fit_h2_clx(f, fitting_params=fitting_params)
|
|
113
114
|
|
|
114
|
-
|
|
115
|
+
cv = cmath.sqrt(moments[1] - moments[0] ** 2) / moments[0]
|
|
115
116
|
|
|
116
117
|
# проверка на близость распределения к Эрланга 2-го порядка
|
|
117
|
-
if math.fabs(
|
|
118
|
+
if math.fabs(cv.real - 1.0 / math.sqrt(2.0)) < fitting_params.ee:
|
|
118
119
|
if fitting_params.verbose:
|
|
119
|
-
print(
|
|
120
|
-
f"H2 is close to E2. Multiply moments to (1+je)"
|
|
121
|
-
f"coev = {coev:5.3f}, e = {fitting_params.e:5.3f}."
|
|
122
|
-
)
|
|
120
|
+
print(f"H2 is close to E2. Multiply moments to (1+je)" f"cv = {cv:5.3f}, e = {fitting_params.e:5.3f}.")
|
|
123
121
|
f = []
|
|
124
122
|
for i, mom in enumerate(moments):
|
|
125
123
|
f.append(mom * complex(1, (i + 1) * fitting_params.e))
|
|
@@ -148,26 +146,23 @@ def fit_cox(moments: list[float], fitting_params: FittingParams | None = None) -
|
|
|
148
146
|
|
|
149
147
|
if fitting_params.is_fitting:
|
|
150
148
|
# проверка на близость распределения к экспоненциальному
|
|
151
|
-
|
|
149
|
+
cv = cmath.sqrt(moments[1] - moments[0] ** 2) / moments[0]
|
|
152
150
|
if abs(moments[1] - moments[0] * moments[0]) < fitting_params.ee:
|
|
153
151
|
if fitting_params.verbose:
|
|
154
|
-
print(
|
|
155
|
-
f"Cox special 1. Multiply moments to (1+je)"
|
|
156
|
-
f"coev = {coev:5.3f} e = {fitting_params.e:5.3f}."
|
|
157
|
-
)
|
|
152
|
+
print(f"Cox special 1. Multiply moments to (1+je)" f"cv = {cv:5.3f} e = {fitting_params.e:5.3f}.")
|
|
158
153
|
f = []
|
|
159
154
|
for i, mom in enumerate(moments):
|
|
160
155
|
f.append(mom * complex(1, (i + 1) * fitting_params.e))
|
|
161
156
|
|
|
162
157
|
return fit_cox(f, fitting_params=fitting_params)
|
|
163
158
|
|
|
164
|
-
|
|
159
|
+
cv = cmath.sqrt(moments[1] - moments[0] ** 2) / moments[0]
|
|
165
160
|
|
|
166
161
|
# проверка на близость распределения к Эрланга 2-го порядка
|
|
167
162
|
if abs(moments[1] - (3.0 / 4) * moments[0] * moments[0]) < fitting_params.ee:
|
|
168
163
|
if fitting_params.verbose:
|
|
169
164
|
print("Cox special 2. Multiply moments to (1+je)")
|
|
170
|
-
print(f"\
|
|
165
|
+
print(f"\tcv = {cv:5.3f}, e = {fitting_params.e:5.3f}")
|
|
171
166
|
f = []
|
|
172
167
|
for i, mom in enumerate(moments):
|
|
173
168
|
f.append(mom * complex(1, (i + 1) * fitting_params.e))
|
|
@@ -176,9 +171,7 @@ def fit_cox(moments: list[float], fitting_params: FittingParams | None = None) -
|
|
|
176
171
|
for i in range(3):
|
|
177
172
|
f[i] = moments[i] / math.factorial(i + 1)
|
|
178
173
|
|
|
179
|
-
d = np.power(f[2] - f[0] * f[1], 2) - 4.0 * (f[1] - np.power(f[0], 2)) * (
|
|
180
|
-
f[0] * f[2] - np.power(f[1], 2)
|
|
181
|
-
)
|
|
174
|
+
d = np.power(f[2] - f[0] * f[1], 2) - 4.0 * (f[1] - np.power(f[0], 2)) * (f[0] * f[2] - np.power(f[1], 2))
|
|
182
175
|
mu2 = f[0] * f[1] - f[2] + cmath.sqrt(d)
|
|
183
176
|
mu2 /= 2.0 * (np.power(f[1], 2) - f[0] * f[2])
|
|
184
177
|
mu1 = (mu2 * f[0] - 1.0) / (mu2 * f[1] - f[0])
|
|
@@ -200,13 +193,13 @@ def fit_pareto_moments(moments: list[float]):
|
|
|
200
193
|
return ParetoParams(alpha=a, K=k)
|
|
201
194
|
|
|
202
195
|
|
|
203
|
-
def
|
|
196
|
+
def fit_pareto_by_mean_and_cv(f1: float, cv: float):
|
|
204
197
|
"""
|
|
205
198
|
Get parameters of the distribution by mean and coefficient of variation.
|
|
206
199
|
:param f1: float, mean value of the distribution
|
|
207
|
-
:param
|
|
200
|
+
:param cv: float, coefficient of variation (mean / std)
|
|
208
201
|
"""
|
|
209
|
-
d = pow(f1 *
|
|
202
|
+
d = pow(f1 * cv, 2)
|
|
210
203
|
c = pow(f1, 2) / d
|
|
211
204
|
disc = 4 * (1 + c)
|
|
212
205
|
a = (2 + math.sqrt(disc)) / 2
|
|
@@ -287,9 +280,7 @@ def fit_gamma(moments: list[float]) -> GammaParams:
|
|
|
287
280
|
else:
|
|
288
281
|
B.append(moments[i - 1])
|
|
289
282
|
for j in range(len(moments) + 1):
|
|
290
|
-
A[i].append(
|
|
291
|
-
calc_gamma_func(alpha + i + j) / (pow(mu, i + j) * calc_gamma_func(alpha))
|
|
292
|
-
)
|
|
283
|
+
A[i].append(calc_gamma_func(alpha + i + j) / (pow(mu, i + j) * calc_gamma_func(alpha)))
|
|
293
284
|
g = np.linalg.solve(A, B)
|
|
294
285
|
return GammaParams(mu=mu, alpha=alpha, g=g)
|
|
295
286
|
|
|
@@ -311,14 +302,10 @@ def fit_weibull(moments: list[float]) -> WeibullParams:
|
|
|
311
302
|
a = moments[1] / (moments[0] * moments[0])
|
|
312
303
|
u0 = math.log(2 * a) / (2.0 * math.log(2))
|
|
313
304
|
ee = 1e-6
|
|
314
|
-
u1 = (1.0 / (2 * math.log(2))) * math.log(
|
|
315
|
-
a * math.sqrt(math.pi) * math.gamma(u0 + 1) / math.gamma(u0 + 0.5)
|
|
316
|
-
)
|
|
305
|
+
u1 = (1.0 / (2 * math.log(2))) * math.log(a * math.sqrt(math.pi) * math.gamma(u0 + 1) / math.gamma(u0 + 0.5))
|
|
317
306
|
delta = u1 - u0
|
|
318
307
|
while math.fabs(delta) > ee:
|
|
319
|
-
u1 = (1.0 / (2 * math.log(2))) * math.log(
|
|
320
|
-
a * math.sqrt(math.pi) * math.gamma(u0 + 1) / math.gamma(u0 + 0.5)
|
|
321
|
-
)
|
|
308
|
+
u1 = (1.0 / (2 * math.log(2))) * math.log(a * math.sqrt(math.pi) * math.gamma(u0 + 1) / math.gamma(u0 + 0.5))
|
|
322
309
|
delta = u1 - u0
|
|
323
310
|
u0 = u1
|
|
324
311
|
k = 1 / u1
|
|
@@ -327,14 +314,14 @@ def fit_weibull(moments: list[float]) -> WeibullParams:
|
|
|
327
314
|
return WeibullParams(k=k, W=big_w)
|
|
328
315
|
|
|
329
316
|
|
|
330
|
-
def
|
|
317
|
+
def gamma_moments_by_mean_and_cv(mean: float, cv: float) -> list[float]:
|
|
331
318
|
"""
|
|
332
319
|
Calculate the first three moments of a gamma distribution
|
|
333
320
|
given the mean and coefficient of variation.
|
|
334
321
|
"""
|
|
335
322
|
f = [0, 0, 0]
|
|
336
|
-
alpha = 1 / (
|
|
323
|
+
alpha = 1 / (cv**2)
|
|
337
324
|
f[0] = mean
|
|
338
|
-
f[1] = pow(f[0], 2) * (pow(
|
|
325
|
+
f[1] = pow(f[0], 2) * (pow(cv, 2) + 1)
|
|
339
326
|
f[2] = f[1] * f[0] * (1.0 + 2 / alpha)
|
|
340
327
|
return f
|