I'm developing an Optimization tool for a domestic energy system that also contains a battery. All values are correct and the solution makes sense. The problem is that the solution contains very strong fluctuations. Meaning that the decision variable is often either 0 or the maximum value. In order to avoid that I would like to add a quadratic constraint that penalizes the difference of two values (something like the derivative). Should look something like this:
((x[t] - x[t-1]) / stepsize) ^ 2
Where x is the decision variable of interest. E.g. power_g_h[t].
My objective function (so far) ist definded as follows:
IloLQNumExpr expr = model.lqNumExpr();
for (int t = 0; t < timesteps; t++) {
expr.addTerm(problem.getCosts().getElectricityCosts(t), power_g_h[t]);
expr.addTerm(problem.getCosts().getElectricityCosts(t), power_g_b[t]);
expr.addTerm(problem.getCosts().getElectricityCosts(t), power_g_bev[t]);
expr.addTerm(problem.getCosts().getFeedCompensation(), power_pv_g[t]);
}
I hope this was somewhat understandable and someone is able to tell whether or not this is even possible in CPLEX.
If this is not possible, I would be very happy about hints on how to "smoothen" a solution in CPLEX.
With kind regards,
L.
QPex1.javaexample that is included with CPLEX. Is that what you were asking? You should just try it to see if it gives you the desired smoothing effect. Another idea would be to try using the solution pool to inspect alternative optimal solutions. - rkersh