title: Schedule optimization
body: <p>I'm trying to solve linear programming problem about scheduling. Each task has starting time r, time to solve task p and weight w. I have to minimize following function (C is ending time of task):</p>
  
  <p><a href="https://i.stack.imgur.com/2FbUr.png" rel="nofollow noreferrer">function to minimize</a></p>
  
  <p>With data provided below Result (C-array) are:</p>
  
  <p>-----RESULT-----</p>
  
  <pre><code>12.0 - C[1]  
  15.0 - C[2]   
  16.0 - C[3]   
  29.0 - C[4] 
  </code></pre>
  
  <p>Which are correct when we take tasks one by one. How can I check all possible permutation and choose best one? In my case the last task should be taken first.</p>
  
  <pre><code> function findTimetable(timeForTask :: Array{Int}, weightForTask :: Array{Int}, momentForTask:: Array{Int} )
          model :: Model = Model(with_optimizer(GLPK.Optimizer))
          _size = size(timeForTask)[1]
          @variable(model, C[1: _size] &gt;= 0, Int)
  
          @objective(model, Min, sum(weightForTask[i] * C[i] for i = 1 : _size))
  
          for i = 1 : _size
               @constraint(model, C[i] &gt;= momentForTask[i] + timeForTask[i])
          end
          for i = 1 : _size - 1
              @constraint(model, C[i+1] &gt;= C[i]  + timeForTask[i+1] )
          end
  
          println(model)
          optimize!(model)
          println(primal_status(model))
          println(objective_value(model))
          println("-----RESULT-----")
          for i in 1:_size
              println(value(C[i]))
          end
      end
  
  
    timeForTask = [2, 3, 1, 13] #p
    weightForTask  = [1, 1, 10, 2000] #w
    momentForTask  = [10, 9, 8, 1] #r
  
    findTimetable(timeForTask, weightForTask, momentForTask)
  </code></pre>
  
  <p>Thanks in advance.</p>