Multiple inputs, multiple outputs; solving when you have simple linear models











up vote
0
down vote

favorite












I am working on a mathematical problem related to a steady state controls problem, and I think this might be the place to ask this. I've figured out some of the simple cases, and am wondering where might the best place to look for a more generic solution, since the real problem involves more inputs (over 50; this is a problem for multiple light sources and sensors, but could be applied to multi-zone heating ovens, for example).



The problem is simplified, since the outputs are linearly dependent on the inputs.



For a single input, and three outputs; say, a single light illuminating 3 sensors:



enter image description here



I've been able to write out the following; the coefficients are based on geometry, and are fixed.



y1=a*x1+b



y2=c*x1+d



y3=e*x1+f



The goal is to have the values y1, y2, and y3 set to some specific outputs (ya, yb, and yc; in our case the same values, but I solved the generic case).



If we create a objective function F=(ya-y1)^2+(yb-y2)^2+(yc-y3)^2, and derive w/r/t x1 and set to zero, I can find a best fit for things:



x1=((a * ya + c * yb + e * yc)-(a * b + c * d + e * f))/(a^2+c^2+e^2)



(For example, for a = 1, b = -3, c = 2, d = -10, e = 5, f = -25, with ya = 10, yb = 11, yc = 12, the objective function (F = 59) is smallest at x1 = 8).



I've checked this result against a spreadsheet solver algorithm, so I think my algebra is correct.



For a 3 input, 3 output problem; say, 3 lights illuminating 3 sensors:



enter image description here



... the equations are:



y1= a0 + a1 * x1 + a2 * x2 + a3 * x3



y2= b0 + b1 * x1 + b2 * x2 + b3 * x3



y3= c0 + c1 * x1 + c2 * x2 + c3 * x3



I actually solved this problem first, but used a spreadsheet solver, where the objective function is still F=(ya-y1)^2+(yb-y2)^2+(yc-y3)^2. Asking the solver to vary y1, y2, and y3, and minimizing F works.



The more general case(s)



Where do I look for solving problems where I've got n inputs, and m outputs, when the relations are linear? Is a spreadsheet solver still going to cut it? It kind of bothers me that it is a bit of black magic which I'm not clear how it solves it.



When inputs are less than outputs (like the first problem), solving algebraically for larger values of n seems unwieldy. I've looked at the two input, 4 output problem, and have tentatively solved it, but you start to turn your paper sideways when deriving for more inputs. This problem has a lot more inputs and outputs (we'll be looking at as many sensors), so unless I'm mistaken, algebra is out.



I'm thinking this is somewhat related to curve fitting of the multiple linear input problem, where you have y = a0 + a1 * x1 + a2 * x2 + a3 * x3 + ..., and are trying to find the coefficients a0, a1, a2 etc, given a bunch of data.



In this case, we know the coefficients, but want to set the outputs, but am not quite sure where to go next. I've used Nelder-Mead (https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method) in the past for solving nonlinear 2D problems; would this be a solution, perhaps? Are there any open-source solvers/libraries in Python that might help here?










