a.binder 9 лет назад
Родитель
Сommit
21c435e056
1 измененных файлов с 58 добавлено и 30 удалено
  1. 58 30
      SE/dev/php-cli/edge_paths_with_PE_controll.xsl

+ 58 - 30
SE/dev/php-cli/edge_paths_with_PE_controll.xsl

@@ -14,7 +14,7 @@
     
     <xsl:param name="PE_Price" select="2500"/>
     <xsl:param name="Cable_Price" select="3"/>
-    <xsl:param name="max_combinate_groups_elements" select="12"/> <!-- po ile wezlow mamy grupowac do wyliczania kombinacji kosztow -->
+    <xsl:param name="max_combinate_groups_elements" select="10"/> <!-- 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 -->
     
@@ -90,24 +90,25 @@
                             <xsl:attribute name="not_id" select="@not_id"/>
                             <xsl:attribute name="len" select="@len"/>
                             <xsl:attribute name="id_path" select="@id_path"/>
-                            <xsl:attribute name="Points" select="count(Points)"/>
                             <xsl:variable name="Points" select="count(Points)"/>
+                            <xsl:attribute name="Points" select="$Points"/>
                             <xsl:variable name="Ways" select="count(Ways)"/>
-                            
-                            
-                            
-                        <xsl:choose>
+                            <xsl:attribute name="Ways_count" select="$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: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:otherwise><xsl:attribute name="NotPoints" select="1"/>
+                                <xsl:attribute name="point_count" select="0"/>
+                            </xsl:otherwise><!-- do Grupowanai potrzebne aby nie liczyc tych w count -->
                         </xsl:choose>
                         </distance>
                     </xsl:for-each>
             </EconomicDistanceCut>
         </xsl:variable>
         <!--<xsl:copy-of select="$EconomicDistanceCut"/>-->
+            
             <xsl:variable name="EconomicDistanceCut2">
                 <EconomicDistanceCut2>
                     <xsl:for-each select="$EconomicDistanceCut/EconomicDistanceCut/distance">
@@ -115,7 +116,7 @@
                             <xsl:attribute name="distance" select="sum( $EconomicDistanceCut/EconomicDistanceCut/distance[number(@pos )&lt;  number(current()/@pos )]/@len)"/>
                             <!-- suma do poprzedniego pkt tylko dla tych co maja pkt-->
                             <xsl:choose>
-                                <xsl:when test="@point_count&gt;0">
+                                <xsl:when test="number(@point_count)&gt;0">
                                     <xsl:variable name="max_pos_z_pkt" select="max($EconomicDistanceCut/EconomicDistanceCut/distance[
                                         number(@pos )&lt;  number(current()/@pos ) and number(@point_count)&gt;0
                                         ]/@pos)"/>
@@ -125,35 +126,52 @@
                                         and number(@pos) &gt;= number($max_pos_z_pkt) 
                                         ]/@len)"/>
                                     <xsl:attribute name="disttopkt" select="$disttopkt" />
-                                    <xsl:variable name="cost_dist" select="$Cable_Price * $disttopkt * @point_count"/>
+                                    <xsl:variable name="cost_dist" select="$Cable_Price * $disttopkt * number(@point_count)"/>
                                     <xsl:attribute name="cost_dist" select="$cost_dist"/>
                                     <xsl:attribute name="point_count" select="@point_count"/>
+                                    <xsl:attribute name="Ways_count" select="@Ways_count"/>
                                     <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:attribute name="not_id" select="@not_id"/> <!-- to jest z ID way - way ma 2 pointsy! -->
                                 </xsl:when>
                                 <xsl:otherwise>
-                                    <xsl:attribute name="point_count" select="0"/>
+                                    <xsl:choose>
+                                        <xsl:when test="number(@Ways_count)&gt;0">
+                                            <xsl:attribute name="point_count" select="@Ways_count"/>
+                                        </xsl:when>
+                                        <xsl:otherwise><xsl:attribute name="point_count" select="0"/></xsl:otherwise>
+                                    </xsl:choose>
                                 </xsl:otherwise>
                             </xsl:choose>
                             <xsl:attribute name="id_path" select="@id_path"/>
                             <xsl:copy-of select="@point_count"/>
-                            <xsl:copy-of select="@pos"/>
+                            <xsl:copy-of select="@pos"/><!-- position() -->
                             <xsl:copy-of select="@len"/>
                             <xsl:copy-of select="@ForceCutByPrice"/>
-                            
+                            <!--<xsl:copy-of select="@NotPoints"/>--><!--debug -->
+                        </distance2>
+                    </xsl:for-each>
+                </EconomicDistanceCut2>
+            </xsl:variable>
+            
+            <xsl:copy-of select="$EconomicDistanceCut"/>
+            
+            
+            <xsl:variable name="EconomicDistanceCut2">
+                <EconomicDistanceCut2><xsl:attribute name="debug" select="'bez pustych punktow tylko grupowanie'"/>
+                    <xsl:for-each select="$EconomicDistanceCut2/EconomicDistanceCut2/distance2[number(@point_count) &gt; 0 ]">
+                        <distance2>
+                            <xsl:copy-of select="@*"/>
                             <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:when test=" position()  mod $max_combinate_groups_elements = 0">  <!--- minus puste sum($EconomicDistanceCut/EconomicDistanceCut/distance[ number(@pos) &lt; number(current()/@pos) ]/number(@NotPoints)) ) --><!-- 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>
