title: Penalty_ Capacitated vehicle routing problem with multiple time windows
body: <p>Brief introduction:</p>
  <p>LKH-3 is an implementation of the Lin-Kernighan traveling salesman heuristic.
  The goal is to build an LKH-3 version able to solve the following problem type:</p>
  <p>CVRPMTW: Capacitated vehicle routing problem with multiple time windows</p>
  <h2>Check: comment that says &quot;how to add waiting time&quot;</h2>
  <p><em>What I need to do:</em></p>
  <p><em>Output <strong>waiting time</strong> (Earliest) and in which node we are facing waiting time</em></p>
  <hr />
  <p>Sample for clear understanding:</p>
  <p>|--------|____________________|--------|</p>
  <p><strong>Waiting</strong>  |    Time window node N   |   Penalty</p>
  <pre><code>GainType Penalty_CVRPMTW()
  {
      static Node *StartRoute = 0;
      Node *N, *NextN, *CurrentRoute;
      GainType CostSum, DemandSum, P = 0;
      int Forward = SUCC(Depot)-&gt;Id != Depot-&gt;Id + DimensionSaved;
      int j;
      int RouteCounter = 0;
  
      if (!StartRoute)
          StartRoute = Depot;
      if (StartRoute-&gt;Id &gt; DimensionSaved)
          StartRoute -= DimensionSaved;
      N = StartRoute;
      do {
          CurrentRoute = N;
          CostSum = DemandSum = 0;
          do {
              if (N-&gt;Id &lt;= Dim &amp;&amp; N != Depot) {
                  if ((DemandSum += N-&gt;Demand) &gt; Capacity)
                          P += DemandSum - Capacity;
  
                  if (MultipleTimeWindowPenaltyMode == PENALTY_ON_EARLIEST || MultipleTimeWindowPenaltyMode == NO) {
                      // Loop over the earliest values of the node's time windows and find the appropriate time window
                      if (CostSum &gt; N-&gt;Latest)
                          P += CostSum - N-&gt;Latest;
                      else {
                          for (j = 0; j &lt; N-&gt;NumberTimeWindows; j++){
                              if (CostSum &lt; N-&gt;EarliestList[j]){
                                  if (MultipleTimeWindowPenaltyMode == NO) {
                                      *CostSum = N-&gt;EarliestList[j]*; //how can i add the waiting time in this line?
                                  }
                                  else if (MultipleTimeWindowPenaltyMode == PENALTY_ON_EARLIEST) {
                                      // CostSum = N-&gt;EarliestList[j]; /* Enable this to also add the waiting time to the cost */
                                      P += N-&gt;EarliestList[j] - CostSum;
                                  }
                                  break;
                              } else if (CostSum &gt;= N-&gt;EarliestList[j] &amp;&amp; CostSum &lt;= N-&gt;LatestList[j]){
                                  break;
                              }
                          }
                      }  
                  }
  
  
  </code></pre>