Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <adolc/adolc.h>
- #include <adolc/taping.h>
- using namespace std;
- adouble obj(adouble parameters[3]) {
- adouble score = 0.0;
- for (unsigned i = 0; i < 3; ++i)
- score += parameters[i] + 2 * parameters[i];
- return score;
- }
- int main() {
- adouble start_values[3];
- start_values[0] <<= 100;
- start_values[1] <<= 150;
- start_values[2] <<= 75;
- trace_on(0);
- adouble ascore = obj(start_values);
- trace_off(1);
- double x[3];
- for (unsigned i = 0; i <3; ++i)
- x[i] = start_values[i].value();
- double g[3];
- int s = gradient(0,3, x, g);
- cout << "DONE" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement