a.binder 9 лет назад
Родитель
Сommit
2445e1d588
2 измененных файлов с 86 добавлено и 35 удалено
  1. 2 2
      SE/dev/php-cli/build__biale_plamy.xml
  2. 84 33
      SE/dev/php-cli/edge_paths_with_PE_controll.xsl

+ 2 - 2
SE/dev/php-cli/build__biale_plamy.xml

@@ -19,7 +19,7 @@
         <property name="points2ID_Way.xml" value="points2ID_Way.xml"/>
         <property name="ways2drogi.xml" value="ways2drogi.xml"/><!--<property name="ways_2ID_Way.xml" value="ways_2ID_Way.xml"/>-->
         
-        <property name="points2joins.xml" value="points2joins.xml"/>
+            <property name="points2joins.xml" value="points2joins.xml"/>
             <property name="ways2joins.xml" value="ways2joins.xml"/>
              <property name="ways_asText.xml" value="ways_asText.xml"/>
     
@@ -32,7 +32,7 @@
             
     
         <property name="points_asText.xml" value="points_asText.xml"/>
-        <property name="points2joins.xml" value="points2joins.xml"/>
+        
         <property name="edge_joins.xml" value="edge_joins.xml"/>
         
             <property name="joins_asText_xml.xsl" value="joins_asText_xml.xsl"/>

+ 84 - 33
SE/dev/php-cli/edge_paths_with_PE_controll.xsl

@@ -14,13 +14,19 @@
     
     <xsl:param name="PE_Price" select="2500"/>
     <xsl:param name="Cable_Price" select="3"/>
+    <xsl:param name="max_combinate_groups_elements" select="14"/> <!-- po ile wezlow mamy grupowac do wyliczania kombinacji kosztow -->
+    <xsl:param name="logic" select="'grouped'"/> <!-- tutaj robi grupy po $max_combinate_groups_elements -->
+    <!--<xsl:param name="logic" select="'sorted'"/>--> <!-- tutaj robi grupy ale analizyje w grupie tylko wazniejsze/bardziej oblozone wezly -->
+    
+    <xsl:param name="debug"/>
+    
     
     <xsl:param name="edge_paths_with_PE.xml"/>
     <xsl:param name="edge_paths_with_PE_controll_temp" select="'edge_paths_with_PE_controll_temp'"/> <!-- cache do przekazywani danych z petli-->
     <xsl:param name="edge_paths_with_PE_controll_temp.alias" select="'edge_paths_with_PE_controll_temp.alias'" />
     
     <!-- bedziemy od najdluzszej drogi starac sie rozmiescic PE w oparciu o rozmieszczenie klientow oraz odleglosci  -->
-    <xsl:variable name="poprzednie_odpalam_liczenie_or_nie"/>
+    
     
     
     <xsl:template match="edge_joins_filled_paths">
@@ -37,6 +43,7 @@
         </xsl:variable>
        
             <edge_paths_with_PE_controll>
+                <xsl:attribute name="logic" select="$logic"/>
                <xsl:apply-templates select="$edge_joins_filled_paths_len" mode="PointMatrixGroup"/>
             </edge_paths_with_PE_controll>
         
@@ -79,10 +86,15 @@
                             <xsl:attribute name="Points" select="count(Points)"/>
                             <xsl:variable name="Points" select="count(Points)"/>
                             <xsl:variable name="Ways" select="count(Ways)"/>
+                            
+                            
+                            
                         <xsl:choose>
                             <xsl:when test="$Ways or $Points">
                                 <xsl:attribute name="point_count" select="$Points + $Ways"/>
+                                <xsl:attribute name="NotPoints" select="0"/><!-- do Grupowanai potrzebne aby nie liczyc tych w count -->
                             </xsl:when>
+                            <xsl:otherwise><xsl:attribute name="NotPoints" select="1"/></xsl:otherwise><!-- do Grupowanai potrzebne aby nie liczyc tych w count -->
                         </xsl:choose>
                         </distance>
                     </xsl:for-each>
