The cost function is
$f=\sum_{i=1}^{N}w_i(A_ix-b_i)(C_ix-d_i)$
Where $A_i$ and $C_i$ are 1 by $L$ vectors, $b_i$, $d_i$ and $w_i$ are known constants, and $x$ is a $L$ by 1 vector with all elements positive.
How to calculate the $x$ that can minimize the cost function.
I would be very appreciated if someone could help.
Use a Quadratic Programming (QP) solver, of which there are many for almost any computing environment.. That will allow you to specify the nonnegativity constraint.If you need $x$ to be strictly positive, you will have to specify small_number and input constraint as $x \ge $ small_number.
All QP solvers can handle this problem if the objective function is convex, and will find the global minimum. If the objective function is not convex, you will need a QP solver which can handle non-convex QPs. Non-convex QP solvers come in two type, 1) Find local but not necessarily global minimum 2) find global minimum . For non-convex QPs, you can also use a general purpose non-convex nonlinear solver (which can handle linear constraints) instead of a dedicated QP solver.