1
  • 申し訳ありませんが、私は Netlogo プログラミングの初心者であり、優先順位に基づいてマシンでジョブをスケジュールしようとしています。
  • 現時点では、product1 タートルのみが 1 つのマシン タートルで処理されます。他の製品のタートルは、マシン 2 やマシン 3 などのアイドル状態のマシンでは実行されていません。現在、彼らは次のループを処理するために他のループが終了するのを待っています。
  • 私が達成したいのは、Product1 が操作のために Machine1 のみを必要とすることです。P2 には M2 と M3 が必要ですが、P3 には M1、M2 と M3 が必要です。したがって、Product1 タートルが M1 にある場合、他のタートルは対応するターゲットに移動し、自分自身をスケジュールする必要があります

      breed [product1 productA]
        breed [product3 productB]
        breed [product2 productC]
        breed [machine1 machineA]
        breed [machine2 machineB]
        breed [machine3 machineC]
        breed [schedulers scheduler]
    
        globals [Priority]
    
    
    
        product1-own
    
        [
    
         productID
        productLength
        arriveTime
        startTime
         finishTime
    
    
         ]
    
         product2-own
    
         [
    
        productID
        productLength
        arriveTime
         startTime
        finishTime
        waitTime
    
    
        ]
    
        product3-own
    
        [
    
        productID
        productLength
        arriveTime
        startTime
        finishTime
    
         ]
    
    
          schedulers-own 
    
          [
    
          numJobArrive
          numJobStart
          numJobFinish
          numJobWait
          currentmachineID
    
          ]
    
    
          machine-own 
    
         [
    
         machineID
         numJobStart
         numJobFinish
         waitTimeM
         idleTimeM
         nextAvailTime
           currentproductID
         utilization
    
    ]
    
    
    
    to setup 
      clear-all
    
      ask patches [set pcolor 8]
      ask patch -3 6 [set pcolor 125]  
    
      ask patch -3 2 [set pcolor 125]
      ask patch 1 4 [set pcolor black]
       setup-products1
       setup-products2
       setup-products3
       setup-machines
    
       reset-ticks
    
    end
    
    to setup-machines
    
      create-machine1 1 [setxy -3 6
      set shape "computer server"]
      create-machine2  1[setxy -3 2
      set shape "computer server"]
      create-machine3  1[setxy 1 4
      set shape "computer server"]
    
    end
    
    to setup-products1
    
       create-product1 Job1-products [
        set shape "hexagonal prism"
        set color red
        set size 1.25
        set xcor -14
        set ycor 6
        set heading  90
        separate-products
      ]
    
    end
    
    
    
    to setup-products2
    
      create-product2 Job2-products [
        set shape "die 4"
        set color blue
        set xcor -14
        set ycor 4
        set size 1.25
        set heading  90
        separate-products
      ]
    
    end
    
    to setup-products3
    
      create-product3 Job3-products [
        set shape "box"
        set color brown
        set size 1.25
        set xcor -14
        set ycor 2
        set heading  90
        separate-products
      ]
    
    end
    
    
    
    
    ; this procedure is needed so when we click "Setup" we
    ; don't end up with any two Products on the same patch
    to separate-products  ;; turtle procedure
      if any? other turtles-here
        [ fd 1.5
          separate-products ]
    end
    
    to go-product3  
    let totalprod (turtle-set product1 product2 product3)
    
      let targetmachine1 patch -3 6
       let targetmachine2 patch -3 2
       let targetmachine3 patch 1 4
    
       if count product3 > 0
       [
    ask one-of product3 [
        if not any? product1-on machine1 or not any? product2-on machine1 
    
           [
            move-to targetmachine1
    
           ]
       if not any? product1-on machine2 or not any? product2-on machine2 
    
           [
            face targetmachine2     
             move-to targetmachine2
           ]
    
           if not any? product1-on machine3 or not any? product2-on machine3 
    
           [
            face targetmachine3 
            move-to targetmachine3
            die
    ] 
    
    
      ]]
       tick
    end
    
    
    to go-product2
    
        let targetmachine1 patch -3 2
       let targetmachine2 patch 1 4
       if count product2 > 0
       [
    ask one-of product2 [
        if not any? product1-on machine2 or not any? product3-on machine2 
    
           [
    
            face targetmachine1      
             move-to targetmachine1
           ]
    
           if not any? product1-on machine3 or not any? product3-on machine3 
    
           [
    
            face targetmachine2 
            move-to targetmachine2
            die
    ] 
    
     ]]
       tick
    
    end
    
    to go-product1
    
    
       let targetmachine patch 1 4
       if count product1 > 0
       [
    
    ask one-of product1
     [
          if not any? product2-on machine3 or not any? product3-on machine3 
    
           [    
            face targetmachine 
            move-to targetmachine
            die
    ] 
      ]]
       tick
    end
    
    
    to go
    
     let totalprod (turtle-set product1 product2 product3)
    
       while [count totalprod > 0] [
      if Priority = "0" [
    go-product1
    go-product2   
    go-product3
       ]
      if Priority = "1" [
        while [count product1 > 0][
    go-product1 ]
    go-product2   
    go-product3
       ]
      if Priority = "2" [
        while [count product2 > 0][
    go-product2 ]
    go-product1   
    go-product3
       ]
      if Priority = "3" [
        while [count product3 > 0][
    go-product3 ]
    go-product1   
    go-product2
       ]
      ]
    
    tick
    end
    
4

1 に答える 1