Writing Objective Functions for Linear or Quadratic Problems
The following solvers handle linear or quadratic objective functions:
linprog
andintlinprog
: minimizef'x
=f(1)*x(1) + f(2)*x(2) +...+ f(n)*x(n)
.Input the vector
f
for the objective. See the examples in Linear Programming and Mixed-Integer Linear Programming.lsqlin
andlsqnonneg
: minimize‖
Cx - d
‖.Input the matrix
C
and the vectord
for the objective. See Nonnegative Linear Least Squares, Solver-Based.quadprog
: minimize1/2 * x'Hx
+f'x
=1/2 * (x(1)*H(1,1)*x(1) + 2*x(1)*H(1,2)*x(2) +...
.
+ x(n)*H(n,n)*x(n)) + f(1)*x(1) + f(2)*x(2) +...+ f(n)*x(n)Input both the vector
f
and the symmetric matrixH
for the objective. See Quadratic Programming and Cone Programming.