@@ -109,9 +121,13 @@
                                     <xsl:variable name="cost_dist" select="$Cable_Price * $disttopkt * @point_count"/>
                                     <xsl:attribute name="cost_dist" select="$cost_dist"/>
                                     <xsl:attribute name="point_count" select="@point_count"/>
-                                    <xsl:if test="$cost_dist &gt; $PE_Price">
-                                        <xsl:attribute name="cut_by_pe" select="1"/>
-                                    </xsl:if>
+                                    <xsl:choose> <!-- to powinno przeciac grupe ale moze nie? -->
+                                        <xsl:when test="$cost_dist &gt; $PE_Price">
+                                            <xsl:attribute name="cut_by_pe" select="1"/>
+                                        </xsl:when>
+                                        <xsl:otherwise><xsl:attribute name="cut_by_pe" select="0"/></xsl:otherwise>
+                                    </xsl:choose>
+                                   
                                     <xsl:attribute name="not_id" select="@not_id"/>
                                 </xsl:when>
                                 <xsl:otherwise>
@@ -122,31 +138,54 @@
                             <xsl:copy-of select="@point_count"/>
                             <xsl:copy-of select="@pos"/>
                             <xsl:copy-of select="@len"/>
+                            <xsl:copy-of select="@ForceCutByPrice"/>
+                            
+                            <xsl:choose>
+                                <xsl:when test="(position() - sum($EconomicDistanceCut/EconomicDistanceCut/distance[ number(@pos) &lt; number(current()/@pos) ]/number(@NotPoints)) ) mod $max_combinate_groups_elements = 0"><!-- nabija grupe do przeliczenia-->
+                                    <xsl:attribute name="PosCut3Flag" select="1"/>
+                                </xsl:when>
+                                <xsl:otherwise>
+                                    <xsl:attribute name="PosCut3Flag" select="0"/>
+                                    <!--<xsl:attribute name="pos-sum"  select="position() - sum($EconomicDistanceCut/EconomicDistanceCut/distance[ number(@pos) &lt; number(current()/@pos) ]/number(@NotPoints))"/>-->
+                                </xsl:otherwise>
+                            </xsl:choose>
                         </distance2>
                     </xsl:for-each>
                 </EconomicDistanceCut2>
             </xsl:variable>
             
+            <!--<xsl:copy-of select="$EconomicDistanceCut2"/>-->
+            
+            <xsl:variable name="EconomicDistanceCut2"> <!-- dla potrzeb przegrupowania po iles do wyliczen grup i posortowania -->
+                <EconomicDistanceCut2><xsl:attribute name="debug" select="'add mod gr'"/>
+                    <xsl:for-each select="$EconomicDistanceCut2/EconomicDistanceCut2/distance2"> <!-- [@point_count &gt; 0] -->
+                        <distance2>
+                            <xsl:copy-of select="@*"/>
+                            <xsl:attribute name="PosCut3GrId" select="sum($EconomicDistanceCut2/EconomicDistanceCut2/distance2[ number(@pos) &lt; number(current()/@pos) ]/number(@PosCut3Flag))"/>
+                        </distance2>
+                    </xsl:for-each>
+                </EconomicDistanceCut2>
+            </xsl:variable>
             <xsl:copy-of select="$EconomicDistanceCut2"/>
             
+            
             <xsl:variable name="elements_cnt" select="count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[@point_count &gt; 0])"/><!-- liczba wezlow potencjalnych licbza PE-->
             <!--<xsl:variable name="bit_max" select="round($len  div  ( $PE_Price div $Cable_Price ) + count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[@cost_dist &gt; $PE_Price])  )"/>--><!-- max licbza PE-->
             
             
             
-            
             <!-- pogrupujemy elementy co 50 metrow -->
             <xsl:variable name="PointMatrixGroup">
                 <PointMatrixGroup>
