I have a function that takes two input matrices an creates some series of variables to be used with Minimize. The function should generate the lazy equations dynamically based on those variables.
SPOP[p_, v_] := (
(* expects |cols(p)| == |cols(v)| *)
{vecy, matx}; (* declare local variables *)
vecy = Table[y[i], {i, Length[p]}]; (* create y[i] for each elements of p *)
)
Now I want to create an objective function and several constraints, So I need to know how to create an equation with these variables.
My objective function may look like
y[1] + y[2] + .... y[Length[vecy]]
How can I generate these equations. I was trying the following which did not work
Expand[Sum[vecy, {i, 1, Length[vecy]}]]
Also How can I do the same with Product of elements in vecy ?