0

F1 + F2 + F3 + F4 + F5 + F6 = 9810; -F1*0.52 - F2*0.52 + F3*0.3 + F4*0.3 + F5*0.64 + F6*0.64 = 0 (F1 + F3 + F5)*(0.94) - (F2 + F4 + F6)*(0.74) = 0

I want to solve this underdetermined system of equations and add a constrain for all values must be higher than zero.I don't want to any of value equal to or less than zero.

I tried in matlab with lsqnonneg function and some of values are zero.Here is the code:

A = [1 1 1 1 1 1;-0.52 -0.52 0.3 0.3 0.64 0.64;0.94 -0.74 0.94 -0.74 0.94 -0.74];

b = [9810;0;0];

x = lsqnonneg(A,b)

Also I tried this code but this code doesn't give me any solution.

syms F1 F2 F3 F4 F5 F6

eq1 = F1 + F2 + F3 + F4 + F5 + F6 == 9810;

eq2 = -F1*0.52 - F2*0.52 + F3*0.3 + F4*0.3 + F5*0.64 + F6*0.64 == 0;

eq3 = (F1 + F3 + F5)*(0.94) - (F2 + F4 + F6)*(0.74) == 0;

lb = [F1, F2, F3, F4, F5, F6] > 0;

sol = solve([eq1, eq2, eq3, lb],[F1,F2,F3,F4,F5,F6]);

sol.F1

sol.F2

sol.F3

sol.F4

sol.F5

sol.F6
Erwin Kalvelagen
  • 15,677
  • 2
  • 14
  • 39
  • Is 0.0001 higher than zero for your purposes? – Reinderien Jun 07 '23 at 12:34
  • Since it is under determined, if you have more than one solution, are all solutions equally desirable? – Reinderien Jun 07 '23 at 12:37
  • What version of Matlab are you using? The Symbolic Math Toolbox in R2023a returns a full solution parametrized by 3 values and valid conditions that describe the full family of solutions. You probably should also specify that your 6 variables are real-valued too (Matlab symbolic variables are complex-valued by default). – horchler Jun 07 '23 at 13:31

2 Answers2

0

A well-known approach is to formulate this as an LP (Linear Programming) problem with a dummy objective (e.g. 0) and lower bounds something like 0.0001. Definitely don't use something like 0.0000001 as there are feasibility tolerances in play (which can be as big as 1e-4 and can be further amplified by scaling). I would use a number that is a few orders of magnitude larger than the feasibility tolerance.

Erwin Kalvelagen
  • 15,677
  • 2
  • 14
  • 39
-1

As @ErwinKalvelagen says, this is fairly commonly done with a linear program, in your case implemented via linprog. But as always, the devil is in the details.

You can reuse your A and b verbatim, because one kind of constraint that LP supports is equality.

Linear programs ask for bounds on your variables - but, crucially, these are always closed-interval bounds and not open-interval bounds, so it is impossible to ask for "greater than zero" - only "greater than or equal to some very small value". For this class of problem you could choose 0.000,001 as an epsilon for the lower bound of every variable, leaving the upper bound of every variable as infinity.

Linear programs always ask for an optimization objective coefficient vector, basically a vector that - when the dot product is performed with your decision variables - produces a minimization cost. You can choose to set this to all 0, implying that there is no optimization; or you can perform repeat evaluations and the dual to find possible solutions for the minima and maxima of every variable. If you don't do anything fancy with the dual, then you will have 12 re-evaluations with coefficient vectors [1 0 0 0 0 0], [-1 0 0 0 0 0], [0 1 0 0 0 0], [0 -1 0 0 0 0] etc. This can give you a better idea as to the solution space.

The latter strategy can produce output like

One row per solution, minima on the diagonal
[[1.00000000e-06 4.14589286e+03 4.32107143e+03 1.00000000e-06 1.00000000e-06 1.34303571e+03]
 [4.32107143e+03 1.00000000e-06 1.00000000e-06 3.72340336e+03 1.00000000e-06 1.76552521e+03]
 [4.32107143e+03 1.09134237e+03 1.00000000e-06 1.00000000e-06 1.00000000e-06 4.39758620e+03]
 [4.32107143e+03 1.09134237e+03 1.00000000e-06 1.00000000e-06 1.00000000e-06 4.39758620e+03]
 [4.32107143e+03 1.09134237e+03 1.00000000e-06 1.00000000e-06 1.00000000e-06 4.39758620e+03]
 [3.58902439e+03 1.00000000e-06 7.32047037e+02 5.48892857e+03 1.00000000e-06 1.00000000e-06]]

One row per solution, maxima on the diagonal
[[4.32107143e+03 1.09134237e+03 1.00000000e-06 1.00000000e-06 1.00000000e-06 4.39758620e+03]
 [1.00000000e-06 5.41241379e+03 1.00000000e-06 1.00000000e-06 4.32107143e+03 7.65147789e+01]
 [1.00000000e-06 4.14589286e+03 4.32107143e+03 1.00000000e-06 1.00000000e-06 1.34303571e+03]
 [3.58902439e+03 1.00000000e-06 7.32047037e+02 5.48892857e+03 1.00000000e-06 1.00000000e-06]
 [1.00000000e-06 5.41241379e+03 1.00000000e-06 1.00000000e-06 4.32107143e+03 7.65147789e+01]
 [4.32107143e+03 1.09134237e+03 1.00000000e-06 1.00000000e-06 1.00000000e-06 4.39758620e+03]]

Those matrices are not exhaustive. For every one of those variable extrema there is still an infinite number of solutions.

Reinderien
  • 11,755
  • 5
  • 49
  • 77