69 #include "IpIpoptApplication.hpp" 70 #include "IpSolveStatistics.hpp" 107 cout <<
"the first function\n";
108 cout << nameMember << endl;
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);
1498 vector <string> myStringDatas;
1499 myStringDatas.push_back(
"aaaaa");
1500 myStringDatas.push_back(
"bbbbb");
1501 myStringDatas.push_back(
"ccccc");
1504 for (
int i=0;i<myStringDatas.size();i++){
1505 istringstream iss(myStringDatas[i]);
1508 xVector.push_back(x);
1517 template <
class T> T
1522 string myStringData;
1523 myStringData =
"abcdefg";
1526 myBoolData =
"false";
1529 istringstream iss(myIntData);
1536 istringstream iss(myStringData);
1543 string tempBoolString;
1544 if (myBoolData ==
"1" || myBoolData ==
"true" || myBoolData ==
"True" || myBoolData ==
"TRUE" || myBoolData ==
"vero" || myBoolData ==
"Vero"|| myBoolData ==
"VERO"){
1545 tempBoolString =
"1";
1547 else if (myBoolData ==
"0" || myBoolData ==
"false" || myBoolData ==
"False" || myBoolData ==
"FALSE" || myBoolData ==
"falso" || myBoolData ==
"falso"|| myBoolData ==
"FALSO"){
1548 tempBoolString =
"0";
1551 msgOut(
MSG_CRITICAL_ERROR,
"Impossible conversion of "+myBoolData+
" to bool!. Aborted.");
1553 istringstream iss(tempBoolString);
1562 template<
typename T> T
1564 std::istringstream iss(s);
1571 vector <TestStructure*>
1573 vector <TestStructure*> toReturn;
1574 for (uint i=0;i<testVector.size();i++){
1576 toReturn.push_back(&testVector[i]);
1596 vector<TestStructure*> myAgents;
1597 vector<double> myResults (nAgents, (
double) 0);
1601 for (
int i=0; i < nAgents; i++){
1604 myAgent->
random = (0+( (double)rand() / ((double)(RAND_MAX)+(double)(1)) )*(10-0+1))/ (double)100;
1605 myAgents.push_back(myAgent);
1608 vector <testThread*> myThreads ;
1610 for (
int i=0; i < nThreads; i++){
1612 myThreads.push_back(myThread);
1615 for (uint i=0;i<myAgents.size();i++){
1616 bool assigned =
false;
1618 for (uint j=0;j<myThreads.size();j++){
1619 if (!myThreads[j]->isRunning()){
1620 cout <<
"Assigning agent " << i <<
" to thread " << j << endl;
1621 myThreads[j]->assignJob(myAgents[i]);
1622 myThreads[j]->start();
1627 cout <<
"Thread " << j <<
" is busy" << endl;
1652 for (
int i=0; i < nThreads; i++){
1653 myThreads[i]->wait();
1657 for (
int i=0; i < nThreads; i++){
1658 delete myThreads[i];
1661 for (uint i=0;i<myAgents.size();i++){
1664 double random = (0+( (double)rand() / ((double)(RAND_MAX)+(double)(1)) )*(10-0+1))/ (double)100;
1676 cout <<
"FINITO"<<endl;
1688 cout << agent->i << endl;
1690 double randChange = (0+( (double)rand() / ((double)(RAND_MAX)+(double)(1)) )*(10-0+1))/ (double)100;
1693 vector <double> takeTimeVector (justn, 0);
1694 for (
int i =0; i< justn;i++){
1695 takeTimeVector.at(i)=i*2;
1697 agent->cachedOffer = agent->random;
1710 using namespace Ipopt;
1720 SmartPtr<IpoptApplication> app = IpoptApplicationFactory();
1725 app->Options()->SetNumericValue(
"tol", 1e-7);
1726 app->Options()->SetStringValue(
"mu_strategy",
"adaptive");
1727 app->Options()->SetStringValue(
"output_file",
"ipopt.out");
1738 ApplicationReturnStatus status;
1739 status = app->Initialize();
1740 if (status != Solve_Succeeded) {
1741 std::cout << std::endl << std::endl <<
"*** Error during initialization!" << std::endl;
1746 status = app->OptimizeTNLP(mynlp);
1748 if (status == Solve_Succeeded) {
1749 std::cout << std::endl << std::endl <<
"*** The problem solved!" << std::endl;
1752 std::cout << std::endl << std::endl <<
"*** The problem FAILED!" << std::endl;
1760 using namespace Ipopt;
1766 SmartPtr<IpoptApplication> app =
new IpoptApplication();
1769 ApplicationReturnStatus status;
1770 status = app->Initialize();
1771 if (status != Solve_Succeeded) {
1772 printf(
"\n\n*** Error during initialization!\n");
1773 return (
int) status;
1776 status = app->OptimizeTNLP(myadolc_nlp);
1778 if (status == Solve_Succeeded) {
1780 Index iter_count = app->Statistics()->IterationCount();
1781 printf(
"\n\n*** The problem solved in %d iterations!\n", iter_count);
1783 Number final_obj = app->Statistics()->FinalObjective();
1784 printf(
"\n\n*** The final value of the objective function is %e.\n", final_obj);
1787 return (
int) status;
1819 TStrStrMap::const_iterator i = map.lower_bound(search_for);
1820 for(;i != map.end();i++){
1821 const string& key = i->first;
1822 if (key.compare(0, search_for.size(), search_for) == 0) {
1823 cout << i->first <<
", " << i->second << endl;
1843 testSearchMap(tMap,
"Marl");
1844 testSearchMap(tMap,
"Mo");
1845 testSearchMap(tMap,
"ther");
1846 testSearchMap(tMap,
"Mad");
1847 testSearchMap(tMap,
"Mom");
1848 testSearchMap(tMap,
"Perr");
1849 testSearchMap(tMap,
"Jo");
1857 TStrStrMap::const_iterator i = map_h.upper_bound(search_for);
1858 if(i!= map_h.begin()) i--;
1859 const string& key = i->first;
1860 string search_base = search_for.substr(0,search_for.size()-4);
1861 if (key.compare(0, search_base.size(), search_base) == 0){
1862 cout <<
"MATCH: " << search_for <<
", "<< i->first <<
", " << i->second << endl;
1864 cout <<
"NOTM: " << search_for <<
", "<< i->first << endl;
1875 tMap.insert(
TStrStrPair(
"mortCoeff_multiplier#broadL_highF##2005",
"2005"));
1878 tMap.insert(
TStrStrPair(
"tp_multiplier#broadL_copp##2005",
"-9999"));
1879 tMap.insert(
TStrStrPair(
"tp_multiplier#broadL_highF##2005",
"50"));
1880 tMap.insert(
TStrStrPair(
"tp_multiplier#broadL_highF##2010",
"2010"));
1881 tMap.insert(
TStrStrPair(
"tp_multiplier#broadL_mixedF##2005",
"-9999"));
1882 tMap.insert(
TStrStrPair(
"tp_multiplier#con_copp##2005",
"-9999"));
1883 tMap.insert(
TStrStrPair(
"tp_multiplier#con_highF##2005",
"-9999"));
1884 tMap.insert(
TStrStrPair(
"tp_multiplier#con_mixedF##2005",
"aa"));
1886 TStrStrMap::const_iterator i;
1888 for(i=tMap.begin();i!=tMap.end();i++){
1889 cout << i->first <<
", " << i->second << endl;
1893 testSearchMap2(tMap,
"mortCoeff_multiplier#broadL_highF##2006");
1894 testSearchMap2(tMap,
"tp_multiplier#broadL_highF##2008");
1895 testSearchMap2(tMap,
"aaaaaa");
1896 testSearchMap2(tMap,
"zzzzzz");
void testPartMatching()
How to partial matching the key of a map.
void testPartMatching2()
How to partial matching the key of a map.
vector< TestStructure * > getTestStructure()
The required data is a string.
The required data is a bool.
pair< string, string > TStrStrPair
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
void testSearchMap2(const map< string, string > &map_h, const string &search_for)
Print an error message and stop the model.
void fullTest()
Tests that require a full sandbox object including MTHREAD. Normally empty.
map< string, string > TStrStrMap
T test2(const std::string &s)
vector< T > getVectorSetting(string name_h, int type)
The required data is an integer.
T getSetting(string name_h, int type)
void testSearchMap(const map< string, string > &map, const string &search_for)
void assignJob(TestStructure *agent_h)
void basicTest()
Simple tests that doesn't require anything else (are encapsulated) and so they can be run at the begi...