I'm quite new in CPLEX with C++. I'm trying to model a piecewise-linear objective function (in the LaTex notation):
F = sum_{i = 1}^{N} f_i = sum_{i = 1}^{N} K_i * (x_i - x_i^*),
K_i = K_i^1, if x_i < x_i^*; K_i^2, if x_i > x_i^*,
that is the sum of values of deviations with weight coefficients. The weight coefficients depend on the sign of the deviation and the index i.
The question is: How to define this kind of the objective function in modelling by row in terms of Ilo
class or something else?
There are some examples in the internet where an objective function is represented with 2-3 variables, for example,
model.add(IloMaximize(env, x[0] + 2 * x[1] + 3 * x[2]));
but if I have much more values? And I don't understand how to take into account the weight coefficients in such a representation.
Tnx.
question from:https://stackoverflow.com/questions/66046216/implementation-of-an-objective-with-unknown-number-of-variables