# In interior point solver we can set unity constraint as x1+x2+x3+x4=1 can we set constraint like 0.10<=x1+x3>=0.80 and 0.20<=x2+x4>=0.50

Asked by At

In interior point solver we can set unity constraint like x1+x2+x3+x4=1 can we set constraint like 0.10<= x1+x3 >=0.80 and 0.20<=x2+x4>=0.50 using setcoefficient.

Please provide the sample to set constraint of weight boundaries on sector and security both level.

https://csharp.hotexamples.com/examples/-/InteriorPointSolver/AddRow/php-interiorpointsolver-addrow-method-examples.html

We have used code of InteriorPointSolver for Markowitz model, It has solved to Minimize or Maximize on Security. But we can not set setbound on sum of some of subset of all securities. We tried to set constraint using Setcoefficient but it's not working. Please provide the sample for it

## 1 Answers On

This is a strange looking constraint.

``````0.10 <= x1+x3 >= 0.80
``````

can be restated as

``````x1+x3 >= 0.10
x1+x3 >= 0.80
``````

or just

``````x1+x3 >= 0.80
``````

No sweat!

If the poster really means:

``````0.10 <= x1+x3 <= 0.80
``````

(it always helps to reread your question!) then we can write this as:

``````x1+x3 >= 0.10
x1+x3 <= 0.80
``````

This is trivial to implement.

If the length of the summation is long:

``````0.10 <= x1+x2+x3+... <= 0.8
``````

there is a better approach:

``````y in [0.1,0.8]     (extra variable with lower and upper bounds)
y = x1+x2+x3+...   (single equality constraint)
``````

This prevents having the long summation twice in the model. Basically we create an extra variable but save a constraint and the corresponding nonzero coefficients.

Of course Microsoft Solver Foundation should not be used in real projects: it has been discontinued in 2012.