Index: /applications/robust/main.cpp
===================================================================
--- /applications/robust/main.cpp (revision 1413)
+++ /applications/robust/main.cpp (revision 1423)
@@ -31,11 +31,11 @@
 const int max_model_order         = 2;
 const double apriorno             = 0.01;
-const int max_window_size         = 30;
+const int max_window_size         = 40;
 const int utility_order           = 25;
 const int prediction_time         = 30;
 const double min_utility_argument = 0.001;
-const double max_investment       = 10.0;
+const double max_investment       = 3.0;
 const int sample_size			  = 5000;
-const char* commodity		      = "BP\\";
+const char* commodity		      = "TY\\";
 
 /*
@@ -484,6 +484,9 @@
 			for(int window_size = max_window_size-1;window_size < max_window_size;window_size++)
 			{
-				models.push_back(new model((*model_type),true,true,window_size,0,&data_matrix));   // to su len konstruktory, len inicializujeme rozne typy
-				models.push_back(new model((*model_type),false,true,window_size,0,&data_matrix));
+				//if(model_type->size()<max_model_order)
+				//{
+					models.push_back(new model((*model_type),true,true,window_size,0,&data_matrix));   // to su len konstruktory, len inicializujeme rozne typy
+					models.push_back(new model((*model_type),false,true,window_size,0,&data_matrix));
+				//}
 				models.push_back(new model((*model_type),true,false,window_size,0,&data_matrix));
 				models.push_back(new model((*model_type),false,false,window_size,0,&data_matrix));		
Index: /applications/robust/robustlib.h
===================================================================
--- /applications/robust/robustlib.h (revision 1413)
+++ /applications/robust/robustlib.h (revision 1423)
@@ -280,4 +280,9 @@
 		return multiplicity;
 	}
+
+	void set_multiplicity(int multiplicity)
+	{
+		this->multiplicity = multiplicity;
+	}
 	
 	/// An obligatory operator, when the class is used within a C++ STL structure like a vector
@@ -701,4 +706,5 @@
 	{			
 
+		int multi = sender->get_multiplicity();
 		// We translate existence of toremove and toadd conditions to booleans for ease of manipulation
 		bool shouldmerge    = (toremove != NULL);
@@ -1138,7 +1144,8 @@
 				
 				
-				if(i==statistic.size()-1)
-				{
-					orders.insert(((toprow*)horiz_ref)->condition_order);
+				
+				//if(i==statistic.size()-1)
+				//{
+				//	orders.insert(((toprow*)horiz_ref)->condition_order);
 					
 					/*
@@ -1146,5 +1153,5 @@
 					cout << "Condition: " << ((toprow*)horiz_ref)->condition_sum << endl;
 					cout << "Order:" << ((toprow*)horiz_ref)->condition_order << endl;*/
-				}
+				//}
 				
 
@@ -1269,6 +1276,6 @@
 
 	void add_and_remove_condition(vec toadd, vec toremove)
-	{
-
+	{	
+		
 		// New condition arrived (new data are available). Here we will perform the Bayesian data update
 		// step by splitting the location parameter space with respect to the new condition and computing
@@ -1447,5 +1454,5 @@
 						// occurence of a point laying on the cutting hyperplane (Programmers note:Also such 
 						// scenarios were not so well tested and computation errors may occur!)
-						cout << "Condition to add: " << toadd << endl;
+						//cout << "Condition to add: " << toadd << endl;
 						cout << "Vertex coords: " << appended_coords << endl;
 
@@ -1570,18 +1577,7 @@
 						// parents.
 						(*merge_ref)->parentconditions.erase(condition_to_remove);
-
-						// If the merger is a vertex..
-						if(k==1)
-						{
-							// ..we will later reduce its multiplicity (this is to prevent multiple reduction of
-							// the same vertex) 
-							vertices_to_be_reduced.insert((vertex*)(*merge_ref));
-						}
-						// If the merger is not a vertex..
-						else
-						{
-							// lower the multiplicity of the merger
-							(*merge_ref)->lower_multiplicity();
-						}	
+						
+						(*merge_ref)->negativeparent = NULL;
+						(*merge_ref)->positiveparent = NULL;					
 
 						// If the merger will not be split and it is not totally neutral with respect to SPLIT
@@ -1842,5 +1838,19 @@
 						normalization_factor += current_positive->triangulate(k==for_splitting.size()-1 && !will_be_split);
 					}
-				}			
+
+					// If the merger is a vertex..
+					if(k==1)
+					{
+						// ..we will later reduce its multiplicity (this is to prevent multiple reduction of
+						// the same vertex) 
+						vertices_to_be_reduced.insert((vertex*)(*merge_ref));
+					}
+					// If the merger is not a vertex..
+					else
+					{
+						// lower the multiplicity of the merger
+						(*merge_ref)->lower_multiplicity();
+					}
+				}				
 			
 				// And we go to the next row