-                    <xsl:for-each-group select="$EconomicDistanceCut2/EconomicDistanceCut2/distance2" group-by="round( @distance div ( $PE_Price div $Cable_Price + 50 ))">
+                    <xsl:for-each-group select="$EconomicDistanceCut2/EconomicDistanceCut2/distance2" group-by="@PosCut3GrId "> <!-- stare : round( @distance div ( $PE_Price div $Cable_Price + 50 ))-->
                         <PointMatrixGroupPos>
                             <xsl:variable name="elements_cnt_Pos" select="count(current-group()[@point_count &gt; 0])"/>
                             <xsl:variable name="bit_max_Pos" select="round(sum( current-group()/@disttopkt )  div  ( $PE_Price div 20 ) )"/>
-                            <xsl:attribute name="distanceGr" select=" current-grouping-key()"/>
+                            <xsl:attribute name="distanceGr" select="@PosCut3GrId "/> <!-- bylo current-grouping-key() -->
                             <xsl:attribute name="elements_cnt_Pos" select="$elements_cnt_Pos"/>
                             <xsl:attribute name="bit_max_Pos" select="$bit_max_Pos"/>
                             <xsl:attribute name="id_path" select="@id_path"/>
-                            <xsl:attribute name="point_count_Pos" select="sum(current-group()/@point_count)"/>
+                            <xsl:attribute name="point_count_Pos" select="sum(current-group()/@point_count)"/><!-- po przesortowaniu z usunieciem wezlow bez skojarzen przylaczy - jest to nieprawdziwe - rzebaa dodac te dane z poprzednich sciezek itp -->
                             <xsl:attribute name="LineStringCount" select="count( current-group())"/>
                             <xsl:attribute name="len_sum" select="sum(current-group()/@len)"/>
                             <xsl:attribute name="distanceBeg" select="min(current-group()/number(@distance))"/>
@@ -166,7 +205,8 @@
                 gdzie najwiecej klientow walimy wezly - grupujemy ilosciami klientow dzielac sume drogi na ilosc przewidzianych wezlow
             -->
             <!-- debug -->
-            <xsl:copy-of select="$PointMatrixGroup"/>
+           
+            <!--<xsl:copy-of select="$PointMatrixGroup"/>-->
             <PointMatrixGroupPE>
             <xsl:for-each select="$PointMatrixGroup/PointMatrixGroup">
                 <xsl:for-each select="PointMatrixGroupPos">
@@ -174,7 +214,9 @@
                 <xsl:variable name="point_count_Pos" select="@point_count_Pos"/>
                 <xsl:variable name="distanceGr" select="@distanceGr"/>
                     <PointMatrixGroup>
-                        <xsl:attribute name="bit_max_Pos" select="$bit_max_Pos"/><xsl:attribute name="point_count_Pos" select="$point_count_Pos"/><xsl:attribute name="distanceGr" select="$distanceGr"/>
+                        <xsl:attribute name="bit_max_Pos" select="$bit_max_Pos"/>
+                        <xsl:attribute name="point_count_Pos" select="$point_count_Pos"/>
+                        <xsl:attribute name="distanceGr" select="$distanceGr"/>
                         <xsl:attribute name="LineStringCount" select="@LineStringCount"/>
                         <xsl:attribute name="len_sum" select="@len_sum"/>
                         <xsl:attribute name="point_count_Pos" select="@point_count_Pos"/>
@@ -182,7 +224,7 @@
                         <xsl:attribute name="distanceEnd" select="@distanceEnd"/>
                 <!-- ida kandydaci -->
                         <xsl:variable name="candidates">
