Code Monkey home page Code Monkey logo

Comments (4)

artivis avatar artivis commented on May 28, 2024 1

Well this does not fully answer my question but I shall dig in the code a little more and come back to you with a clearer idea.
Thanks a lot anyway !

from ifopt.

awinkler avatar awinkler commented on May 28, 2024

Hi!
In the end, the cost always has to be scalar, that's just the way nonlinear programming problems are defined. This cost however can be composed of a variety of scalar cost-terms. You can subtract a scalar cost term by defining the costs as negative.

The image shows the scalar cost J(x), and the gradient of this cost w.r.t x, which are two added 1xn row vectors (n being the number of optimization variables). Does that clear things up?

from ifopt.

artivis avatar artivis commented on May 28, 2024

Thanks for the (very) quick answer !

From a theoretical point of view we're on the same page. My question however was more from a programming point of view.
Using the same example as before, say I would like to do this vector subtraction (or whatever the operation) all at once. To benefit from vectorization, because the operation is heavy, well whatever the reason... How could one somewhat 'pre-compute' the error (in its vector form) to later on 'distribute' each scalar cost-term ? Or how to 'group' this variety of CostTerm objects so that the operation is computed only once ?
I'm not sure this comment make things clearer, hopefully.

from ifopt.

awinkler avatar awinkler commented on May 28, 2024

So I guess I would simply implement this as one cost term, and then exploit Eigen efficiency to calculate the cost e.g. as

VectorXd x0 = var_set0->GetValues();
VectorXd x1 = var_set1->GetValues();
double cost = (x0 - x1).norm(); // Eigen will do this in the fastest way possible I assume

from ifopt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.