@@ -161,19 +179,31 @@
                 </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))"/>
+                            <xsl:copy-of select="@*"/>
                         </distance2>
                     </xsl:for-each>
                 </EconomicDistanceCut2>
             </xsl:variable>
-            <xsl:copy-of select="$EconomicDistanceCut2"/>
+            
+            <!-- debug -->
+            <!--<EconomicDistanceCut2><xsl:attribute name="debug" select="'#183 just show PosCut3GrId data'"/>
+                <xsl:for-each select="$EconomicDistanceCut2/EconomicDistanceCut2/distance2">
+                    <distance2>
+                        <xsl:attribute name="fl" select="@PosCut3Flag"/>
+                        <xsl:copy-of select="@PosCut3GrId"/>
+                        <xsl:copy-of select="@CurSumNotPoints"/>
+                        <xsl:copy-of select="@NotPoints"/>
+                        <!-\-<xsl:copy-of select="@pos"/>-\->
+                    </distance2>
+                </xsl:for-each>
+            </EconomicDistanceCut2>-->
+            <!--<xsl:copy-of select="$EconomicDistanceCut2"/>-->
             
             
             <xsl:variable name="elements_cnt" select="count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[@point_count &gt; 0])"/><!-- liczba wezlow potencjalnych licbza PE-->
@@ -181,18 +211,15 @@
             
             
             
-            <!-- pogrupujemy elementy co 50 metrow -->
+            <!-- pogrupujemy elementy co 50 metrow lub grupy ilosciowe -->
             <xsl:variable name="PointMatrixGroup">
                 <PointMatrixGroup>
                     <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="elements_cnt_Pos" select="count(current-group()[@point_count &gt; 0])"/> 
                             <xsl:variable name="countGr" select="count(current-group())"/>
                             <xsl:variable name="bit_max_Pos" select="round(sum( current-group()/@disttopkt )  div  ( $PE_Price div 20 ) )"/>
-                            <xsl:message>Nowa grupa Ways:<xsl:value-of select="@PosCut3GrId"/>; distanceGr=<xsl:value-of select="@PosCut3GrId"/>;elements_cnt_Pos=<xsl:value-of select="$elements_cnt_Pos"/>
-                                @bit_max_Pos=<xsl:value-of select="$bit_max_Pos"/>; @id_path=<xsl:value-of select="@id_path"/>; 
-                                countGr=<xsl:value-of select="$countGr"/>; point_count_Pos=<xsl:value-of select="sum(current-group()/@point_count)"/>; len_sum=<xsl:value-of select="sum(current-group()/@len)"/> ;
-                                distanceBeg/distanceEnd= <xsl:value-of select="min(current-group()/number(@distance))"/>/<xsl:value-of select="max(current-group()/number(@distance))"/>
+                            <xsl:message>Nowa grupa Ways:<xsl:value-of select="@PosCut3GrId"/>; distanceGr=<xsl:value-of select="@PosCut3GrId"/>;elements_cnt_Pos=<xsl:value-of select="$elements_cnt_Pos"/>;  @bit_max_Pos=<xsl:value-of select="$bit_max_Pos"/>; @id_path=<xsl:value-of select="@id_path"/>; countGr=<xsl:value-of select="$countGr"/>; point_count_Pos=<xsl:value-of select="sum(current-group()/@point_count)"/>; len_sum=<xsl:value-of select="sum(current-group()/@len)"/> ; distanceBeg/distanceEnd= <xsl:value-of select="min(current-group()/number(@distance))"/>/<xsl:value-of select="max(current-group()/number(@distance))"/>
                             </xsl:message>
                             <xsl:attribute name="distanceGr" select="@PosCut3GrId "/> <!-- bylo current-grouping-key() -->
                             <xsl:attribute name="elements_cnt_Pos" select="$elements_cnt_Pos"/>
@@ -236,9 +263,11 @@
                         <xsl:attribute name="point_count_Pos" select="@point_count_Pos"/>
                         <xsl:attribute name="distanceBeg" select="@distanceBeg"/>
                         <xsl:attribute name="distanceEnd" select="@distanceEnd"/>
+                        <xsl:message>#239: calc @distanceGr=<xsl:value-of select="$distanceGr"/>; @point_count_Pos=<xsl:value-of select="@point_count_Pos"/>;@LineStringCount ; @len_sum=<xsl:value-of select="@len_sum"/>; @distanceBeg=<xsl:value-of select="@distanceBeg"/>; @distanceEnd=<xsl:value-of select="@distanceEnd"/>;
+                        </xsl:message>
                 <!-- ida kandydaci -->
                         <xsl:variable name="candidates">
-                            <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: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()"/>
@@ -369,7 +398,7 @@
                 <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"/>
+                <xsl:copy-of select="$cand_to_calc"/>
             </variant>
         </xsl:if>
         <xsl:variable name="calc_cost_way">
@@ -404,8 +433,7 @@
                 </xsl:otherwise>
             </xsl:choose>
         </xsl:variable>
-        <xsl:copy-of select="$best"/>
-        
+        <xsl:if test="$debug"><xsl:copy-of select="$best"/></xsl:if>
         <xsl:choose>
             <xsl:when test="$bit = $max_bit">
                 <koniec_wariantow>