-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Example
Say one wants to model choosing between four different stocks, each with an expected return and a volatility. One might currently model it like
model = Model()
expected_return = model.constant([...])
volatility = model.constant([...])
stock = model.integer(lower_bound=0, upper_bound=3)
stock_return = expected_return[stock]
stock_volatility = volatility[stock]This works OK but stock isn't really modelling an integer variable in the sense that the ordering of the stocks in the relevant arrays does not hold any semantic meaning.
Feature Request
In such cases a user might wish to use a categorical variable. This might have a similar API
model = Model()
expected_return = model.constant([...])
volatility = model.constant([...])
stock = model.categorical(num_categories=4)
stock_return = expected_return[stock]
stock_volatility = volatility[stock]but semantically the solver would not consider the variable to be ordered.
Other thoughts
This needs more thought, but something like
stock = model.categorical(["a", "b", "c"]) # takes values in [0, 1, 2] as usual
stock == stock.category("a") # equivalent to stock == model.constant(0)might be convenient. Or might just introduce a mess.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request