code: def solve_segment_time(n,c,t,segments):
      
  
      model = base_model(n,c,t)   # base model for minimizing cost or time
      x,u,C,T = model.data
  
      # store the set of solutions for plotting
      cand = []
      # print("optimizing time"
      model.setObjective(T, "minimize")
      stat1 = optimize(model,cand)
  
      # print("optimizing cost"
      model.setObjective(C, "minimize")
      stat2 = optimize(model,cand)
  
      if stat1 != "optimal" or stat2 != "optimal":
          return []
  
      times = [ti for (ti,ci) in cand]
      max_time = max(times)
      min_time = min(times)
      delta = (max_time-min_time)/segments
      # print("making time range from",min_time,"to",max_time
  
      # add a time upper bound constraint, moving between min and max values
      TimeCons = model.addCons(T <= max_time, "TimeCons")
  
      for i in range(segments+1):
          time_ub = max_time - delta*i
          model.chgRhs(TimeCons, time_ub)
          # print("optimizing cost subject to time <=",time_ub
          optimize(model,cand)
  
      return cand
docs: solve_segment: segmentation for finding set of solutions for two-objective TSP
      Parameters:
          - n: number of cities
          - c,t: alternative edge weights, to compute two objective functions
          - segments: number of segments for finding various non-dominated solutions
      Returns list of candidate solutions