I have the problem describe below
I need to find value of x1', x2', x3', x4', x5' that make
(x1-x1')^2+(x2-x2')^2+(x3-x3')^2+(x4-x4')^2+(x5-x5')^2 = mininum value
and
x1' + x2' + x3' + x4' + x5' = 1
x1 + x2 + x3 + x4 + x5 = 1
Note: we know value of a, b, c, d, e, x1, x2, x3, x4, x5
Would anyone help me in this case?
I have tried with google/or-tools library but can't add condition to find minimum value.
MPSolver solver = createSolver(solverType);
double infinity = MPSolver.infinity();
MPVariable x1 = solver.makeNumVar(0.0, infinity, "x1");
MPVariable x2 = solver.makeNumVar(0.0, infinity, "x2");
MPVariable x3 = solver.makeNumVar(0.0, infinity, "x3");
MPVariable x4 = solver.makeNumVar(0.0, infinity, "x4");
MPVariable x5 = solver.makeNumVar(0.0, infinity, "x5");
// 0.15 <= x1 <= 0.35
MPConstraint c1 = solver.makeConstraint(-infinity, 0.35);
c1.setCoefficient(x1, 1);
MPConstraint c2 = solver.makeConstraint(0.15, infinity);
c2.setCoefficient(x1, 1);
// 0.1 <= x2 <= 0.3
MPConstraint c3 = solver.makeConstraint(-infinity, 0.3);
c3.setCoefficient(x2, 1);
MPConstraint c4 = solver.makeConstraint(0.1, infinity);
c4.setCoefficient(x2, 1);
// 0.0 <= x3 <= 0.2
MPConstraint c5 = solver.makeConstraint(-infinity, 0.2);
c5.setCoefficient(x3, 1);
MPConstraint c6 = solver.makeConstraint(0.0, infinity);
c6.setCoefficient(x3, 1);
// 0.15 <= x4 <= 0.35
MPConstraint c7 = solver.makeConstraint(-infinity, 0.35);
c7.setCoefficient(x4, 1);
MPConstraint c8 = solver.makeConstraint(0.15, infinity);
c8.setCoefficient(x4, 1);
// 0.1 <= x5 <= 0.3
MPConstraint c9 = solver.makeConstraint(-infinity, 0.3);
c9.setCoefficient(x5, 1);
MPConstraint c10 = solver.makeConstraint(0.1, infinity);
c10.setCoefficient(x5, 1);
// x1 + x2 + x3 + x4 + x5 = 1
MPConstraint c11 = solver.makeConstraint(-infinity, 1.0);
c11.setCoefficient(x1, 1);
c11.setCoefficient(x2, 1);
c11.setCoefficient(x3, 1);
c11.setCoefficient(x4, 1);
c11.setCoefficient(x5, 1);
MPConstraint c12 = solver.makeConstraint(1.0, infinity);
c12.setCoefficient(x1, 1);
c12.setCoefficient(x2, 1);
c12.setCoefficient(x3, 1);
c12.setCoefficient(x4, 1);
c12.setCoefficient(x5, 1);
MPObjective objective = solver.objective();
objective.setCoefficient(x1, 1);
objective.setCoefficient(x2, 1);
objective.setCoefficient(x3, 1);
objective.setCoefficient(x4, 1);
objective.setCoefficient(x5, 1);
objective.setMinimization();
This is a basic constrain optimization problem with convex objective function.
https://en.wikipedia.org/wiki/Constrained_optimization
There are many softwares that help you to do this. e.g.
http://cvxopt.org/documentation/index.html