Changeset 202
- Timestamp:
- 02/17/10 18:30:47 (14 years ago)
- Location:
- trunk/yao/src/YAOObjects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yao/src/YAOObjects/Order.cpp
r194 r202 598 598 void Order::automaticOrderGenerator() { 599 599 600 // Dedicated light structures that will be used to create the main graph then populate its properties 601 // --------------------------------------------------------------------------------------------------- 602 603 vector<edge> edgeArray; 604 vector<string> modulList; 605 vector<int> valCi, valCj, valCk; 606 607 // Array of boolean values that will be used to know the dimensions on which the moduls are defined 608 // ------------------------------------------------------------------------------------------------ 609 610 bool *isDefinedOn = new bool[3]; 611 612 isDefinedOn[0] = false; 613 isDefinedOn[1] = false; 614 isDefinedOn[2] = false; 615 616 // Scan the table of moduls to get relevable informations for setting up the graph and get informations on dimensions 617 // ------------------------------------------------------------------------------------------------------------------ 618 619 for(Table<Modul>::iterator tok_tab = myModulTable -> begin(); tok_tab < myModulTable -> end(); tok_tab++) { 620 621 // Select just the moduls not involved in noward 622 // --------------------------------------------- 623 624 if(!tok_tab ->isNoward()) { 625 626 // Get informations on modul names then populate the modulList vector that will be used by Boost to register the vertex_name property 627 // ---------------------------------------------------------------------------------------------------------------------------------- 628 629 modulList.push_back(tok_tab -> getName()); 630 631 // Get informations on dimensions where are defined the moduls then populate the isDefinedOn array 632 // ----------------------------------------------------------------------------------------------- 633 634 if(tok_tab -> getYA(1) > 0) isDefinedOn[0] = true; 635 if(tok_tab -> getYA(2) > 0) isDefinedOn[1] = true; 636 if(tok_tab -> getYA(3) > 0) isDefinedOn[2] = true; 637 } 638 } 639 640 // Avoid to work on an empty set 641 // ----------------------------- 642 643 if(modulList.size() > 0) { 644 645 646 // Scan the table of the connections to get all relevable informations for generating the order statement 647 // ------------------------------------------------------------------------------------------------------ 600 601 /* 602 * Get informations on the trajectories then map all the spaces with the trajectory in which they are included. 603 * As this information is not provided by the space (the space object have no information about the trajectories), 604 * the mapping is done by extracting spaces and trajectories informations from the moduls. 605 */ 606 607 // Map that will contain the space name as a key and the trajectory name as a matched value 608 // ---------------------------------------------------------------------------------------- 609 610 map<string, string> trajMap; 611 612 // Vector that will contain the trajectories name 613 // ---------------------------------------------- 614 615 vector<string> trajVector; 616 617 // For each modul 618 // -------------- 619 620 for(Table<Modul>::iterator tok_tab = myModulTable -> begin(); tok_tab < myModulTable -> end(); tok_tab++) { 621 622 // If the module is not a noward one 623 // --------------------------------- 624 625 if(!tok_tab -> isNoward()) { 626 627 // By default the trajectory is considerated as a new one 628 // ------------------------------------------------------ 629 630 bool isSetTraj = false; 631 632 // For all the trajectories already integrated in the vector 633 // --------------------------------------------------------- 634 635 for(int noTraj = 0; noTraj < trajVector.size(); noTraj++) 636 637 // If the trajectory match the current one, then it should be considerated as already integrated 638 // --------------------------------------------------------------------------------------------- 639 640 if(!isSetTraj && trajVector[noTraj] == tok_tab -> getTrajectory()) isSetTraj = true; 641 642 // If the trajectory is really a new one, then add it in the trajectories vector 643 // ----------------------------------------------------------------------------- 644 645 if(!isSetTraj) trajVector.push_back(tok_tab -> getTrajectory()); 646 647 // Update the trajectory map with the current couple space / trajectory 648 // -------------------------------------------------------------------- 649 650 trajMap[tok_tab -> getSpaceOrOperator()] = tok_tab -> getTrajectory(); 651 652 } 653 } 654 655 656 /* 657 * Set up a graph that will contain one vertex by space and one edge by pair of moduls connected from different spaces. 658 * As this graph can not contain any clycle, a topological sort is performed to know in which order the spaces should 659 * be intergated in the spaceintraj statement. 660 */ 661 662 // Vector that will contain the space names 663 // ---------------------------------------- 664 665 vector<string> spacesList; 666 667 // For all spaces of the description file, add the space name in the space list 668 // ---------------------------------------------------------------------------- 669 670 for (Table<Operator>::iterator tok_space = mySpaceTable -> begin(); tok_space != mySpaceTable -> end(); ++tok_space) spacesList.push_back(tok_space -> getName()); 671 672 // Create a graph that will be used to sort the spaces 673 // --------------------------------------------------- 674 675 myGraphType spaceGraph; 676 677 // Add one vertex by space 678 // ----------------------- 679 680 for(int i = 0; i < spacesList.size(); i++) add_vertex(spaceGraph); 681 682 // Register the space name inside each vertex 683 // ------------------------------------------ 684 685 for(tie(vertexIterOne, vertexIterTwo) = vertices(spaceGraph); vertexIterOne != vertexIterTwo; ++vertexIterOne) put(get(boost::vertex_name_t(), spaceGraph), *vertexIterOne, spacesList[*vertexIterOne]); 686 687 // For all the connections of the description file 688 // ----------------------------------------------- 648 689 649 690 for(Table<Connection>::iterator tok_tab = myConnectionTable -> begin(); tok_tab < myConnectionTable -> end(); tok_tab++) { 650 691 651 652 692 // Select just the dependencies defined on the current time 693 // --------------------------------------------------------- 653 694 654 695 if(tok_tab -> getT() > -1) { 655 696 656 Table<Modul>::iterator itSource = getModule(tok_tab -> getOutModule()); 657 Table<Modul>::iterator itTarget = getModule(tok_tab -> getInModule()); 658 659 // Select just the moduls not involved in noward (match the condition used to create the modulList vector) 660 // ------------------------------------------------------------------------------------------------------- 661 662 if(!itSource -> isNoward() && !itTarget -> isNoward() ) { 663 664 string sourceName = itSource -> getName(); 665 string targetName = itTarget -> getName(); 666 667 // Setting all pair of integer values that will be used by Boost to manage the edges 668 // ---------------------------------------------------------------------------------- 669 670 int modPairOne = getModulIndex(itSource -> getName(), modulList, modulList.size()); 671 int modPairTwo = getModulIndex(itTarget -> getName(), modulList, modulList.size()); 672 673 edgeArray.push_back(edge(modPairOne, modPairTwo)); 674 675 // Getting informations about spatial dependency between moduls for the dimension i then populate the dedicated vector 676 // ------------------------------------------------------------------------------------------------------------------- 677 678 valCi.push_back(tok_tab -> getI()); 679 680 // Getting informations about spatial dependency between moduls for the dimension j then populate the dedicated vector 681 // ------------------------------------------------------------------------------------------------------------------- 682 683 valCj.push_back(tok_tab -> getJ()); 684 685 // Getting informations about spatial dependency between moduls for the dimension k then populate the dedicated vector 686 // ------------------------------------------------------------------------------------------------------------------- 687 688 valCk.push_back(tok_tab -> getK()); 697 if(!getModule(tok_tab -> getOutModule()) -> isNoward() && !getModule(tok_tab -> getInModule()) -> isNoward()) { 698 699 // If the source modul is not in the same space than the target modul 700 // ------------------------------------------------------------------ 701 702 if(getModule(tok_tab -> getOutModule()) -> getSpaceOrOperator() != getModule(tok_tab -> getInModule()) -> getSpaceOrOperator()) { 703 704 // Add an edge between the space in which the source modul is included and the space in which the target modul is included 705 // ----------------------------------------------------------------------------------------------------------------------- 706 707 int spacePairOne = getModulIndex(getModule(tok_tab -> getOutModule()) -> getSpaceOrOperator(), spacesList, spacesList.size()); 708 709 int spacePairTwo = getModulIndex(getModule(tok_tab -> getInModule()) -> getSpaceOrOperator(), spacesList, spacesList.size()); 710 711 add_edge(spacePairOne, spacePairTwo, spaceGraph); 712 713 } 689 714 } 690 715 } 691 } 692 693 // Get the number of dimensions on which tho moduls are defined 694 // ------------------------------------------------------------ 695 696 switch(isDefinedOn[0] + isDefinedOn[1] + isDefinedOn[2]) { 697 698 // If the moduls are defined on on dimension 699 // ----------------------------------------- 716 } 717 718 // Data structure that will be used by boost to register the topological sort informations 719 // --------------------------------------------------------------------------------------- 720 721 std::deque<int> topoOrder; 722 723 // Perform the topological sort 724 // ---------------------------- 725 726 boost::topological_sort(spaceGraph, std::front_inserter(topoOrder), boost::vertex_index_map(boost::identity_property_map())); 727 728 729 /* 730 * Accordignly to the space ordonnancing that just have been performed, set up an order for the trajectories. 731 * This step could be avoided as it appears that the trajectories can be integrated in any order (for now this step is integrated). 732 * The sorting criteria is the order of the latest space integrated in the trajectory (space order performed over all the trajectories). 733 * The trajectory which the latest space has the lower order Id (in the main space ordonnancing) will be integrated in first. 734 * The trajectory which the latest space has the higher order Id (in the main space ordonnancing) will be integrated in last. 735 */ 736 737 typedef pair<int, string> trajOrderType; 738 739 vector<trajOrderType> trajOrder; 740 741 // For all the trajectories 742 // ------------------------- 743 744 for(int noTraj = 0; noTraj < trajVector.size(); noTraj++) { 745 746 int orderId = -1; 747 748 // For all the spaces 749 // ------------------ 750 751 for(int noSpace = 0; noSpace < topoOrder.size(); noSpace++) { 752 753 // In the order that have been defined to the spaces by the topological sort 754 // ------------------------------------------------------------------------- 755 756 int noTopo = topoOrder[noSpace]; 757 758 // If the current space is a part of the current trajectory 759 // -------------------------------------------------------- 760 761 if(trajMap[spacesList[noTopo]] == trajVector[noTraj]) { 762 763 // Update the orderId value with the current noSpace value 764 // ------------------------------------------------------- 765 766 orderId = noSpace; 767 } 768 } 769 770 // Set to the trajectory is orderId (i.e : order of the latest space that is included in this trajectory) 771 // ------------------------------------------------------------------------------------------------------ 772 773 trajOrder.push_back(trajOrderType(orderId, trajVector[noTraj])); 774 } 775 776 // Sort the trajectories accordingly to their higher space order Id 777 // ---------------------------------------------------------------- 778 779 sort(trajOrder.begin(), trajOrder.end()); 780 781 782 /* 783 * Launch the modinspace generating space by space in the order that have been defined in the spaceintraj generating step just below 784 */ 785 786 // For all the sorted trajectories 787 // -------------------------------- 788 789 for(int noTraj = 0; noTraj < trajOrder.size(); noTraj++) { 790 791 // For all the space numbers 792 // ------------------------- 793 794 for(int noSpace = 0; noSpace < topoOrder.size(); noSpace++) { 795 796 // In the order that have been defined to the spaces by the topological sort 797 // ------------------------------------------------------------------------- 798 799 int noTopo = topoOrder[noSpace]; 800 801 // If the trajectory affected to the sorted space is the current trajectory 802 // ------------------------------------------------------------------------ 803 804 if((trajMap.find(spacesList[noTopo]) -> second).compare(trajOrder[noTraj].second) == 0) { 805 806 // Launch the modinspace generation for the current space 807 // ------------------------------------------------------ 808 809 string spaceName = trajMap.find(spacesList[noTopo]) -> first; 810 811 // Dedicated light structures that will be used to create the main graph then populate its properties 812 // --------------------------------------------------------------------------------------------------- 813 814 vector<edge> edgeArray; 815 vector<string> modulList; 816 vector<int> valCi, valCj, valCk; 817 818 // Array of boolean values that will be used to know the dimensions on which the moduls are defined 819 // ------------------------------------------------------------------------------------------------ 820 821 bool *isDefinedOn = new bool[3]; 822 823 isDefinedOn[0] = false; 824 isDefinedOn[1] = false; 825 isDefinedOn[2] = false; 826 827 // Scan the table of moduls to get relevable informations for setting up the graph and get informations on dimensions 828 // ------------------------------------------------------------------------------------------------------------------ 829 830 for(Table<Modul>::iterator tok_tab = myModulTable -> begin(); tok_tab < myModulTable -> end(); tok_tab++) { 831 832 // If the modul is in the current space 833 // ------------------------------------ 834 835 if(tok_tab -> getSpaceOrOperator() == spaceName) { 836 837 // Select just the moduls not involved in noward 838 // --------------------------------------------- 839 840 if(!tok_tab ->isNoward()) { 841 842 // Get informations on modul names then populate the modulList vector that will be used by Boost to register the vertex_name property 843 // ---------------------------------------------------------------------------------------------------------------------------------- 844 845 modulList.push_back(tok_tab -> getName()); 846 847 // Get informations on dimensions where are defined the moduls then populate the isDefinedOn array 848 // ----------------------------------------------------------------------------------------------- 849 850 if(tok_tab -> getYA(1) > 0) isDefinedOn[0] = true; 851 if(tok_tab -> getYA(2) > 0) isDefinedOn[1] = true; 852 if(tok_tab -> getYA(3) > 0) isDefinedOn[2] = true; 853 } 854 } 855 } 856 857 // Avoid to work on an empty set 858 // ----------------------------- 859 860 if(modulList.size() > 0) { 861 862 863 // Scan the table of the connections to get all relevable informations for generating the order statement 864 // ------------------------------------------------------------------------------------------------------ 865 866 for(Table<Connection>::iterator tok_tab = myConnectionTable -> begin(); tok_tab < myConnectionTable -> end(); tok_tab++) { 867 868 // Select just the dependencies defined on the current time 869 // --------------------------------------------------------- 870 871 if(tok_tab -> getT() > -1) { 872 873 Table<Modul>::iterator itSource = getModule(tok_tab -> getOutModule()); 874 Table<Modul>::iterator itTarget = getModule(tok_tab -> getInModule()); 875 876 877 // If both source and target modules are in the current space 878 // ---------------------------------------------------------- 879 880 if(itSource -> getSpaceOrOperator() == spaceName && itTarget -> getSpaceOrOperator() == spaceName) { 881 882 883 // Select just the moduls not involved in noward (match the condition used to create the modulList vector) 884 // ------------------------------------------------------------------------------------------------------- 885 886 if(!itSource -> isNoward() && !itTarget -> isNoward() ) { 887 888 string sourceName = itSource -> getName(); 889 string targetName = itTarget -> getName(); 890 891 // Setting all pair of integer values that will be used by Boost to manage the edges 892 // ---------------------------------------------------------------------------------- 893 894 int modPairOne = getModulIndex(itSource -> getName(), modulList, modulList.size()); 895 int modPairTwo = getModulIndex(itTarget -> getName(), modulList, modulList.size()); 700 896 701 case 1 : 702 703 // Modify the spatial dependencies vector to offset i dimension to the k dimension then set the dependencies to zero for i and j dimensions 704 // ---------------------------------------------------------------------------------------------------------------------------------------- 705 706 to3D(1, valCi, valCj, valCk, edgeArray.size()); 707 708 // Create the main graph with the informations collected (and modified for spatial dependencies) by scanning YAO tables 709 // -------------------------------------------------------------------------------------------------------------------- 710 711 generateGraph(myGraph, valCi, valCj, valCk, modulList, edgeArray); 712 713 // Launch the main function that will create the vector 3D components, the vectors of 2D components then the vectors of 1D components 714 // ---------------------------------------------------------------------------------------------------------------------------------- 715 716 setOuter(); 717 718 // Read the vector of 1D components to display the order statement (the two first dimensions have dummy values, then the third one is read as the first one) 719 // --------------------------------------------------------------------------------------------------------------------------------------------------------- 720 721 read1D(); 722 723 break; 724 725 case 2 : 726 727 // Modify the spatial dependencies vector to offset i and j dimensions to k j and k dimensions then set the dependencies to zero for the i dimension 728 // ------------------------------------------------------------------------------------------------------------------------------------------------- 729 730 to3D(2, valCi, valCj, valCk, edgeArray.size()); 731 732 // Create the main graph with the informations collected (and modified for spatial dependencies) by scanning YAO tables 733 // -------------------------------------------------------------------------------------------------------------------- 734 735 generateGraph(myGraph, valCi, valCj, valCk, modulList, edgeArray); 736 737 // Launch the main function that will create the vector 3D components, the vectors of 2D components then the vectors of 1D components 738 // ---------------------------------------------------------------------------------------------------------------------------------- 739 740 setOuter(); 741 742 // Read the vector of 2D components to display the order statement (the first dimension have dummy value, then the second and third are read as the first and second) 743 // ------------------------------------------------------------------------------------------------------------------------------------------------------------------ 744 745 read2D(); 746 747 break; 748 749 case 3 : 897 edgeArray.push_back(edge(modPairOne, modPairTwo)); 898 899 // Getting informations about spatial dependency between moduls for the dimension i then populate the dedicated vector 900 // ------------------------------------------------------------------------------------------------------------------- 901 902 valCi.push_back(tok_tab -> getI()); 903 904 // Getting informations about spatial dependency between moduls for the dimension j then populate the dedicated vector 905 // ------------------------------------------------------------------------------------------------------------------- 906 907 valCj.push_back(tok_tab -> getJ()); 908 909 // Getting informations about spatial dependency between moduls for the dimension k then populate the dedicated vector 910 // ------------------------------------------------------------------------------------------------------------------- 911 912 valCk.push_back(tok_tab -> getK()); 750 913 751 // Create the main graph with the informations collectedby scanning YAO tables 752 // -------------------------------------------------------------------------- 914 } 915 } 916 } 917 } 918 919 // Get the number of dimensions on which tho moduls are defined 920 // ------------------------------------------------------------ 921 922 switch(isDefinedOn[0] + isDefinedOn[1] + isDefinedOn[2]) { 923 924 // If the moduls are defined on on dimension 925 // ----------------------------------------- 926 927 case 1 : 928 929 // Modify the spatial dependencies vector to offset i dimension to the k dimension then set the dependencies to zero for i and j dimensions 930 // ---------------------------------------------------------------------------------------------------------------------------------------- 931 932 to3D(1, valCi, valCj, valCk, edgeArray.size()); 933 934 935 resetGraph(myGraph); 936 937 // Create the main graph with the informations collected (and modified for spatial dependencies) by scanning YAO tables 938 // -------------------------------------------------------------------------------------------------------------------- 939 940 generateGraph(myGraph, valCi, valCj, valCk, modulList, edgeArray); 941 942 // Launch the main function that will create the vector 3D components, the vectors of 2D components then the vectors of 1D components 943 // ---------------------------------------------------------------------------------------------------------------------------------- 944 945 setOuter(); 946 947 // Read the vector of 1D components to display the order statement (the two first dimensions have dummy values, then the third one is read as the first one) 948 // --------------------------------------------------------------------------------------------------------------------------------------------------------- 949 950 read1D(); 951 952 break; 953 954 case 2 : 955 956 // Modify the spatial dependencies vector to offset i and j dimensions to k j and k dimensions then set the dependencies to zero for the i dimension 957 // ------------------------------------------------------------------------------------------------------------------------------------------------- 958 959 to3D(2, valCi, valCj, valCk, edgeArray.size()); 960 961 resetGraph(myGraph); 962 963 // Create the main graph with the informations collected (and modified for spatial dependencies) by scanning YAO tables 964 // -------------------------------------------------------------------------------------------------------------------- 965 966 generateGraph(myGraph, valCi, valCj, valCk, modulList, edgeArray); 967 968 // Launch the main function that will create the vector 3D components, the vectors of 2D components then the vectors of 1D components 969 // ---------------------------------------------------------------------------------------------------------------------------------- 970 971 setOuter(); 972 973 // Read the vector of 2D components to display the order statement (the first dimension have dummy value, then the second and third are read as the first and second) 974 // ------------------------------------------------------------------------------------------------------------------------------------------------------------------ 975 976 read2D(); 977 978 break; 979 980 case 3 : 981 982 resetGraph(myGraph); 983 984 // Create the main graph with the informations collectedby scanning YAO tables 985 // -------------------------------------------------------------------------- 753 986 754 generateGraph(myGraph, valCi, valCj, valCk, modulList, edgeArray); 755 756 // Launch the main function that will create the vector 3D components, the vectors of 2D components then the vectors of 1D components 757 // ---------------------------------------------------------------------------------------------------------------------------------- 758 759 setOuter(); 760 761 // Read the vector of 3D components 762 // -------------------------------- 763 764 read3D(); 765 766 setMacroGraph(); 767 768 break; 769 987 generateGraph(myGraph, valCi, valCj, valCk, modulList, edgeArray); 988 989 // Launch the main function that will create the vector 3D components, the vectors of 2D components then the vectors of 1D components 990 // ---------------------------------------------------------------------------------------------------------------------------------- 991 992 setOuter(); 993 994 // Read the vector of 3D components 995 // -------------------------------- 996 997 read3D(); 998 999 break; 1000 1001 } 1002 } 1003 } 1004 } 770 1005 } 771 1006 772 } 1007 1008 /* 1009 * Perform the spaceintraj writting. 1010 * For each trajectory in the trajectories order that have been performed (maybe not needed). 1011 * For each space of the trajectory in the space order that have been performed 1012 */ 1013 1014 1015 // For all the sorted trajectories 1016 // -------------------------------- 1017 1018 for(int noTraj = 0; noTraj < trajOrder.size(); noTraj++) { 1019 1020 cout << endl << "order spaceintraj " << trajOrder[noTraj].second << endl << endl << "\t"; 1021 1022 // For all the space numbers 1023 // ------------------------- 1024 1025 for(int noSpace = 0; noSpace < topoOrder.size(); noSpace++) { 1026 1027 // In the order that have been defined to the spaces by the topological sort 1028 // ------------------------------------------------------------------------- 1029 1030 int noTopo = topoOrder[noSpace]; 1031 1032 // If the trajectory affected to the sorted space is the current trajectory 1033 // ------------------------------------------------------------------------ 1034 1035 if((trajMap.find(spacesList[noTopo]) -> second).compare(trajOrder[noTraj].second) == 0) { 1036 1037 // Insert the space in the spaceintraj order 1038 // ----------------------------------------- 1039 1040 cout << trajMap.find(spacesList[noTopo]) -> first << " "; 1041 } 1042 } 1043 1044 // Close the current spaceintraj statement 1045 // --------------------------------------- 1046 1047 cout << endl << endl << "forder"; 1048 1049 } 1050 773 1051 774 1052 }; … … 1039 1317 if(sign0 != 2 && sign1 == 2 && sign2 == 2) noConf = 2; // i -> j -> k 1040 1318 if(sign0 != 2 && sign1 == 2 && sign2 != 2) noConf = 3; // i -> k -> j (k free) 1041 if(sign0 == 2 && sign1 != 2 && sign2 != 2) noConf = 4; // j -> k -> i (kfree)1319 if(sign0 == 2 && sign1 != 2 && sign2 != 2) noConf = 4; // j -> i -> k (i free) 1042 1320 if(sign0 == 2 && sign1 != 2 && sign2 == 2) noConf = 5; // j -> i -> k 1043 1321 if(sign0 == 2 && sign1 == 2 && sign2 != 2) noConf = 6; // k -> i -> j … … 1161 1439 case 4: 1162 1440 1163 outerComp[noComponent].cfcSign[0].second = outerComp[noComponent].cfcSign[1].second; 1164 outerComp[noComponent].cfcSign[1].second = 0; 1165 outerComp[noComponent].cfcSign[2].second = 2; 1166 outerComp[noComponent].cfcSign[0].first = 1; 1167 outerComp[noComponent].cfcSign[1].first = 2; 1168 outerComp[noComponent].cfcSign[2].first = 0; 1169 1170 if(isImposed[noComponent][1] != 0) outerComp[noComponent].cfcSign[0].second = isImposed[noComponent][1]; 1171 if(isImposed[noComponent][2] != 0) outerComp[noComponent].cfcSign[1].second = isImposed[noComponent][2]; 1172 if(isImposed[noComponent][0] != 0) outerComp[noComponent].cfcSign[2].second = isImposed[noComponent][0]; 1173 1174 if(isImposed1D[noComponent][1] != 0) outerComp[noComponent].cfcSign[0].second = isImposed1D[noComponent][1]; 1175 if(isImposed1D[noComponent][2] != 0) outerComp[noComponent].cfcSign[1].second = isImposed1D[noComponent][2]; 1176 if(isImposed1D[noComponent][0] != 0) outerComp[noComponent].cfcSign[2].second = isImposed1D[noComponent][0]; 1177 1178 if(outerComp[noComponent].cfcSign[0].second == 2) 1179 if(outerComp[noComponent].cfcSign[2].second != 2) 1180 // if(!isToDecompose(1, 2, 0, myGraph)) 1181 if(!isToDecompose(0, myGraph)) 1182 1183 outerComp[noComponent].cfcSign[0].second = 3; 1184 1185 break; 1441 outerComp[noComponent].cfcSign[0].second = outerComp[noComponent].cfcSign[1].second; 1442 outerComp[noComponent].cfcSign[1].second = 0; 1443 1444 outerComp[noComponent].cfcSign[2].second = 2; 1445 outerComp[noComponent].cfcSign[0].first = 1; 1446 outerComp[noComponent].cfcSign[1].first = 0; 1447 outerComp[noComponent].cfcSign[2].first = 2; 1448 1449 if(isImposed[noComponent][1] != 0) outerComp[noComponent].cfcSign[0].second = isImposed[noComponent][1]; 1450 if(isImposed[noComponent][0] != 0) outerComp[noComponent].cfcSign[1].second = isImposed[noComponent][0]; 1451 if(isImposed[noComponent][2] != 0) outerComp[noComponent].cfcSign[2].second = isImposed[noComponent][2]; 1452 1453 if(isImposed1D[noComponent][1] != 0) outerComp[noComponent].cfcSign[0].second = isImposed1D[noComponent][1]; 1454 if(isImposed1D[noComponent][0] != 0) outerComp[noComponent].cfcSign[1].second = isImposed1D[noComponent][0]; 1455 if(isImposed1D[noComponent][2] != 0) outerComp[noComponent].cfcSign[2].second = isImposed1D[noComponent][2]; 1456 1457 if(outerComp[noComponent].cfcSign[0].second == 2) 1458 if(outerComp[noComponent].cfcSign[2].second != 2) 1459 // if(!isToDecompose(1, 2, 0, myGraph)) 1460 if(!isToDecompose(0, myGraph)) 1461 1462 outerComp[noComponent].cfcSign[0].second = 3; 1463 1464 break; 1186 1465 1187 1466 case 5: … … 2966 3245 }; 2967 3246 2968 void Order::setMacroGraph() { 2969 2970 2971 // Data structure used by boost to register informations on component search 2972 // ------------------------------------------------------------------------- 2973 2974 std::vector<int> componentList; 2975 2976 // Resizign the structure : one element for each main graph vertex 2977 // ---------------------------------------------------------------- 2978 2979 componentList.resize(boost::num_vertices(myGraph)); 2980 2981 // Data strcture used by boost to perform component search 2982 // ------------------------------------------------------- 2983 2984 std::vector<vertexDescriptor> verticesDiscoverList(boost::num_vertices(myGraph)); 2985 2986 // Perform a component search on the main graph 2987 // -------------------------------------------- 2988 2989 boost::strong_components(myGraph, &componentList[0], boost::root_map(&verticesDiscoverList[0])); 2990 2991 // Register vertices properties on affected components 2992 // --------------------------------------------------- 2993 2994 for(int i = 0; i < componentList.size(); i++) put(get(boost::vertex_affected_comp_t(), myGraph), i, componentList[i]); 2995 2996 // Getting the number of components 2997 // -------------------------------- 2998 2999 int nbComponents = *max_element(componentList.begin(), componentList.end()) + 1; 3000 3001 // Graph that will be the reduced graph from the main graph 3002 // -------------------------------------------------------- 3003 3004 myGraphType cfcGraph; 3005 3006 // Reduce the main graph and set up the reduced graph 3007 // -------------------------------------------------- 3008 3009 reduceGraph(myGraph, cfcGraph, nbComponents); 3010 3011 // Data structure used by boost to register informations on topological sort 3012 // ------------------------------------------------------------------------- 3013 3014 std::deque<int> topoOrder; 3015 3016 // Do not perform a topological sort if there is just one vertex in the graph 3017 // -------------------------------------------------------------------------- 3018 3019 if(boost::num_vertices(cfcGraph) > 1) { 3020 3021 // Perform a topological sort on the reduced graph 3022 // ----------------------------------------------- 3023 3024 boost::topological_sort(cfcGraph, std::front_inserter(topoOrder), boost::vertex_index_map(boost::identity_property_map())); 3025 3026 // Sort the vertices affected components accordignly to the topological order 3027 // -------------------------------------------------------------------------- 3028 3029 for(int noComponent = 0; noComponent < topoOrder.size(); noComponent++) 3030 put(get(boost::vertex_affected_comp_t(), cfcGraph), noComponent, topoOrder[noComponent]); 3031 } 3032 3033 }; 3247 3248 void Order::resetGraph(myGraphType& currentGraph) { 3249 3250 // Putting iterators inside a vector is more convenient , especially for deletions 3251 // ------------------------------------------------------------------------------- 3252 3253 typedef boost::graph_traits<myGraphType>::edge_iterator edgeIterType; 3254 3255 std::vector<edgeIterType> edgeIterVector; 3256 3257 // Insert all edges of the graph inside a vector of edge 3258 // ----------------------------------------------------- 3259 3260 for(tie(edgeIterOne, edgeIterTwo) = edges(currentGraph); edgeIterOne != edgeIterTwo; ++edgeIterOne) edgeIterVector.push_back(edgeIterOne); 3261 3262 // Reverse the vector to avoid a mess in the indexes when the edges are deleted 3263 // ---------------------------------------------------------------------------- 3264 3265 reverse(edgeIterVector.begin(), edgeIterVector.end()); 3266 3267 // For all edges inside the vector 3268 // ------------------------------- 3269 3270 for(int i = 0; i < edgeIterVector.size(); i++) boost::remove_edge(*(edgeIterVector[i]), currentGraph); 3271 3272 // Putting iterators inside a vector is more convenient , especially for deletions 3273 // ------------------------------------------------------------------------------- 3274 3275 typedef boost::graph_traits<myGraphType>::vertex_iterator vertexIterType; 3276 3277 std::vector<vertexIterType> vertexIterVector; 3278 3279 // Insert all vertices of the graph inside a vector of vertex 3280 // ---------------------------------------------------------- 3281 3282 for(tie(vertexIterOne, vertexIterTwo) = vertices(currentGraph); vertexIterOne != vertexIterTwo; ++vertexIterOne) vertexIterVector.push_back(vertexIterOne); 3283 3284 // Reverse the vector to avoid a mess in the indexes when the vertices are deleted 3285 // ---------------------------------------------------------------------------- 3286 3287 reverse(vertexIterVector.begin(), vertexIterVector.end()); 3288 3289 // For all vertices embeded in the vector 3290 // ----------------------------------- 3291 3292 for(int i = 0; i < vertexIterVector.size(); i++) boost::remove_vertex(*(vertexIterVector[i]), currentGraph); 3293 3294 3295 } ; 3034 3296 3035 3297 -
trunk/yao/src/YAOObjects/Order.hpp
r198 r202 379 379 380 380 /** 381 * Function that set-up a graph that will be used to perform the final groupping procedure 382 * 383 * This function create a graph composed by macro-vertices from the main graph : every vertex of this graph 384 * is made from a component of the main graph and every edge of this graph is an edge that link two components 385 * of the main graph. 386 * 387 * As the component Id affected to each vertex must match the component structure "outerComp" (because many 388 * relevant informations needed by the groupping procedure will be found inside the component structures), it 389 * is very important to keep the correct component Id in the "vertex_affected_comp" property of each macro-vertex. 390 * To keep the referencing between structures and macro-vertices, the same operations than those performed on the 391 * main graph inside the setOuter() function are performed here. 392 * 393 * As every vertex have an affected component (even a single vertex), this graph embed all the relevant informations 394 * to perform the final groupping procedure : 395 * 396 * - Informations on edges linking components are already carried by the graph. 397 * - Informations on components will be naturally found by looking at the tructures indexed by the macro-vertices 398 * "vertex_affected_comp" property 399 * 400 * It could seems to be an overhead to perform the component search and the sorting on the main graph because it have already 401 * been done inside the setOuter() procedure but this is just a first step : 3D components, 2D components and 1D components 402 * should be mixed all together in the same graph, so several operations, not yet implemented, will be needed. 403 */ 404 void setMacroGraph(); 405 381 * Function that reset the main graph and all its properties. 382 * This function make a tabula rasa of the graph that have been created for the latest space 383 * and allow it to register informations on the space that is currently analyzed. 384 * As informations on the graph are just used to create the current modinspace statement, there 385 * is no need to keep those informations from space to space. 386 * As as the main graph (myGraph) is a global data, it is very important to perform this operation. 387 */ 388 void resetGraph(myGraphType& currentGraph); 406 389 407 390
Note: See TracChangeset
for help on using the changeset viewer.