|
From: <koc...@us...> - 2010-03-12 05:21:29
|
Revision: 695
http://scstudio.svn.sourceforge.net/scstudio/?rev=695&view=rev
Author: kocianon
Date: 2010-03-12 05:21:23 +0000 (Fri, 12 Mar 2010)
Log Message:
-----------
hmsc tightening fix.
Modified Paths:
--------------
trunk/src/check/time/hmsc_all_paths.h
trunk/src/check/time/hmsc_block_paths.cpp
trunk/src/check/time/hmsc_block_paths.h
trunk/src/check/time/tightening.h
trunk/tests/tighten_hmsc_test.cpp
Modified: trunk/src/check/time/hmsc_all_paths.h
===================================================================
--- trunk/src/check/time/hmsc_all_paths.h 2010-03-12 02:41:10 UTC (rev 694)
+++ trunk/src/check/time/hmsc_all_paths.h 2010-03-12 05:21:23 UTC (rev 695)
@@ -1,7 +1,6 @@
#ifndef _AllPaths_
#define _AllPaths_
-#include "time_consistency.h"
#include "time_pseudocode.h"
//typedef std::pair<std::list<HMscNodePtr>,bool> HMscPath;
@@ -22,7 +21,7 @@
std::string m_number; //TODO rename to "name" ask Ondra, whether I didn't miss anything
std::list<PathFoundListener*> m_path_found_listeners;
-
+
//preconditions: every path from node first to end node should go through some node from last
public:
AllPaths(HMscPtr hmsc, //TimeRelationRefNodePtr relation,
@@ -30,7 +29,7 @@
const std::string& number="AllPathAlg")
:m_hmsc(hmsc),m_first(first),m_last(last),m_occurence(occurence),m_number(number)
{
-
+
}
~AllPaths()
@@ -54,7 +53,7 @@
for(node=m_nodes_set.begin();node!=m_nodes_set.end();node++)
(*node)->remove_attribute<int>(m_number);
}
-
+
/**
* Traverses given BMscGraph and calls on_path_found method of every added PathFoundListener on all paths, such:
* - the path starts from node first
@@ -62,7 +61,7 @@
* - the path does not contain more than occurence times of same node.
*/
static void traverse(
- HMscPtr hmsc,
+ HMscPtr hmsc,
HMscNodePtr first,
HMscNodePtrSet last,
int occurence
@@ -72,7 +71,7 @@
allpaths.traverse();
}
- void traverse();
+ void traverse();
void all_paths(HMscNodePtr, MscElementPList);
@@ -92,14 +91,14 @@
class PathFoundListener
{
public:
-
+
virtual ~PathFoundListener()
{
-
+
}
-
+
virtual void on_path_found(MscElementPList& path)=0;
-
+
};
#endif
\ No newline at end of file
Modified: trunk/src/check/time/hmsc_block_paths.cpp
===================================================================
--- trunk/src/check/time/hmsc_block_paths.cpp 2010-03-12 02:41:10 UTC (rev 694)
+++ trunk/src/check/time/hmsc_block_paths.cpp 2010-03-12 05:21:23 UTC (rev 695)
@@ -1,16 +1,18 @@
#include "check/time/hmsc_block_paths.h"
+
+/*
void BlockPathFoundListener::on_path_found(MscElementPList& path)
{
std::cout << "mam cestu" << std::endl;
//from hmsc path to bmsc ??
//then tighten ??
}
+*/
-
void AllPathsAllBlocks::all_paths_all_blocks()
-{
+{
// m_hmsc= AllPathsAllBlocks::m_hmsc;
// m_list_of_blocks= AllPathsAllBlocks::m_list_of_blocks;
int i=0;
@@ -20,8 +22,8 @@
std::cout << "Cesty v " << i << " bloku" << std::endl;
m_last.insert(it->get_end());
AllPaths allpaths = AllPaths(m_hmsc, it->get_begin(), m_last, 1);
- BlockPathFoundListener* l= new BlockPathFoundListener();
- allpaths.add_path_found_listener(l);
+
+ allpaths.add_path_found_listener(m_listener);
allpaths.traverse();
m_last.clear();
//don't know exatly what is result of allpaths.traverse() -- maybe list of path found listener??
Modified: trunk/src/check/time/hmsc_block_paths.h
===================================================================
--- trunk/src/check/time/hmsc_block_paths.h 2010-03-12 02:41:10 UTC (rev 694)
+++ trunk/src/check/time/hmsc_block_paths.h 2010-03-12 05:21:23 UTC (rev 695)
@@ -1,31 +1,44 @@
+#ifndef _HMSC_BLOCKPATHS_H_
+#define _HMSC_BLOCKPATHS_H_
-
#include "check/time/hmsc_all_paths.h"
#include "check/time/find_block.h"
class SCTIME_EXPORT BlockPathFoundListener:public PathFoundListener
{
public:
+ BlockPathFoundListener()
+ {}
+
virtual ~BlockPathFoundListener()
{}
- void on_path_found(MscElementPList& path);
+
+ virtual void on_path_found(MscElementPList& path)=0;
};
class AllPathsAllBlocks
{
private:
- HMscPtr m_hmsc;
+ HMscPtr m_hmsc;
HMscNodePtr m_first;
HMscNodePtrSet m_last;
+ PathFoundListener* m_listener;
// int m_occurence;
std::list<Block> m_list_of_blocks;
+
+
public:
- AllPathsAllBlocks(std::list<Block> list_of_blocks, HMscPtr hmsc)//(Block* block, HMscPtr hmsc)
+ AllPathsAllBlocks(std::list<Block> list_of_blocks, HMscPtr hmsc):m_hmsc(hmsc),m_list_of_blocks(list_of_blocks)//(Block* block, HMscPtr hmsc)
{
- this->m_list_of_blocks=list_of_blocks;
- this->m_hmsc=hmsc;
}
void all_paths_all_blocks();
+ void set_listener(PathFoundListener* l)
+ {
+ m_listener = l;
+ }
+
};
+
+#endif // _HMSC_BLOCKPATHS_H_
Modified: trunk/src/check/time/tightening.h
===================================================================
--- trunk/src/check/time/tightening.h 2010-03-12 02:41:10 UTC (rev 694)
+++ trunk/src/check/time/tightening.h 2010-03-12 05:21:23 UTC (rev 695)
@@ -24,7 +24,7 @@
#include "check/pseudocode/msc_duplicators.h"
#include "data/transformer.h"
#include "hmsc_all_paths.h"
-//#include "hmsc_block_paths.h"
+#include "hmsc_block_paths.h"
#include <vector>
@@ -175,7 +175,7 @@
BMscPtr transform(BMscPtr bmsc);
};
-class SCTIME_EXPORT HMscTighter //:public Transformer // , public BMscTransformer
+class SCTIME_EXPORT HMscTighter: public PathFoundListener //:public Transformer // , public BMscTransformer
{
public:
@@ -191,23 +191,30 @@
HMscPtr transform(HMscPtr h)
{
- /*
+ HMscDuplicator duplicator;
+ HMscPtr result = duplicator.duplicate(h);
BMscGraphDuplicator graph_dup;
- HMscPtr bmsc_graph = graph_dup.duplicate_hmsc(h);
- AllPaths all_paths;
- all_paths.
- */
- return NULL;
+ HMscPtr bmsc_graph = graph_dup.duplicate_hmsc(result);
+ TraverseAndMarkBlocks block_marker;
+ block_marker.travers_and_mark_blocks(bmsc_graph);
+
+
+ AllPathsAllBlocks block_to_path(block_marker.m_list_of_blocks,bmsc_graph);
+ block_to_path.set_listener(this);
+ block_to_path.all_paths_all_blocks();
+
+
+ return result;
}
- IntervalSetMatrix tight_path(std::list<MscElement*> path)
+ virtual void on_path_found(std::list<MscElement*>& path)
{
std::list<EventP> events_to_delete;
HMscFlatPathToBMscDuplicator duplicator;
BMscPtr bmsc = duplicator.duplicate_path(path);
-
+
BMscIntervalSetMatrix b_matrix(bmsc); // create matrix
std::map<BMsc*,int> bmsc_to_count;
@@ -232,7 +239,7 @@
b_matrix.add_event(a);
events_to_delete.push_back(a);
rel_to_event[top] = a;
-
+
MinimalEventPList min(in);
std::vector<std::pair<EventP,EventP> > floor(min.size());
for(MinimalEventPList::iterator m=min.begin();m!=min.end();m++)
@@ -254,14 +261,14 @@
{
if((*it)->is_top_node_b())
other = &((*it)->get_ref_node_b()->get_time_relations_top());
- else
+ else
other = &((*it)->get_ref_node_b()->get_time_relations_bottom());
}
- else
+ else
{
if((*it)->is_top_node_a())
other = &((*it)->get_ref_node_a()->get_time_relations_top());
- else
+ else
other = &((*it)->get_ref_node_a()->get_time_relations_bottom());
}
b_matrix.fill(a,rel_to_event[other],(*it)->get_interval_set());
@@ -298,25 +305,25 @@
{
if((*it)->is_top_node_b())
other = &((*it)->get_ref_node_b()->get_time_relations_top());
- else
+ else
other = &((*it)->get_ref_node_b()->get_time_relations_bottom());
}
- else
+ else
{
if((*it)->is_top_node_a())
other = &((*it)->get_ref_node_a()->get_time_relations_top());
- else
+ else
other = &((*it)->get_ref_node_a()->get_time_relations_bottom());
}
b_matrix.fill(rel_to_event[other],a,(*it)->get_interval_set());
}
else
open_rel.insert((*it).get());
- }
+ }
}
b_matrix.build_up();
-
+
IntervalSetMatrix result;
result.resize(b_matrix.size1());
combination.init();
@@ -337,7 +344,7 @@
IntervalSetMatrix new_result = report.m_matrix_result;
-
+
for(unsigned i=0;i<new_result.size1();i++)
for(unsigned j=0;j<new_result.size1();j++)
result(i,j) = MscTimeIntervalSetD::set_union(result(i,j),new_result(i,j));
@@ -349,7 +356,7 @@
}
} while(combination.move_next());
- /*
+
std::map<TimeRelation*, std::pair<unsigned,unsigned> > relations = b_matrix.get_tied_time_relations();
for(std::map<TimeRelation*, std::pair<unsigned,unsigned> >::iterator it=relations.begin();it!=relations.end();it++)
@@ -365,8 +372,6 @@
copy->get_interval_set() = MscTimeIntervalSetD::set_union(copy->get_interval_set(),result(it->second.first,it->second.second));
}
- */
- return result;
}
Modified: trunk/tests/tighten_hmsc_test.cpp
===================================================================
--- trunk/tests/tighten_hmsc_test.cpp 2010-03-12 02:41:10 UTC (rev 694)
+++ trunk/tests/tighten_hmsc_test.cpp 2010-03-12 05:21:23 UTC (rev 695)
@@ -65,8 +65,8 @@
CompleteMessagePtr m21 = new CompleteMessage(L"hi1");
m21->glue_events(e20, e21);
-
-
+
+
MscTimeIntervalD in6(0,5);
MscTimeIntervalD in8(5,10);
MscTimeIntervalD in9(7,D::infinity());
@@ -80,7 +80,7 @@
ins1.insert(in6);
ins1.insert(in9);
-
+
ins2.insert(in10);
ins3.insert(in8);
@@ -91,7 +91,7 @@
TimeRelationEventPtr rel2 = new TimeRelationEvent(ins2);
rel2->glue_events(e20.get(),e21.get());
-
+
Z120 z120;
z120.save_msc(std::cout,L"original 1",bmsc);
@@ -102,12 +102,12 @@
// // SRMChannelMapperPtr srlm = SRMChannelMapper::instance(); //sender-receiver-label
HMscPtr h1(new HMsc(L"h1"));
-
+
StartNodePtr start1 = new StartNode(); h1->set_start(start1);
EndNodePtr end1(new EndNode);h1->add_node(end1);
ReferenceNodePtr p1(new ReferenceNode());h1->add_node(p1);
ReferenceNodePtr p2(new ReferenceNode());h1->add_node(p2);
-
+
start1->add_successor(p1.get());
p1->add_successor(p2.get());
p1->add_successor(p1.get());
@@ -116,10 +116,10 @@
p1->set_msc(bmsc);
p2->set_msc(bmsc2);
-
+
TimeRelationRefNodePtr rel3 = new TimeRelationRefNode(ins3);
rel3->glue_ref_nodes(0,p1.get(),1,p2.get());
-
+
std::cout << " " << std::endl;
std::list<MscElement*> path_list;
@@ -127,27 +127,28 @@
path_list.push_back(p2.get());
HMscTighter* tighter = new HMscTighter();
- IntervalSetMatrix result = tighter->tight_path(path_list);
+ //IntervalSetMatrix result =
+ tighter->on_path_found(path_list);
- std::cout<< "matrix result:" << std::endl;
- std::cout<< result << std::endl;
+ std::cout<< "matrix result:" << std::endl;
+ // std::cout<< result << std::endl;
-
+
HMscFlatPathToBMscDuplicator duplicator;
bmsc2 = duplicator.duplicate_path(path_list);
p1->set_msc(bmsc2);
path_list.clear();
path_list.push_back(p1.get());
rel3->glue_ref_nodes(0,p1.get(),1,p1.get());
- result = tighter->tight_path(path_list);
- std::cout<< result << std::endl;
-
-
+ // result = tighter->tight_path(path_list);
+ // std::cout<< result << std::endl;
- std::cout<< "test finished" << std::endl;
+
+ std::cout<< "test finished" << std::endl;
+
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|