You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@bherd-rb Some tradable resources have quantities that are naturally discrete whilst other tradable resources have quantities that are natural continuous. I have been trying to come up with a solution to get this information into the type system. Getting this information into the type system is useful because it would allow us to restrict that types of orders that a particular auction can accept. For example, we might want to force market participants to only submit orders for discrete quantities (or continuous quantities).
I think that the Wurman et al (2001) paper provides a solution. Suppose that we have a trait Quantity that extends AnyVal and is parameterized on the type of value it contains. Then we can define two case classes for DiscreteQuantity and ContinuousQuantity as follows.
@bherd-rb There are some issues with the above implementation. First, one can not extend from a trait/class that extends from AnyVal nor can one mixin a trait with a class that extends from AnyVal. More details on this issue can be found on SO. This means that if we move forward with this implementation we must accept that additional memory overhead associated with allocating instances of the Quantity objects which was saved by the use of value classes. Second I would prefer to restrict the type of T to be any numeric value rather than the more generic AnyVal but at present this it is not possible to do this. I did learn about the specialized annotation that should help improve run-time performance of calculations using quantities.
@bherd-rb Some tradable resources have quantities that are naturally discrete whilst other tradable resources have quantities that are natural continuous. I have been trying to come up with a solution to get this information into the type system. Getting this information into the type system is useful because it would allow us to restrict that types of orders that a particular auction can accept. For example, we might want to force market participants to only submit orders for discrete quantities (or continuous quantities).
I think that the Wurman et al (2001) paper provides a solution. Suppose that we have a trait
Quantity
that extendsAnyVal
and is parameterized on the type of value it contains. Then we can define two case classes forDiscreteQuantity
andContinuousQuantity
as follows.Thoughts?
The text was updated successfully, but these errors were encountered: