org.cpsolver.ifs.example.jobshop

## Class JobShopModel

- java.lang.Object
- - org.cpsolver.ifs.model.Model<Operation,Location>
  - - org.cpsolver.ifs.example.jobshop.JobShopModel

-     public class JobShopModel
      extends Model<Operation,Location>

  Job Shop model.
  It contains the number of available time slots and all machines and jobs.
  It can also load the model from a file and save the solution.
  Input file format: First line:

      <number of jobs> <number of machines>

  Following lines:

       space separated list (a line for each job) of operations, each operation
       consist of machine number and operation processing time

  Example of 10 jobs, 10 machines:

       10 10
       4 88 8 68 6 94 5 99 1 67 2 89 9 77 7 99 0 86 3 92
       5 72 3 50 6 69 4 75 2 94 8 66 0 92 1 82 7 94 9 63
       9 83 8 61 0 83 1 65 6 64 5 85 7 78 4 85 2 55 3 77
       7 94 2 68 1 61 4 99 3 54 6 75 5 66 0 76 9 63 8 67
       3 69 4 88 9 82 8 95 0 99 2 67 6 95 5 68 7 67 1 86
       1 99 4 81 5 64 6 66 8 80 2 80 7 69 9 62 3 79 0 88
       7 50 1 86 4 97 3 96 0 95 8 97 2 66 5 99 6 52 9 71
       4 98 6 73 3 82 2 51 1 71 5 94 7 85 0 62 8 95 9 79
       0 94 6 71 3 81 7 85 1 66 2 90 4 76 5 58 8 93 9 97
       3 50 0 59 1 82 8 67 7 56 9 96 6 58 4 81 5 59 2 96

  For instance, the first job is described as follows:

       88 time units on machine 4, then 68 time units on machine 8, then 94 time
       units on machine 6 ...

  Output file firmat:

       A line for each machine, in each line there is a space separated list of jobs
       which the machine will process in the order they will be processed.

  Version:
    IFS 1.3 (Iterative Forward Search)
    Copyright (C) 2006 - 2014 Tomáš Müller
    muller@unitime.org
    http://muller.unitime.org
    This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
    This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    You should have received a copy of the GNU Lesser General Public License along with this library; if not see http://www.gnu.org/licenses/.
  Author:
    Tomáš Müller

- - ### Field Summary

    - ### Fields inherited from class org.cpsolver.ifs.model.Model

      `sDoubleFormat, sPercentageFormat, sTimeFormat`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JobShopModel(int nrMachines, int nrJobs)` Constructor �

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `countJobs()` Count number of jobs in the model
    `int` | `countMachines()` Count number of machines in the model
    `int` | `getFinishingTime(Assignment<Operation,Location> assignment)` Get finishing time of the current (partial) solution
    `Map<String,String>` | `getInfo(Assignment<Operation,Location> assignment)` Get information table
    `Job` | `getJob(int jobNumber)` Get job of the given number
    `Machine` | `getMachine(int machineNumber)` Get machine of the given number
    `int` | `getTotalNumberOfSlots()` Get total number of slots
    `static JobShopModel` | `loadModel(String file)` Loads the model from the given file
    `void` | `save(Assignment<Operation,Location> assignment, String file)` Save the solution into the given file

    - ### Methods inherited from class org.cpsolver.ifs.model.Model

      `addConstraint, addCriterion, addGlobalConstraint, addModelListener, addVariable, afterAssigned, afterAssigned, afterUnassigned, afterUnassigned, assignedVariables, assignedVariables, beforeAssigned, beforeAssigned, beforeUnassigned, beforeUnassigned, bestUnassignedVariables, bestUnassignedVariables, clearAssignmentContexts, clearBest, conflictConstraints, conflictValues, conflictValues, constraints, countConstraints, countGlobalConstraints, countVariables, createAssignmentContexts, createInheritedAssignment, createReference, getBestPerturbations, getBestUnassignedVariables, getBestValue, getCriteria, getCriterion, getDefaultAssignment, getEmptyAssignment, getExtendedInfo, getExtendedInfo, getInfo, getInfo, getInfo, getInfoProviders, getModelListeners, getPerc, getPercRev, getTotalValue, getTotalValue, getTotalValue, getTotalValue, globalConstraints, inConflict, inConflict, init, invalidateVariablesWithInitialValueCache, modelListenerOfType, nrAssignedVariables, nrAssignedVariables, nrUnassignedVariables, nrUnassignedVariables, perturbVariables, perturbVariables, perturbVariables, perturbVariables, perturbVariables, removeConstraint, removeCriterion, removeCriterion, removeGlobalConstraint, removeModelListener, removeReference, removeVariable, restoreBest, restoreBest, restoreBest, saveBest, saveBest, setBestValue, setDefaultAssignment, toString, toString, unassignedHardConstraints, unassignedVariables, unassignedVariables, variables, variablesWithInitialValue, weaken`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### JobShopModel

          public JobShopModel(int nrMachines,
                              int nrJobs)

      Constructor �
      Parameters:
        `nrMachines` - number of machines
        `nrJobs` - number of jobs

  - ### Method Detail

    - #### getTotalNumberOfSlots

          public int getTotalNumberOfSlots()

      Get total number of slots
      Returns:
        total number of slots

    - #### getMachine

          public Machine getMachine(int machineNumber)

      Get machine of the given number
      Parameters:
        `machineNumber` - machine number
      Returns:
        machine of the given number

    - #### countMachines

          public int countMachines()

      Count number of machines in the model
      Returns:
        number of machines in the model

    - #### getJob

          public Job getJob(int jobNumber)

      Get job of the given number
      Parameters:
        `jobNumber` - job number
      Returns:
        job of the given number

    - #### countJobs

          public int countJobs()

      Count number of jobs in the model
      Returns:
        number of jobs in the model

    - #### loadModel

          public static JobShopModel loadModel(String file)
                                        throws IOException

      Loads the model from the given file
      Parameters:
        `file` - file to load
      Returns:
        loaded model
      Throws:
        `IOException` - thrown when there is a problem reading the input file

    - #### getFinishingTime

          public int getFinishingTime(Assignment<Operation,Location> assignment)

      Get finishing time of the current (partial) solution
      Parameters:
        `assignment` - current assignment
      Returns:
        finishing time of the current (partial) solution

    - #### getInfo

          public Map<String,String> getInfo(Assignment<Operation,Location> assignment)

      Get information table
      Overrides:
        `getInfo` in class `Model<Operation,Location>`
      Parameters:
        `assignment` - current assignment
      Returns:
        info table

    - #### save

          public void save(Assignment<Operation,Location> assignment,
                           String file)
                    throws IOException

      Save the solution into the given file
      Parameters:
        `assignment` - current assignment
        `file` - file to write
      Throws:
        `IOException` - throw when there is a problem writing the file