@@ -1855,5 +1865,8 @@
 				for(list<polyhedron*>::iterator merge_ref = for_merging[i].begin();merge_ref!=for_merging[i].end();merge_ref++)
 				{
-					delete (*merge_ref);
+					if((*merge_ref)->get_multiplicity()==0)
+					{
+						delete (*merge_ref);
+					}
 				}
 			}
@@ -1877,4 +1890,5 @@
 		}
 		
+		//step_me(3);
 		// This is a control check for errors in the merging procedure.
 		/*
@@ -2026,4 +2040,7 @@
 					negative_poly->parentconditions.insert(current_polyhedron->parentconditions.begin(),current_polyhedron->parentconditions.end());
 
+					positive_poly->set_multiplicity(current_polyhedron->get_multiplicity());
+					negative_poly->set_multiplicity(current_polyhedron->get_multiplicity());
+
 					// We loop through the parents of the split polyhedron
 					for(list<polyhedron*>::iterator parent_ref = current_polyhedron->parents.begin();parent_ref!=current_polyhedron->parents.end();parent_ref++)
@@ -2145,5 +2162,5 @@
 		}
 		*/
-
+				
 		// step_me(101);
 	}
@@ -2776,39 +2793,49 @@
 	void bayes(itpp::vec yt)
 	{
-		if(has_constant)
-		{
-			int c_size = yt.size();
+		bool informative = true;
+		for(int i=1;i<yt.size();i++)
+		{
+			if(yt.get(i)==0.0)
+			{
+				informative = false;
+			}
+		}
+
+		if(informative)
+		{
+			if(has_constant)
+			{
+				int c_size = yt.size();
 			
-			yt.ins(c_size,1.0);
-		}		
-
-		if(yt.size() == posterior->number_of_parameters+1)
-		{
-			conditions.push_back(yt);		
-		}
-		else
-		{
-			throw new exception("Wrong condition size for bayesian data update!");
-		}
-
-		//posterior->step_me(0);
+				yt.ins(c_size,1.0);
+			}		
+
+			if(yt.size() == posterior->number_of_parameters+1)
+			{
+				conditions.push_back(yt);		
+			}
+			else
+			{
+				throw new exception("Wrong condition size for bayesian data update!");
+			}
+
+			//posterior->step_me(0);
 		
-		cout << "*************************************" << endl << "Current condition:" << yt << endl << "*************************************" << endl;
-
-		/// \TODO tohle je spatne, tady musi byt jiny vypocet poctu podminek, kdyby nejaka byla multiplicitni, tak tohle bude spatne
-		if(conditions.size()>window_size && window_size!=0)
-		{
-			posterior->add_and_remove_condition(yt,conditions.front());
-			conditions.pop_front();
-
-			//posterior->step_me(1);
-		}
-		else
-		{
-			posterior->add_condition(yt);
-		}
-
-		
-				
+			cout << "*************************************" << endl << "Added condition:  " << yt << endl << "*************************************" << endl;
+
+			/// \TODO tohle je spatne, tady musi byt jiny vypocet poctu podminek, kdyby nejaka byla multiplicitni, tak tohle bude spatne
+			if(conditions.size()>window_size && window_size!=0)
+			{
+				cout << "*************************************" << endl << "Removed condition:" << conditions.front() << endl << "*************************************" << endl;
+			
+				posterior->add_and_remove_condition(yt,conditions.front());
+				conditions.pop_front();
+				//posterior->step_me(1);
+			}
+			else
+			{
+				posterior->add_condition(yt);
+			}
+		}				
 	}
 
Index: /applications/robust/DDEClient.cpp
===================================================================
--- /applications/robust/DDEClient.cpp (revision 1358)
+++ /applications/robust/DDEClient.cpp (revision 1423)
@@ -30,5 +30,5 @@
 #include <windows.h>
 #include <ddeml.h>
-#include <atlstr.h>		// only for string handling of error messages
+//#include <atlstr.h>		// only for string handling of error messages
 #include "DCErrors.h"	// Error messages for dll
 
Index: /applications/robust/CMakeLists.txt
===================================================================
--- /applications/robust/CMakeLists.txt (revision 1361)
+++ /applications/robust/CMakeLists.txt (revision 1423)
@@ -14,8 +14,7 @@
 link_directories (${BDM_SOURCE_DIR}/bdm)
 
-add_library(robustlib robustlib.cpp robustlib.h)
-add_library(DDEClient SHARED ddeclient.cpp ddeclient.h dcerrors.h)
+add_library(robustlib robustlib.cpp robustlib.h)  
 
-EXEC(main robustlib DDEClient)
+EXEC(main robustlib)
 
 
