69#include "IpIpoptApplication.hpp"
70#include "IpSolveStatistics.hpp"
107 cout <<
"the first function\n";
114 cout <<
"its \"underload\"\n";
118 operator vector<int> ()
120 cout <<
"within vector <int>" << endl;
121 vector <int> toReturn;
122 toReturn.push_back(3);
123 toReturn.push_back(4);
124 toReturn.push_back(5);
1509 vector <string> myStringDatas;
1510 myStringDatas.push_back(
"aaaaa");
1511 myStringDatas.push_back(
"bbbbb");
1512 myStringDatas.push_back(
"ccccc");
1515 for (
int i=0;i<myStringDatas.size();i++){
1516 istringstream iss(myStringDatas[i]);
1519 xVector.push_back(x);
1533 string myStringData;
1534 myStringData =
"abcdefg";
1537 myBoolData =
"false";
1540 istringstream iss(myIntData);
1547 istringstream iss(myStringData);
1554 string tempBoolString;
1555 if (myBoolData ==
"1" || myBoolData ==
"true" || myBoolData ==
"True" || myBoolData ==
"TRUE" || myBoolData ==
"vero" || myBoolData ==
"Vero"|| myBoolData ==
"VERO"){
1556 tempBoolString =
"1";
1558 else if (myBoolData ==
"0" || myBoolData ==
"false" || myBoolData ==
"False" || myBoolData ==
"FALSE" || myBoolData ==
"falso" || myBoolData ==
"falso"|| myBoolData ==
"FALSO"){
1559 tempBoolString =
"0";
1564 istringstream iss(tempBoolString);
1573template<
typename T> T
1575 std::istringstream iss(s);
1582vector <TestStructure*>
1584 vector <TestStructure*> toReturn;
1607 vector<TestStructure*> myAgents;
1608 vector<double> myResults (nAgents, (
double) 0);
1612 for (
int i=0; i < nAgents; i++){
1615 myAgent->
random = (0+( (double)rand() / ((double)(RAND_MAX)+(double)(1)) )*(10-0+1))/ (double)100;
1616 myAgents.push_back(myAgent);
1619 vector <testThread*> myThreads ;
1621 for (
int i=0; i < nThreads; i++){
1623 myThreads.push_back(myThread);
1626 for (uint i=0;i<myAgents.size();i++){
1627 bool assigned =
false;
1629 for (uint j=0;j<myThreads.size();j++){
1630 if (!myThreads[j]->isRunning()){
1631 cout <<
"Assigning agent " << i <<
" to thread " << j << endl;
1633 myThreads[j]->start();
1638 cout <<
"Thread " << j <<
" is busy" << endl;
1663 for (
int i=0; i < nThreads; i++){
1664 myThreads[i]->wait();
1668 for (
int i=0; i < nThreads; i++){
1669 delete myThreads[i];
1672 for (uint i=0;i<myAgents.size();i++){
1675 double random = (0+( (double)rand() / ((double)(RAND_MAX)+(double)(1)) )*(10-0+1))/ (double)100;
1687 cout <<
"FINITO"<<endl;
1699 cout <<
agent->
i << endl;
1701 double randChange = (0+( (double)rand() / ((double)(RAND_MAX)+(double)(1)) )*(10-0+1))/ (double)100;
1704 vector <double> takeTimeVector (justn, 0);
1705 for (
int i =0; i< justn;i++){
1706 takeTimeVector.at(i)=i*2;
1721 using namespace Ipopt;
1731 SmartPtr<IpoptApplication> app = IpoptApplicationFactory();
1736 app->Options()->SetNumericValue(
"tol", 1e-7);
1737 app->Options()->SetStringValue(
"mu_strategy",
"adaptive");
1738 app->Options()->SetStringValue(
"output_file",
"ipopt.out");
1749 ApplicationReturnStatus status;
1750 status = app->Initialize();
1751 if (status != Solve_Succeeded) {
1752 std::cout << std::endl << std::endl <<
"*** Error during initialization!" << std::endl;
1757 status = app->OptimizeTNLP(mynlp);
1759 if (status == Solve_Succeeded) {
1760 std::cout << std::endl << std::endl <<
"*** The problem solved!" << std::endl;
1763 std::cout << std::endl << std::endl <<
"*** The problem FAILED!" << std::endl;
1771 using namespace Ipopt;
1777 SmartPtr<IpoptApplication> app =
new IpoptApplication();
1780 ApplicationReturnStatus status;
1781 status = app->Initialize();
1782 if (status != Solve_Succeeded) {
1783 printf(
"\n\n*** Error during initialization!\n");
1784 return (
int) status;
1787 status = app->OptimizeTNLP(myadolc_nlp);
1789 if (status == Solve_Succeeded) {
1791 Index iter_count = app->Statistics()->IterationCount();
1792 printf(
"\n\n*** The problem solved in %d iterations!\n", iter_count);
1794 Number final_obj = app->Statistics()->FinalObjective();
1795 printf(
"\n\n*** The final value of the objective function is %e.\n", final_obj);
1798 return (
int) status;
1830 TStrStrMap::const_iterator i = map.lower_bound(search_for);
1831 for(;i != map.end();i++){
1832 const string& key = i->first;
1833 if (key.compare(0, search_for.size(), search_for) == 0) {
1834 cout << i->first <<
", " << i->second << endl;
1868 TStrStrMap::const_iterator i = map_h.upper_bound(search_for);
1869 if(i!= map_h.begin()) i--;
1870 const string& key = i->first;
1871 string search_base = search_for.substr(0,search_for.size()-4);
1872 if (key.compare(0, search_base.size(), search_base) == 0){
1873 cout <<
"MATCH: " << search_for <<
", "<< i->first <<
", " << i->second << endl;
1875 cout <<
"NOTM: " << search_for <<
", "<< i->first << endl;
1886 tMap.insert(
TStrStrPair(
"mortCoeff_multiplier#broadL_highF##2005",
"2005"));
1889 tMap.insert(
TStrStrPair(
"tp_multiplier#broadL_copp##2005",
"-9999"));
1890 tMap.insert(
TStrStrPair(
"tp_multiplier#broadL_highF##2005",
"50"));
1891 tMap.insert(
TStrStrPair(
"tp_multiplier#broadL_highF##2010",
"2010"));
1892 tMap.insert(
TStrStrPair(
"tp_multiplier#broadL_mixedF##2005",
"-9999"));
1893 tMap.insert(
TStrStrPair(
"tp_multiplier#con_copp##2005",
"-9999"));
1894 tMap.insert(
TStrStrPair(
"tp_multiplier#con_highF##2005",
"-9999"));
1895 tMap.insert(
TStrStrPair(
"tp_multiplier#con_mixedF##2005",
"aa"));
1897 TStrStrMap::const_iterator i;
1899 for(i=tMap.begin();i!=tMap.end();i++){
1900 cout << i->first <<
", " << i->second << endl;
@ TYPE_BOOL
The required data is a bool.
@ TYPE_INT
The required data is an integer.
@ TYPE_STRING
The required data is a string.
@ MSG_CRITICAL_ERROR
Print an error message and stop the model.
vector< T > getVectorSetting(string name_h, int type)
map< string, string > TStrStrMap
pair< string, string > TStrStrPair
ThreadManager * MTHREAD
Pointer to the Thread manager.
void msgOut(const int &msgCode_h, const string &msg_h, const bool &refreshGUI_h=true) const
Overloaded function to print the output log.
void fullTest()
Tests that require a full sandbox object including MTHREAD. Normally empty.
T getSetting(string name_h, int type)
vector< TestStructure > testVector
void testPartMatching2()
How to partial matching the key of a map.
T test2(const std::string &s)
void testSearchMap2(const map< string, string > &map_h, const string &search_for)
void basicTest()
Simple tests that doesn't require anything else (are encapsulated) and so they can be run at the begi...
void testPartMatching()
How to partial matching the key of a map.
void testSearchMap(const map< string, string > &map, const string &search_for)
vector< TestStructure * > getTestStructure()
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
volatile TestStructure * agent
void assignJob(TestStructure *agent_h)