share|cite|improve this question


























    up vote
    0
    down vote

    favorite












    I am working on a mathematical problem related to a steady state controls problem, and I think this might be the place to ask this. I've figured out some of the simple cases, and am wondering where might the best place to look for a more generic solution, since the real problem involves more inputs (over 50; this is a problem for multiple light sources and sensors, but could be applied to multi-zone heating ovens, for example).



    The problem is simplified, since the outputs are linearly dependent on the inputs.



    For a single input, and three outputs; say, a single light illuminating 3 sensors:



    enter image description here



    I've been able to write out the following; the coefficients are based on geometry, and are fixed.



    y1=a*x1+b



    y2=c*x1+d



    y3=e*x1+f



    The goal is to have the values y1, y2, and y3 set to some specific outputs (ya, yb, and yc; in our case the same values, but I solved the generic case).



    If we create a objective function F=(ya-y1)^2+(yb-y2)^2+(yc-y3)^2, and derive w/r/t x1 and set to zero, I can find a best fit for things:



    x1=((a * ya + c * yb + e * yc)-(a * b + c * d + e * f))/(a^2+c^2+e^2)



    (For example, for a = 1, b = -3, c = 2, d = -10, e = 5, f = -25, with ya = 10, yb = 11, yc = 12, the objective function (F = 59) is smallest at x1 = 8).



    I've checked this result against a spreadsheet solver algorithm, so I think my algebra is correct.



    For a 3 input, 3 output problem; say, 3 lights illuminating 3 sensors:



    enter image description here



    ... the equations are:



    y1= a0 + a1 * x1 + a2 * x2 + a3 * x3



    y2= b0 + b1 * x1 + b2 * x2 + b3 * x3



    y3= c0 + c1 * x1 + c2 * x2 + c3 * x3



    I actually solved this problem first, but used a spreadsheet solver, where the objective function is still F=(ya-y1)^2+(yb-y2)^2+(yc-y3)^2. Asking the solver to vary y1, y2, and y3, and minimizing F works.



    The more general case(s)



    Where do I look for solving problems where I've got n inputs, and m outputs, when the relations are linear? Is a spreadsheet solver still going to cut it? It kind of bothers me that it is a bit of black magic which I'm not clear how it solves it.



    When inputs are less than outputs (like the first problem), solving algebraically for larger values of n seems unwieldy. I've looked at the two input, 4 output problem, and have tentatively solved it, but you start to turn your paper sideways when deriving for more inputs. This problem has a lot more inputs and outputs (we'll be looking at as many sensors), so unless I'm mistaken, algebra is out.



    I'm thinking this is somewhat related to curve fitting of the multiple linear input problem, where you have y = a0 + a1 * x1 + a2 * x2 + a3 * x3 + ..., and are trying to find the coefficients a0, a1, a2 etc, given a bunch of data.



    In this case, we know the coefficients, but want to set the outputs, but am not quite sure where to go next. I've used Nelder-Mead (https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method) in the past for solving nonlinear 2D problems; would this be a solution, perhaps? Are there any open-source solvers/libraries in Python that might help here?










    share|cite|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am working on a mathematical problem related to a steady state controls problem, and I think this might be the place to ask this. I've figured out some of the simple cases, and am wondering where might the best place to look for a more generic solution, since the real problem involves more inputs (over 50; this is a problem for multiple light sources and sensors, but could be applied to multi-zone heating ovens, for example).



      The problem is simplified, since the outputs are linearly dependent on the inputs.



      For a single input, and three outputs; say, a single light illuminating 3 sensors:



      enter image description here



      I've been able to write out the following; the coefficients are based on geometry, and are fixed.



      y1=a*x1+b



      y2=c*x1+d



      y3=e*x1+f



      The goal is to have the values y1, y2, and y3 set to some specific outputs (ya, yb, and yc; in our case the same values, but I solved the generic case).



      If we create a objective function F=(ya-y1)^2+(yb-y2)^2+(yc-y3)^2, and derive w/r/t x1 and set to zero, I can find a best fit for things:



      x1=((a * ya + c * yb + e * yc)-(a * b + c * d + e * f))/(a^2+c^2+e^2)



      (For example, for a = 1, b = -3, c = 2, d = -10, e = 5, f = -25, with ya = 10, yb = 11, yc = 12, the objective function (F = 59) is smallest at x1 = 8).



      I've checked this result against a spreadsheet solver algorithm, so I think my algebra is correct.



      For a 3 input, 3 output problem; say, 3 lights illuminating 3 sensors:



      enter image description here



      ... the equations are:



      y1= a0 + a1 * x1 + a2 * x2 + a3 * x3



      y2= b0 + b1 * x1 + b2 * x2 + b3 * x3



      y3= c0 + c1 * x1 + c2 * x2 + c3 * x3



      I actually solved this problem first, but used a spreadsheet solver, where the objective function is still F=(ya-y1)^2+(yb-y2)^2+(yc-y3)^2. Asking the solver to vary y1, y2, and y3, and minimizing F works.



      The more general case(s)



      Where do I look for solving problems where I've got n inputs, and m outputs, when the relations are linear? Is a spreadsheet solver still going to cut it? It kind of bothers me that it is a bit of black magic which I'm not clear how it solves it.



      When inputs are less than outputs (like the first problem), solving algebraically for larger values of n seems unwieldy. I've looked at the two input, 4 output problem, and have tentatively solved it, but you start to turn your paper sideways when deriving for more inputs. This problem has a lot more inputs and outputs (we'll be looking at as many sensors), so unless I'm mistaken, algebra is out.



      I'm thinking this is somewhat related to curve fitting of the multiple linear input problem, where you have y = a0 + a1 * x1 + a2 * x2 + a3 * x3 + ..., and are trying to find the coefficients a0, a1, a2 etc, given a bunch of data.



      In this case, we know the coefficients, but want to set the outputs, but am not quite sure where to go next. I've used Nelder-Mead (https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method) in the past for solving nonlinear 2D problems; would this be a solution, perhaps? Are there any open-source solvers/libraries in Python that might help here?










      share|cite|improve this question













      I am working on a mathematical problem related to a steady state controls problem, and I think this might be the place to ask this. I've figured out some of the simple cases, and am wondering where might the best place to look for a more generic solution, since the real problem involves more inputs (over 50; this is a problem for multiple light sources and sensors, but could be applied to multi-zone heating ovens, for example).



      The problem is simplified, since the outputs are linearly dependent on the inputs.



      For a single input, and three outputs; say, a single light illuminating 3 sensors:



      enter image description here



      I've been able to write out the following; the coefficients are based on geometry, and are fixed.



      y1=a*x1+b



      y2=c*x1+d



      y3=e*x1+f



      The goal is to have the values y1, y2, and y3 set to some specific outputs (ya, yb, and yc; in our case the same values, but I solved the generic case).



      If we create a objective function F=(ya-y1)^2+(yb-y2)^2+(yc-y3)^2, and derive w/r/t x1 and set to zero, I can find a best fit for things:



      x1=((a * ya + c * yb + e * yc)-(a * b + c * d + e * f))/(a^2+c^2+e^2)



      (For example, for a = 1, b = -3, c = 2, d = -10, e = 5, f = -25, with ya = 10, yb = 11, yc = 12, the objective function (F = 59) is smallest at x1 = 8).



      I've checked this result against a spreadsheet solver algorithm, so I think my algebra is correct.



      For a 3 input, 3 output problem; say, 3 lights illuminating 3 sensors:



      enter image description here



      ... the equations are:



      y1= a0 + a1 * x1 + a2 * x2 + a3 * x3



      y2= b0 + b1 * x1 + b2 * x2 + b3 * x3



      y3= c0 + c1 * x1 + c2 * x2 + c3 * x3



      I actually solved this problem first, but used a spreadsheet solver, where the objective function is still F=(ya-y1)^2+(yb-y2)^2+(yc-y3)^2. Asking the solver to vary y1, y2, and y3, and minimizing F works.



      The more general case(s)



      Where do I look for solving problems where I've got n inputs, and m outputs, when the relations are linear? Is a spreadsheet solver still going to cut it? It kind of bothers me that it is a bit of black magic which I'm not clear how it solves it.



      When inputs are less than outputs (like the first problem), solving algebraically for larger values of n seems unwieldy. I've looked at the two input, 4 output problem, and have tentatively solved it, but you start to turn your paper sideways when deriving for more inputs. This problem has a lot more inputs and outputs (we'll be looking at as many sensors), so unless I'm mistaken, algebra is out.



      I'm thinking this is somewhat related to curve fitting of the multiple linear input problem, where you have y = a0 + a1 * x1 + a2 * x2 + a3 * x3 + ..., and are trying to find the coefficients a0, a1, a2 etc, given a bunch of data.



      In this case, we know the coefficients, but want to set the outputs, but am not quite sure where to go next. I've used Nelder-Mead (https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method) in the past for solving nonlinear 2D problems; would this be a solution, perhaps? Are there any open-source solvers/libraries in Python that might help here?







      systems-of-equations linear-programming






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked Nov 24 at 0:32









      asylumax

      1011




      1011






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          Hint.



          As far as I understood, it seems that your problem can be represented as



          $$
          E(x) = ||A x+b-y_0||
          $$



          or



          $$
          E^2(x) = x^t A^t A x +2(b-y_0)A x + ||b-y_0||^2
          $$



          with minimum at



          $$
          A^tA x_0+A^t(b-y_0) = 0
          $$



          with



          $$
          x_0 = -(A^t A)^{-1}A^t(b-y_0)
          $$



          Here



          $b = (a_0,b_0,cdots, n_0)$ and $y_0 = (y_a, y_b,cdots, y_n)$



          The linear modeling can give strange solutions. For example, in case of $x$ associated to light sources the solution can give darkening properties to some sources... ($ x < 0$)






          share|cite|improve this answer




























            up vote
            0
            down vote













            You might want to try total least squares model based off of your previous success with summing residuals, like you would in the least squares model. Wikipedia has a naive gnu implementation of the algorithm, and with some trial and error you could get it running in pandas if you wanted.






            share|cite|improve this answer





















              Your Answer





              StackExchange.ifUsing("editor", function () {
              return StackExchange.using("mathjaxEditing", function () {
              StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
              StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
              });
              });
              }, "mathjax-editing");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "69"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              noCode: true, onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3011027%2fmultiple-inputs-multiple-outputs-solving-when-you-have-simple-linear-models%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              0
              down vote













              Hint.



              As far as I understood, it seems that your problem can be represented as



              $$
              E(x) = ||A x+b-y_0||
              $$



              or



              $$
              E^2(x) = x^t A^t A x +2(b-y_0)A x + ||b-y_0||^2
              $$



              with minimum at



              $$
              A^tA x_0+A^t(b-y_0) = 0
              $$



              with



              $$
              x_0 = -(A^t A)^{-1}A^t(b-y_0)
              $$



              Here



              $b = (a_0,b_0,cdots, n_0)$ and $y_0 = (y_a, y_b,cdots, y_n)$



              The linear modeling can give strange solutions. For example, in case of $x$ associated to light sources the solution can give darkening properties to some sources... ($ x < 0$)






              share|cite|improve this answer

























                up vote
                0
                down vote













                Hint.



                As far as I understood, it seems that your problem can be represented as



                $$
                E(x) = ||A x+b-y_0||
                $$



                or



                $$
                E^2(x) = x^t A^t A x +2(b-y_0)A x + ||b-y_0||^2
                $$



                with minimum at



                $$
                A^tA x_0+A^t(b-y_0) = 0
                $$



                with



                $$
                x_0 = -(A^t A)^{-1}A^t(b-y_0)
                $$



                Here



                $b = (a_0,b_0,cdots, n_0)$ and $y_0 = (y_a, y_b,cdots, y_n)$



                The linear modeling can give strange solutions. For example, in case of $x$ associated to light sources the solution can give darkening properties to some sources... ($ x < 0$)






                share|cite|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Hint.



                  As far as I understood, it seems that your problem can be represented as



                  $$
                  E(x) = ||A x+b-y_0||
                  $$



                  or



                  $$
                  E^2(x) = x^t A^t A x +2(b-y_0)A x + ||b-y_0||^2
                  $$



                  with minimum at



                  $$
                  A^tA x_0+A^t(b-y_0) = 0
                  $$



                  with



                  $$
                  x_0 = -(A^t A)^{-1}A^t(b-y_0)
                  $$



                  Here



                  $b = (a_0,b_0,cdots, n_0)$ and $y_0 = (y_a, y_b,cdots, y_n)$



                  The linear modeling can give strange solutions. For example, in case of $x$ associated to light sources the solution can give darkening properties to some sources... ($ x < 0$)






                  share|cite|improve this answer












                  Hint.



                  As far as I understood, it seems that your problem can be represented as



                  $$
                  E(x) = ||A x+b-y_0||
                  $$



                  or



                  $$
                  E^2(x) = x^t A^t A x +2(b-y_0)A x + ||b-y_0||^2
                  $$



                  with minimum at



                  $$
                  A^tA x_0+A^t(b-y_0) = 0
                  $$



                  with



                  $$
                  x_0 = -(A^t A)^{-1}A^t(b-y_0)
                  $$



                  Here



                  $b = (a_0,b_0,cdots, n_0)$ and $y_0 = (y_a, y_b,cdots, y_n)$



                  The linear modeling can give strange solutions. For example, in case of $x$ associated to light sources the solution can give darkening properties to some sources... ($ x < 0$)







                  share|cite|improve this answer












                  share|cite|improve this answer



                  share|cite|improve this answer










                  answered Nov 24 at 1:25









                  Cesareo

                  7,4303416




                  7,4303416






















                      up vote
                      0
                      down vote













                      You might want to try total least squares model based off of your previous success with summing residuals, like you would in the least squares model. Wikipedia has a naive gnu implementation of the algorithm, and with some trial and error you could get it running in pandas if you wanted.






                      share|cite|improve this answer

























                        up vote
                        0
                        down vote













                        You might want to try total least squares model based off of your previous success with summing residuals, like you would in the least squares model. Wikipedia has a naive gnu implementation of the algorithm, and with some trial and error you could get it running in pandas if you wanted.






                        share|cite|improve this answer























                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          You might want to try total least squares model based off of your previous success with summing residuals, like you would in the least squares model. Wikipedia has a naive gnu implementation of the algorithm, and with some trial and error you could get it running in pandas if you wanted.






                          share|cite|improve this answer












                          You might want to try total least squares model based off of your previous success with summing residuals, like you would in the least squares model. Wikipedia has a naive gnu implementation of the algorithm, and with some trial and error you could get it running in pandas if you wanted.







                          share|cite|improve this answer












                          share|cite|improve this answer



                          share|cite|improve this answer










                          answered Nov 24 at 2:46









                          multicusp

                          211




                          211






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Mathematics Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              Use MathJax to format equations. MathJax reference.


                              To learn more, see our tips on writing great answers.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3011027%2fmultiple-inputs-multiple-outputs-solving-when-you-have-simple-linear-models%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Wiesbaden

                              Marschland

                              Dieringhausen