I am trying to build an optimisation program based on Bass model (see below):
- Decision variables: p, m, q
- Problem: min RMSE
- Constraints:
- Ft = (p + q(C(t-1)/m)(m - C(t-1))
- Et = Ft - St
with C(t) being the cumulative sum of sales, St being the actual amount of sales, Ft being the predicted sales for period t and Et being the error term.
I cannot seem to figure out how to write constraints that assign such values to new variables (and not necessarily use comparative operators)...
For the moment, I created a Bass_F function doing the equation Ft above, and an rmse function computing the rmse. I also wrote the following code (my actual sales value are variable y and I have 4 records in it):
import docplex.mp.model as cpx
opt_model = cpx.Model(name="Bass")
opt_model.continuous_var(name = "p")
opt_model.continuous_var(name = "q")
opt_model.continuous_var(name = "m")
F = [None]*4
E = [None]*4
opt_model.add_constraint_(F[0] = p*m)
opt_model.add_constraint_(E[0] = F[0] - y[0])
for i in range(1,len(F)):
opt_model.add_constraints_(F[i] = Bass_F(F[i-1], p, q, m))
opt_model.add_constraints_(E[i] = F[i] - y[i])
Obviously this gives me an error, which is:
opt_model.add_constraint_(F[0] = p*m) ^
SyntaxError: keyword can't be an expression
Can anyone help? Thanks in advance!