Hello everyone and thank you in advance for your attention,
I am trying to model and solve a Mixed-integer model in which the objective function and all constraints are linear and I only have one nonlinear constraint. The relevant variables related to this constraint are defined as follow:
p_pg = mdl.continuous_var_dict(utility_key, name='p')
u_pg = mdl.continuous_var_dict(utility_key, name='u')
where p and g after "_" are indices
The mathematical expression of this non-linear constraint is as follows:
p_pg = (exp(u_pg)) / (Σ p∈p exp (u_pg) + exp (0)) for all p, g
I am trying to add this constraint in python by using docplex as follow:
mdl.add_constraints(p_pg[plan, segment] == (exp(u_pg[plan, segment]) / (mdl.sum(exp(u_pg[s, segment]) for s in range(1, p+1)) + exp(0)))for plan in range(1, p+1) for segment in range(1, g+1))
I get the following error: Model has not been solved yet
It should be noted that I also tried the mdl.add_quadratic_constraints and I get the same error.
I do not understand why I should get this error when I am trying to add constraints.
Thank you for your kind support in advance