Thank you for the prompt response, Prof. Bierlaire. I followed the ex7 and wanted to extend it to three classes which I ran to the error as I specified model as follow.
ASC_CAR_C1 = Beta('ASC_CAR_C1', 0, None, None, 0)
ASC_TRAIN_C1 = Beta('ASC_TRAIN_C1', 0, None, None, 0)
ASC_SM_C1 = Beta('ASC_SM_C1', 0, None, None, 1)
B_TIME_C1 = Beta('B_TIME_C1', 0, None, None, 0)
B_COST_C1 = Beta('B_COST_C1', 0, None, None, 0)
ASC_CAR_C2 = Beta('ASC_CAR_C2', 0, None, None, 0)
ASC_TRAIN_C2 = Beta('ASC_TRAIN_C2', 0, None, None, 0)
ASC_SM_C2 = Beta('ASC_SM_C2', 0, None, None, 1)
B_TIME_C2 = Beta('B_TIME_C2', 0, None, None, 0)
B_COST_C2 = Beta('B_COST_C2', 0, None, None, 0)
ASC_CAR_C3 = Beta('ASC_CAR_C3', 0, None, None, 0)
ASC_TRAIN_C3 = Beta('ASC_TRAIN_C3', 0, None, None, 0)
ASC_SM_C3 = Beta('ASC_SM_C3', 0, None, None, 1)
B_TIME_C3 = Beta('B_TIME_C3', 0, None, None, 0)
B_COST_C3 = Beta('B_COST_C3', 0, None, None, 0)
Class membership probability.
PROB_CLASS1 = Beta('PROB_CLASS1', 0.5, 0, 1, 0)
PROB_CLASS2 = Beta('PROB_CLASS2', 0.5, 0, 1, 0)
PROB_CLASS3 = 1 - PROB_CLASS1-PROB_CLASS2
Definition of the utility functions for latent class 1, where the
time coefficient is zero.
V11 = ASC_TRAIN_C1 + B_COST_C1 * TRAIN_COST_SCALED
V12 = ASC_SM_C1 + B_COST_C1 * SM_COST_SCALED
V13 = ASC_CAR_C1 + B_COST_C1 * CAR_CO_SCALED
V21 = ASC_TRAIN_C2 + B_TIME_C2 * TRAIN_TT_SCALED + B_COST_C2 * TRAIN_COST_SCALED
V22 = ASC_SM_C2 + B_TIME_C2 * SM_TT_SCALED + B_COST_C2 * SM_COST_SCALED
V23 = ASC_CAR_C2 + B_TIME_C2 * CAR_TT_SCALED + B_COST_C2 * CAR_CO_SCALED
V31 = ASC_TRAIN_C3 + B_TIME_C3 * TRAIN_TT_SCALED + B_COST_C3 * TRAIN_COST_SCALED
V32 = ASC_SM_C3 + B_TIME_C3 * SM_TT_SCALED + B_COST_C3 * SM_COST_SCALED
V33 = ASC_CAR_C3 + B_TIME_C3 * CAR_TT_SCALED + B_COST_C3 * CAR_CO_SCALED
Associate utility functions with the numbering of alternatives.
V1 = {1: V11, 2: V12, 3: V13}
V2 = {1: V21, 2: V22, 3: V23}
V3 = {1: V31, 2: V32, 3: V33}
Associate the availability conditions with the alternatives.
av = {1: TRAIN_AV_SP, 2: SM_AV, 3: CAR_AV_SP}
The choice model is a discrete mixture of logit, with availability conditions
prob1 = models.logit(V1, av, CHOICE)
prob2 = models.logit(V2, av, CHOICE)
prob3 = models.logit(V3, av, CHOICE)
prob = PROB_CLASS1 * prob1 + PROB_CLASS2 * prob2 + PROB_CLASS3*prob3
logprob = log(prob)