-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Flat-Rate Policies #131
Comments
I think this may technically be possible in the current rate structure by setting the {
"activity": "parking",
"max_stay": 60,
"max_stay_unit": "minute",
"rate": [
{
"rate": 0,
"rate_unit": "minute",
"increment_duration": 15,
"start_duration": 0,
"end_duration": 15
},
{
"rate": 150,
"rate_unit": "minute",
"increment_duration": 15,
"start_duration": 15,
"end_duration": 30
},
{
"rate": 150,
"rate_unit": "minute",
"increment_duration": 30,
"start_duration": 30,
"end_duration": 60
}
]
} I think that rate structure would make it so the vehicle was charged $1.50 for being parked during the 15-30 durations and then another $1.50 for being parked during the 30-60 durations for a total of $3.00. |
@jiffyclub I'm not sure this is entirely correct, at least not based upon how I'm reading the specification. Let's look at the second rate in your definition in particular. My interpretation of this would be that the price applied here would be $1.50 per minute, where the driver would be billed a flat rate of $22.50 for parking in the zone for a duration of between 15 and 30 minutes. I think we would need to divide the rate by 15 to achieve our initially proposed policy, so the policy would look like this: {
"activity": "parking",
"max_stay": 60,
"max_stay_unit": "minute",
"rate": [
{
"rate": 0,
"rate_unit": "minute",
"increment_duration": 15,
"start_duration": 0,
"end_duration": 15
},
{
"rate": 10,
"rate_unit": "minute",
"increment_duration": 15,
"start_duration": 15,
"end_duration": 30
},
{
"rate": 10,
"rate_unit": "minute",
"increment_duration": 30,
"start_duration": 30,
"end_duration": 60
}
]
} I believe you are correct that our desired policy representation can be achieved with the policy specification as is, assuming of course that the intended flat rate divides evenly into the number of Perhaps there is a non-breaking modification we could introduce (either to the I'm a bit torn as to where this modification would belong. An argument could be made either for the
|
One possibility would be adding a new property to the If the new property is not defined, the default value is assumed to be If the new property is defined, the following conditions apply:
For example, let's examine the following rate: {
"rate": 150,
"rate_unit": "minute",
"increment_duration": 15,
"start_duration": 15,
"end_duration": 30
} In this case, the rate is defined as 150 per minute, with a minimum payment of $22.50 (i.e. 15 minutes * $1.50 / minute). If we were to instead express this rate like so: {
"rate": 150,
"rate_unit": "minute",
"rate_basis": "increment",
"increment_duration": 15,
"start_duration": 15,
"end_duration": 30
} Then the rate is defined as 150 per 15 minutes. So the minimum payment is simply $1.50. |
I think I agree with @lummish here in that flat-rate policies are discontinuous step function-based rate policies whereas the current notion of rates assumes a linear model that scales with time. In this way the If we were to support flat-rate policies I think the simplest solution would be to add an optional, default-initialized field called
So the vehicle will be charged nothing for minutes 0-15, $1.50 for any active minutes 15-30 and $1.50 for any active minutes between 30-60. Since the rates apply on individual chunks of the duration itself, they are additive and hence relative to each other, so
EDIT: Fixed incorrect explination, oops. |
Would like to hear back from @jiffyclub to see if he still thinks this is possible in the current spec. |
I think @jiffyclub's interpretation is correct.
So if increment_duration is set as the payment period, we charge the full period as soon as the even hits that period. So for an event duration of 28 minutes in the above exemple, we would charge the full first period since 28 > 15, for a subtotal of 0$, and the full second period since 15 < 28 < 30, for a subtotal of 1,50$, for a grand total of 1,50$. The thing that is probably missing is some langages/exemples to document this. |
I think either of these are possible depending on how you interpret the spec, hinging on whether we interpret the A flag like |
Is your feature request related to a problem? Please describe.
Certain cities have requested the implementation of a flat-rate fee structure for parking, for example:
A few examples of this policy at work:
At present, the specification for policy definition does not allow for expression of this kind of policy; the current implementation depends on policies and their corresponding rates being assessed in an additive fashion, rather than as a flat fee for different session durations.
Describe the solution you'd like
We propose the addition of a single new property to the Rule type called
rate_application_type
.The new property would assume one of two values:
additive
orflat
, where theadditive
value would correspond to the current definition and behavior of aRule
, and theflat
value would correspond to the proposed new behavior.This property would be optional, and when not specified would designate the current behavior (i.e.
additive
).When the
rate_application_type
for a given rule is defined asadditive
, the current behavior will persist. That is to say, the elements in therate
array for the given rule will apply additively.When the
rate_application_type
for a given rule is defined asflat
, only one element of therate
array of the rule will apply to a session.As an illustrative example, let's use the policy described above. We could define a rule to represent this policy like so:
Is this a breaking change
A breaking change would require consumers or implementors of an API to modify their code for it to continue to function (ex: renaming of a required field or the change in data type of an existing field). A non-breaking change would allow existing code to continue to function (ex: addition of an optional field or the creation of a new optional endpoint).
Impacted Spec
For which spec is this feature being requested?
Describe alternatives you've considered
We explored implementing the desired feature by modifying the
Policy
andRate
types, however it seems that the most sensible place to make the change is on theRule
type.cc: @michael-automotus
The text was updated successfully, but these errors were encountered: