-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquad_rotor_main.cpp
72 lines (61 loc) · 2.23 KB
/
quad_rotor_main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (C) 2005, 2009 International Business Machines and others.
// All Rights Reserved.
// This code is published under the Eclipse Public License.
//
// Authors: Carl Laird, Andreas Waechter IBM 2005-08-10
//
// ./quad_rotor_main 50
#include "IpIpoptApplication.hpp"
#include "quad_rotor_nlp.hpp"
#include "Differentiation_Matrix.hpp"
#include <iostream>
#include <cstdlib>
using namespace Ipopt;
int main(int argv, char* argc[]) {
// Create a new instance of your nlp
// (use a SmartPtr, not raw)
int no_of_grid_points;
//std::cin >> no_of_grid_points;
no_of_grid_points = atoi(argc[1]);
SmartPtr<TNLP> mynlp = new QUAD_ROTOR_NLP(no_of_grid_points);
// Create a new instance of IpoptApplication
// (use a SmartPtr, not raw)
// We are using the factory, since this allows us to compile this
// example with an Ipopt Windows DLL
SmartPtr<IpoptApplication> app = IpoptApplicationFactory();
app->RethrowNonIpoptException(true);
// Change some options
// Note: The following choices are only examples, they might not be
// suitable for your optimization problem.
// app->Options()->SetNumericValue("tol", 1e-7);
// app->Options()->SetStringValue("mu_strategy", "adaptive");
// app->Options()->SetStringValue("output_file", "ipopt.out");
// The following overwrites the default name (ipopt.opt) of the
// options file
app->Options()->SetStringValue("option_file_name", "ipopt.opt");
// Initialize the IpoptApplication and process the options
ApplicationReturnStatus status;
status = app->Initialize();
if (status != Solve_Succeeded) {
std::cout << std::endl
<< std::endl
<< "*** Error during initialization!" << std::endl;
return (int)status;
}
// Ask Ipopt to solve the problems
status = app->OptimizeTNLP(mynlp);
if (status == Solve_Succeeded) {
std::cout << std::endl
<< std::endl
<< "*** The problem solved!" << std::endl;
} else {
std::cout << std::endl
<< std::endl
<< "*** The problem FAILED!" << std::endl;
}
// As the SmartPtrs go out of scope, the reference count
// will be decremented and the objects will automatically
// be deleted.
return (int)status;
//return 0;
}