Skip to content
This repository was archived by the owner on Nov 19, 2020. It is now read-only.
This repository was archived by the owner on Nov 19, 2020. It is now read-only.

Quadratic Objective Function to support basic vector operations #819

@CatchemAL

Description

@CatchemAL

Feature request

It would be quite nice if the quadratic objective function supported basic vector operations (vectors in the mathematical sense) such as addition and scalar multiplication. It's quite common to want to combine various quadratic objective functions possibly with a weighting. A proposed API would be:

var target1 = new QuadraticObjectiveFunction(quadraticTerms1, linearTerms1);
var target2 = new QuadraticObjectiveFunction(quadraticTerms2, linearTerms2);
double weight1 = 0.4, weight2 = 0.6;

QuadraticObjectiveFunction weightedTarget = (weight1 * target1) + (weight2 * target2);

Mathematically, this is trivial because f=x(Q+P)x+(c+d)x=xQx+xPx+cx+dc=f1+f2 but, syntactically, it would be really nice to write the maths and not have to scale and add individual matrices and vectors etc. If you like it, I'll add it. It's probably a quick job but there are some dictionaries floating around in that function that will need to be handled with care.

p.s. - This line looks a bit suspicious to me. That only works if Q is symmetric but the class permits you to pass in a non-symmetric matrix. It should either calculate 0.5*(Q+Q')*x or throw an Exception if non-symmetric matrices are passed in. I would propose the latter. Assuming the latter, Q.Dot(input) would be much faster.

Thanks,
Alex

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions