Question: NLPSolve in Matrix Form - variable problem dimensions

Hello,

I ran into problems while trying to write the input to NLPSolve in the Matrix Form because the problem dimensions depend on the input data. Take the following example:

max f(x)           <- f a nonlinear function of x

st: x1+x2+x3+x4                     ≤ b1

                                 x5+x6+x7+x8 ≤ b2

       x1      +x3     +x5     +x7        ≤ b3

            x2     +x4        +x6      +x8 ≤ b4

      x1                     +x5               ≤ b5

         x2                      +x6          ≤ b6

                   x3                     +x7       ≤ b7

                         x4                +x8 ≤ b8

                            x ≥ 0.

Depending on the input data, the dimension of x changes as well as the number of constraints and the structure of each constraint (more or less variables in each). Writing out the matrix of coefficients each time there is a change in the input data is definitely not smart. I chose a somewhat lenghthy example to also support the fact that I want (very much) to avoid manual input.

Is there a way to overcome this issue while using the matrix form or is there another more generalized call to the solver? By a more generalized call I mean a command that will allow me to address the set of constraints via a procedure call, something of the form constr:=proc(a,b) for i to 8 do a[i]  ≤ b[i] end do; end proc; and then just use constr in the solver command.

Many thanks in advance,

Melania

Please Wait...