-                            <xsl:for-each select="distance2[( position() &lt;= $bit_max_Pos and @point_count &gt;0 ) or (  position()=1 and $point_count_Pos &gt; 0 )  or position()= last()]"> <!-- jak jest maly wspolczynnik to chociaz jeden punkt jak sa punkty jakies w tej grupie -->
+                            <xsl:for-each select="distance2[ (  $logic='sorted' and  ( position() &lt;= $bit_max_Pos and @point_count &gt;0 ) or (  position()=1 and $point_count_Pos &gt; 0 )  or position()= last()  )   or ( @point_count &gt;0 and $logic='grouped'  )  ]">  <!--@point_count &gt;0-->  <!--( position() &lt;= $bit_max_Pos and @point_count &gt;0 ) or (  position()=1 and $point_count_Pos &gt; 0 )  or position()= last() --> <!-- jak jest maly wspolczynnik to chociaz jeden punkt jak sa punkty jakies w tej grupie -->
                                     <xsl:sort select="@cost_dist" order="descending"/>
                                     <bp:Path_Point>
                                         <xsl:attribute name="DebugPosPoint" select="position()"/>
@@ -194,7 +236,6 @@
                                         <xsl:attribute name="cost_dist" select="@cost_dist"/>
                                         <xsl:attribute name="id_path" select="@id_path"/>
                                         <xsl:attribute name="point_count" select="@point_count"/>
-                                        
                                         <xsl:attribute name="X" select="$edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString[@id_path = current()/@id_path]/@X"/>
                                         <xsl:attribute name="Y" select="$edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString[@id_path = current()/@id_path]/@Y"/>
                                     </bp:Path_Point>
@@ -220,10 +261,9 @@
                             <xsl:attribute name="cache_file_name_previous" select="$cache_file_name_previous"/>
                             <xsl:copy-of select="$poprzednie_odpalam_liczenie_or_nie/poprzednie_odpalam_liczenie_or_nie"/>
                         </poprzednie_odpalam_liczenie_or_nie>-->
-                        
                         <xsl:variable name="odpalam_liczenie_or_nie">
                             <xsl:choose>
-                                <xsl:when test="count($candidates/bp:Path_Point) &lt; 14  and count($candidates/bp:Path_Point)&gt;1">
+                                <xsl:when test="count($candidates/bp:Path_Point) &lt;= $max_combinate_groups_elements  and count($candidates/bp:Path_Point)&gt;1">
                                     <xsl:variable name="max_bit">
                                         <xsl:for-each select="1 to count($candidates/bp:Path_Point)"><xsl:value-of select="1"/></xsl:for-each>
                                     </xsl:variable>
@@ -251,8 +291,19 @@
                         <xsl:copy-of select="$odpalam_liczenie_or_nie"/>
                         <xsl:result-document href="{$cache_file_name}"> <!-- zapisanie do cache, aby odczytac w kolejnej petli-->
                             <poprzednie_odpalam_liczenie_or_nie>
-                                <xsl:copy-of select="$odpalam_liczenie_or_nie/odpalam_liczenie/koniec_wariantow/bp:Path_Point"/>
-                                <xsl:copy-of select="$odpalam_liczenie_or_nie/bp:Path_Point"/>
+                                <xsl:for-each select="$odpalam_liczenie_or_nie/odpalam_liczenie/koniec_wariantow/bp:Path_Point">
+                                    <xsl:if test="position() = last()">
+                                        <xsl:copy-of select="."/>
+                                    </xsl:if>
+                                </xsl:for-each>
+                                <nizej_zwykly></nizej_zwykly>
+                                <xsl:for-each select="$odpalam_liczenie_or_nie/bp:Path_Point">
+                                    <xsl:if test="position() = last()">
+                                        <xsl:copy-of select="."/>
+                                    </xsl:if>
+                                </xsl:for-each>
+                                <!--<xsl:copy-of select="$odpalam_liczenie_or_nie/odpalam_liczenie/koniec_wariantow/bp:Path_Point"/>
+                                <xsl:copy-of select="$odpalam_liczenie_or_nie/bp:Path_Point"/>-->
                             </poprzednie_odpalam_liczenie_or_nie>
                         </xsl:result-document>
                     </PointMatrixGroup>
@@ -299,12 +350,14 @@
             </xsl:for-each>
         </xsl:variable>
         <!-- debug -->
