Advertisement
Guest User

Untitled

a guest
Nov 13th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4.  
  5. #include <adolc/adolc.h>
  6. #include <adolc/taping.h>
  7.  
  8. using namespace std;
  9.  
  10. adouble obj(adouble parameters[3]) {
  11. adouble score = 0.0;
  12. for (unsigned i = 0; i < 3; ++i)
  13. score += parameters[i] + 2 * parameters[i];
  14.  
  15. return score;
  16. }
  17.  
  18.  
  19. int main() {
  20. adouble start_values[3];
  21. start_values[0] <<= 100;
  22. start_values[1] <<= 150;
  23. start_values[2] <<= 75;
  24.  
  25. trace_on(0);
  26. adouble ascore = obj(start_values);
  27. trace_off(1);
  28.  
  29. double x[3];
  30. for (unsigned i = 0; i <3; ++i)
  31. x[i] = start_values[i].value();
  32.  
  33. double g[3];
  34. int s = gradient(0,3, x, g);
  35.  
  36. cout << "DONE" << endl;
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement