Question: NLPSolve variable number of parameters for objective function

Hello,

I have some trouble with specifying an optimization problem in NLPSolve (package Optimization).

This is the situation: the Maple help specifies 3 ways of calling NLPSolve. Algebraic, Operator and Matrix form.

I can't use the algebraic form for this problem.

I tried using the Matrix form but the problem is that I have a few linear constraints which can't be represented using a matrix (A) and a vector (b) (the linear constraint typically is Ax = b)

Ideally I'd define a procedure which takes some parameters and calculates the linear constraint. The operator form of NLPSolve makes this possible but a new problem arises: the objective function has to be of the form proc(x1, x2, x3, ..., xn). My problem is that i don't know the number of parameters before i've imported my data from an excel worksheet. Obviously the number of paramers can also vary depending on the data.

So my question boils down to: Is there a way of specifying a procedure that takes a variable number of parameters? I've looked at the possibility of using the "_rest" variable inside a procedure body (with an empty parameter list) or using the x::seq(float[8]) as the only parameter.

I also tried the following:

 formparam := seq(xi, i = 1..nrofparam);

 testproc := proc(formparam)::float[8]; for l from 1 to nrofparam do *do something with xl* end do: end proc:

This seems to work but when I specify an initialpoint using the option initialpoint = [seq(0, i = 1..nrofparam)] then it gives an error: "Error, (in Optimization:-NLPSolve) input list has incorrect dimension"

 

I hope I explained my problem well enough and I would be really grateful to anyone that offers me some help.

Please Wait...