Add float support to balarce offset modified
This commit is contained in:
@@ -397,8 +397,8 @@ class RotaScheduleForm(forms.ModelForm):
|
||||
# legacy builder args (the remaining keys in `options` are treated as
|
||||
# constraint configuration for `RotaConstraintOptions`).
|
||||
builder_args = {
|
||||
"balance_offset_modifier": {"type": "int", "default": 1, "help": "Balance offset modifier used by the builder"},
|
||||
"ltft_balance_offset": {"type": "int", "default": 1, "help": "LTFT balance offset used by the builder"},
|
||||
"balance_offset_modifier": {"type": "float", "default": 1.0, "help": "Balance offset modifier used by the builder"},
|
||||
"ltft_balance_offset": {"type": "float", "default": 1.0, "help": "LTFT balance offset used by the builder"},
|
||||
"use_previous_shifts": {"type": "bool", "default": False, "help": "Use previous shifts when building the rota"},
|
||||
"use_shift_balance_extra": {"type": "bool", "default": False, "help": "Enable extra shift-balance penalties"},
|
||||
"use_bank_holiday_extra": {"type": "bool", "default": False, "help": "Apply bank-holiday balancing extras"},
|
||||
@@ -412,6 +412,8 @@ class RotaScheduleForm(forms.ModelForm):
|
||||
self.fields[field_name] = forms.BooleanField(required=False, initial=bool(initial), label=k.replace("_", " "), help_text=meta.get("help"))
|
||||
elif meta["type"] == "int":
|
||||
self.fields[field_name] = forms.IntegerField(required=False, initial=initial, label=k.replace("_", " "), help_text=meta.get("help"))
|
||||
elif meta["type"] == "float":
|
||||
self.fields[field_name] = forms.FloatField(required=False, initial=initial, label=k.replace("_", " "), help_text=meta.get("help"))
|
||||
else:
|
||||
self.fields[field_name] = forms.CharField(required=False, initial=initial, label=k.replace("_", " "), help_text=meta.get("help"))
|
||||
|
||||
|
||||
+11
-10
@@ -50,7 +50,7 @@ def main(
|
||||
ratio: float = 0.001,
|
||||
start_date: datetime.datetime = "2026-03-02",
|
||||
weeks: int = 26,
|
||||
bom: int = 2,
|
||||
bom: float = 1.5,
|
||||
):
|
||||
rota_start_date = start_date.date()
|
||||
suspend_on_finish = suspend
|
||||
@@ -59,17 +59,18 @@ def main(
|
||||
rota_start_date,
|
||||
weeks_to_rota=weeks,
|
||||
balance_offset_modifier=bom,
|
||||
name="proc_rota",
|
||||
name="proc_rota1",
|
||||
)
|
||||
# Rota = RotaBuilder(start_date, weeks_to_rota=20, balance_offset_modifier=1)
|
||||
Rota.constraint_options["balance_shifts"] = False
|
||||
Rota.constraint_options["balance_shifts_quadratic"] = True
|
||||
Rota.constraint_options["balance_weekends"] = True
|
||||
Rota.constraint_options["max_night_frequency"] = 3 # 3
|
||||
Rota.constraint_options["max_night_frequency"] = 4 # 3
|
||||
Rota.constraint_options["max_night_frequency_week_exclusions"] = []
|
||||
Rota.constraint_options["max_weekend_frequency"] = 2
|
||||
Rota.constraint_options["max_weekend_frequency"] = 3
|
||||
Rota.constraint_options["hard_constrain_pair_separation"] = True
|
||||
# Rota.constraint_options["avoid_st2_first_month"] = True
|
||||
|
||||
Rota.constraint_options["max_days_per_week_block"] = [(5, 2), (6, 3), (8,4)]
|
||||
|
||||
#wr = [
|
||||
# WorkerRequirement(
|
||||
@@ -93,7 +94,7 @@ def main(
|
||||
name="exeter_twilight",
|
||||
length=12.5,
|
||||
days=days[:5],
|
||||
balance_offset=4,
|
||||
balance_offset=2,
|
||||
constraints=[MaxShiftsPerWeekConstraint(max_shifts=2)],
|
||||
),
|
||||
SingleShift(
|
||||
@@ -115,7 +116,7 @@ def main(
|
||||
name="torbay_twilight",
|
||||
length=12.5,
|
||||
days=days[:4],
|
||||
balance_offset=4,
|
||||
balance_offset=2,
|
||||
assign_as_block=True,
|
||||
),
|
||||
SingleShift(
|
||||
@@ -128,7 +129,7 @@ def main(
|
||||
name="plymouth_twilight",
|
||||
length=12.5,
|
||||
days=days[:5],
|
||||
balance_offset=4,
|
||||
balance_offset=2,
|
||||
workers_required=1,
|
||||
constraints=[MaxShiftsPerWeekConstraint(max_shifts=2)],
|
||||
),
|
||||
@@ -143,7 +144,7 @@ def main(
|
||||
name="weekend_exeter",
|
||||
length=12.5,
|
||||
days=days[5:],
|
||||
balance_offset=3,
|
||||
balance_offset=2,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=True,
|
||||
constraints=[PostShiftConstraint(days=2), PreShiftConstraint(days=2)],
|
||||
@@ -172,7 +173,7 @@ def main(
|
||||
name="weekend_torbay",
|
||||
length=12.5,
|
||||
days=days[4:],
|
||||
balance_offset=3,
|
||||
balance_offset=2,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=True,
|
||||
constraints=[PreShiftConstraint(days=2), PostShiftConstraint(days=2)],
|
||||
|
||||
@@ -610,7 +610,7 @@ class RotaBuilder(object):
|
||||
self,
|
||||
start_date: datetime.date = datetime.date.today(),
|
||||
weeks_to_rota: int = 26,
|
||||
balance_offset_modifier: int = 1,
|
||||
balance_offset_modifier: float = 1.0,
|
||||
ltft_balance_offset: int = 1,
|
||||
use_previous_shifts: bool = False,
|
||||
use_shift_balance_extra: bool = False,
|
||||
|
||||
Reference in New Issue
Block a user