-        <variant><xsl:attribute name="variant" select="$variant"/>
-            <xsl:attribute name="cur_bit" select="$bit"/>
-            <xsl:attribute name="best_cost" select="$best_cost"/>
-            <xsl:attribute name="best_variant" select="$best_variant"/>
-        <xsl:copy-of select="$cand_to_calc"/>
-        </variant>
+        <xsl:if test="$debug">
+            <variant><xsl:attribute name="variant" select="$variant"/>
+                <xsl:attribute name="cur_bit" select="$bit"/>
+                <xsl:attribute name="best_cost" select="$best_cost"/>
+                <xsl:attribute name="best_variant" select="$best_variant"/>
+            <xsl:copy-of select="$cand_to_calc"/>
+            </variant>
+        </xsl:if>
         <xsl:variable name="calc_cost_way">
             <xsl:call-template name="calc_cost_way">
                 <xsl:with-param name="cand_to_calc" select="$cand_to_calc"/>
@@ -319,7 +372,7 @@
                 <xsl:copy-of select="$calc_cost_way"/>    
             </costs>
         </xsl:variable>
-        <xsl:copy-of select="$cost_sum"></xsl:copy-of>
+        <xsl:if test="$debug"><xsl:copy-of select="$cost_sum"/></xsl:if>
         <xsl:variable name="best">
             <xsl:variable name="cur_Price" select="$cost_sum/costs/@Price"/>
             <xsl:choose>
@@ -369,7 +422,6 @@
                 </xsl:call-template>
             </xsl:otherwise>
         </xsl:choose>
-        
     </xsl:template>
     
     <xsl:template name="calc_cost_way"><!-- do wyliczenia ile wyjda kable w takiej konfiguracji -->
@@ -390,13 +442,13 @@
             </xsl:for-each>
             <!--<xsl:copy-of select="$cand_to_calc/bp:Path_Point"/>-->
         </xsl:variable>
-        
-        <!--<candidates_merged_with_poprzednie>
-            <cand_to_calc><xsl:copy-of select="$cand_to_calc"/></cand_to_calc>
-            <poprzedniee><xsl:copy-of select="$poprzednie_odpalam_liczenie_or_nie/poprzednie_odpalam_liczenie_or_nie"/></poprzedniee>
-            <merged><xsl:copy-of select="$candidates_merged_with_poprzednie"/></merged>
-        </candidates_merged_with_poprzednie>-->
-        
+        <xsl:if test="$debug">
+                <candidates_merged_with_poprzednie>
+                    <cand_to_calc><xsl:copy-of select="$cand_to_calc"/></cand_to_calc>
+                    <poprzedniee><xsl:copy-of select="$poprzednie_odpalam_liczenie_or_nie/poprzednie_odpalam_liczenie_or_nie"/></poprzedniee>
+                    <merged><xsl:copy-of select="$candidates_merged_with_poprzednie"/></merged>
+                </candidates_merged_with_poprzednie>
+        </xsl:if>
         <xsl:for-each select="$candidates_merged_with_poprzednie/bp:Path_Point"> <!-- bylo cand_to_calc  -->
             <xsl:choose>
                 <xsl:when test="@poprzednia_grupa">
@@ -404,7 +456,7 @@
                         <xsl:attribute name="Cable_Price" select="0"/>
                         <xsl:attribute name="PE_Price" select="0"/>
                         <xsl:attribute name="Price" select="0"/>
-                        <xsl:attribute name="debug" select="'ignore by last DistGroup'"/>
+                        <xsl:attribute name="debug" select="'ignore by last DistGroup @poprzednia_grupa'"/>
                     </cost>
                 </xsl:when>
                 <xsl:when test="@bin_pos=0"><!-- szukamy gdzie ma najblizej i za ile -->
@@ -479,7 +531,6 @@
                 </xsl:otherwise>
             </xsl:choose>
         </xsl:for-each>
-        
     </xsl:template>