title: How to reorganize this data?
body: <p>I have the following input:</p>
  <ul>
  <li><p>A horizon: number of periods</p>
  </li>
  <li><p>A set of <em>resources</em>, each resource has an <em>id</em> and an <em>availability</em> encoded using an array. (e.g [3, 4,..] means 3 units of the resource during the first period, 4 during the second period etc.) The number of elements of the array is equal to the number of periods (i.e the horizon)</p>
  </li>
  <li><p>A set of <em>comms</em>, each order has a <em>release date</em>, <em>due date</em> and a set of <em>tasks</em>.
  The tasks of an order cannot start before the release date of that order and cannot end after its due date. (My algorithm will fix the starting time of tasks, it's not an input data but accessing the release dates and due dates is important in order to correctly determine the starting time of tasks)</p>
  </li>
  <li><p>Each task has a <em>duration</em>, <em>successors</em>(i.e a set of tasks that cannot start before the task on hand), <em>resource requirements</em> (e.g [0,1,3,...] means the task needs 0 units of the first resource, 1 unit of the second resource etc).</p>
  </li>
  </ul>
  <p>Here's how I organized the code:</p>
  <pre><code>class Problem:
      def __init__(self, horizon, comms, resources):
          self.horizon = horizon
          self.resources = resources 
          self.comms = comms 
  </code></pre>
  <pre><code>    class Resource:
          def __init__(self, identifier, inter):
              self.id = identifier
              self.inter = availabilities
  </code></pre>
  <pre><code>class Comm:
      def __init__(self, id:str, r_date, d_date, ta):
          self.id = id
          self.r_date = r_date
          self.d_date = d_date
          self.ta = ta
  </code></pre>
  <pre><code>class Task:
      def __init__(self, id:str, dur, succ, requ):
          self.id = id
          self.dur = dur
          self.succ = succ
          self.requ = requ
  </code></pre>
  <p>A lot of problems appears using this way of organizing data (e.g. if I need to access data about a task, I need to go through comms to determine to which order it belongs and then accessing the due date, release date for that order). The data is very &quot;nested&quot;.</p>
  <p>I thought of defining the <code>Task</code> object as following but there is a redundancy (information present in both <code>Task</code> and <code>Order</code>).</p>
  <pre><code>class Task:
      def __init__(self, id:str, dur, succ, requ, 
                   order_id:str, r_date, d_date):
          self.id = id
          self.dur = dur
          self.succs = succ
          self.requ = requ
          self.order_id = order_id
          self.r_date = r_date
          self.d_date = d_date
  </code></pre>
  <p>Some other questions:</p>
  <p>For the <code>successors</code> is it better to just put the ids of the tasks or the entire objects?</p>
  <p>For the resource <code>requirements</code>. Assume a task has a requirement [0,1,3,...] of 1 units of the second resource, then I need in someway relate to the appropriate resource id in order to check its availability. How to do it?</p>