Anylogic moving average of processing times












1















in my model I have 9 different service blocks and each service can produce 9 different features. Each combination has a different delay time and standard deviation. For example feature 3 need 5 minutes in service block 8 with a deviation of 0.05, but only needs 3 minutes with a deviation of 0.1 in service block 4.



How can I permanently track the last 5 needed times of each combination and calculate the average (like a moving average)? I want to use the average to let the products decide which service block to choose for the respective feature according to the shortes time comparing the past times of all of the machines for the respective feature. The product agents already have a parameter for the time entering the service and one calculating the processing time by subtracting the entering time from the time leaving the service block.



Thank you for your support!










share|improve this question



























    1















    in my model I have 9 different service blocks and each service can produce 9 different features. Each combination has a different delay time and standard deviation. For example feature 3 need 5 minutes in service block 8 with a deviation of 0.05, but only needs 3 minutes with a deviation of 0.1 in service block 4.



    How can I permanently track the last 5 needed times of each combination and calculate the average (like a moving average)? I want to use the average to let the products decide which service block to choose for the respective feature according to the shortes time comparing the past times of all of the machines for the respective feature. The product agents already have a parameter for the time entering the service and one calculating the processing time by subtracting the entering time from the time leaving the service block.



    Thank you for your support!










    share|improve this question

























      1












      1








      1








      in my model I have 9 different service blocks and each service can produce 9 different features. Each combination has a different delay time and standard deviation. For example feature 3 need 5 minutes in service block 8 with a deviation of 0.05, but only needs 3 minutes with a deviation of 0.1 in service block 4.



      How can I permanently track the last 5 needed times of each combination and calculate the average (like a moving average)? I want to use the average to let the products decide which service block to choose for the respective feature according to the shortes time comparing the past times of all of the machines for the respective feature. The product agents already have a parameter for the time entering the service and one calculating the processing time by subtracting the entering time from the time leaving the service block.



      Thank you for your support!










      share|improve this question














      in my model I have 9 different service blocks and each service can produce 9 different features. Each combination has a different delay time and standard deviation. For example feature 3 need 5 minutes in service block 8 with a deviation of 0.05, but only needs 3 minutes with a deviation of 0.1 in service block 4.



      How can I permanently track the last 5 needed times of each combination and calculate the average (like a moving average)? I want to use the average to let the products decide which service block to choose for the respective feature according to the shortes time comparing the past times of all of the machines for the respective feature. The product agents already have a parameter for the time entering the service and one calculating the processing time by subtracting the entering time from the time leaving the service block.



      Thank you for your support!







      java simulation anylogic agent-based-modeling






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 '18 at 17:26









      MarieMarie

      152




      152
























          1 Answer
          1






          active

          oldest

          votes


















          1














          I am not sure if I understand what you are asking, but this may be an answer:



          to track the last 5 needed times you can use a dataset from the analysis palette, limiting the number of samples to 5...



          dataset



          you will update the dataset using dataset.add(yourTimeVariable); so you can leave the vertical axis value of the dataset empty.



          I assume you would need 1 dataset per feature



          Then you can calculate your moving average doing:



          dataset.getYMean();


          If you need 81 datasets, then you can create a collection as an ArrayList with element type DataSet
          And on Main properties, in On Startup you can add the following code and it will have the same effect.



          for(int i=0;i<81;i++){
          collection.add(new DataSet( 5, new DataUpdater_xjal() {
          double _lastUpdateX = Double.NaN;
          @Override
          public void update( DataSet _d ) {
          if ( time() == _lastUpdateX ) { return; }
          _d.add( time(), 0 );
          _lastUpdateX = time();
          }
          @Override
          public double getDataXValue() {
          return time();
          }
          } )
          );
          }


          you will only need to remember what corresponds to what serviceblock and feature and then you can just do



          collection.get(4).getYMean();


          and to add a new value to the dataset:



          collection.get(2).add(yourTimeVariable);





          share|improve this answer


























          • That means I need in sum 9*9 = 81 datasets? I hoped I could avoid that..

            – Marie
            Nov 19 '18 at 18:25











          • Oh I thought you would only need 9, in that case the answer is quite different, I will write an answer for that

            – Felipe
            Nov 19 '18 at 18:33











          • I edited the question. This gives you a way of doing it, but in fact there is a better one using classes, in which case you can assign a feature and a serviceBlock too... I may do that later

            – Felipe
            Nov 19 '18 at 18:40











          • And how do I add a time to a dataset using the collection as ArrayList?

            – Marie
            Nov 19 '18 at 18:43











          • i added that in my last edit

            – Felipe
            Nov 19 '18 at 18:43











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53379796%2fanylogic-moving-average-of-processing-times%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          I am not sure if I understand what you are asking, but this may be an answer:



          to track the last 5 needed times you can use a dataset from the analysis palette, limiting the number of samples to 5...



          dataset



          you will update the dataset using dataset.add(yourTimeVariable); so you can leave the vertical axis value of the dataset empty.



          I assume you would need 1 dataset per feature



          Then you can calculate your moving average doing:



          dataset.getYMean();


          If you need 81 datasets, then you can create a collection as an ArrayList with element type DataSet
          And on Main properties, in On Startup you can add the following code and it will have the same effect.



          for(int i=0;i<81;i++){
          collection.add(new DataSet( 5, new DataUpdater_xjal() {
          double _lastUpdateX = Double.NaN;
          @Override
          public void update( DataSet _d ) {
          if ( time() == _lastUpdateX ) { return; }
          _d.add( time(), 0 );
          _lastUpdateX = time();
          }
          @Override
          public double getDataXValue() {
          return time();
          }
          } )
          );
          }


          you will only need to remember what corresponds to what serviceblock and feature and then you can just do



          collection.get(4).getYMean();


          and to add a new value to the dataset:



          collection.get(2).add(yourTimeVariable);





          share|improve this answer


























          • That means I need in sum 9*9 = 81 datasets? I hoped I could avoid that..

            – Marie
            Nov 19 '18 at 18:25











          • Oh I thought you would only need 9, in that case the answer is quite different, I will write an answer for that

            – Felipe
            Nov 19 '18 at 18:33











          • I edited the question. This gives you a way of doing it, but in fact there is a better one using classes, in which case you can assign a feature and a serviceBlock too... I may do that later

            – Felipe
            Nov 19 '18 at 18:40











          • And how do I add a time to a dataset using the collection as ArrayList?

            – Marie
            Nov 19 '18 at 18:43











          • i added that in my last edit

            – Felipe
            Nov 19 '18 at 18:43
















          1














          I am not sure if I understand what you are asking, but this may be an answer:



          to track the last 5 needed times you can use a dataset from the analysis palette, limiting the number of samples to 5...



          dataset



          you will update the dataset using dataset.add(yourTimeVariable); so you can leave the vertical axis value of the dataset empty.



          I assume you would need 1 dataset per feature



          Then you can calculate your moving average doing:



          dataset.getYMean();


          If you need 81 datasets, then you can create a collection as an ArrayList with element type DataSet
          And on Main properties, in On Startup you can add the following code and it will have the same effect.



          for(int i=0;i<81;i++){
          collection.add(new DataSet( 5, new DataUpdater_xjal() {
          double _lastUpdateX = Double.NaN;
          @Override
          public void update( DataSet _d ) {
          if ( time() == _lastUpdateX ) { return; }
          _d.add( time(), 0 );
          _lastUpdateX = time();
          }
          @Override
          public double getDataXValue() {
          return time();
          }
          } )
          );
          }


          you will only need to remember what corresponds to what serviceblock and feature and then you can just do



          collection.get(4).getYMean();


          and to add a new value to the dataset:



          collection.get(2).add(yourTimeVariable);





          share|improve this answer


























          • That means I need in sum 9*9 = 81 datasets? I hoped I could avoid that..

            – Marie
            Nov 19 '18 at 18:25











          • Oh I thought you would only need 9, in that case the answer is quite different, I will write an answer for that

            – Felipe
            Nov 19 '18 at 18:33











          • I edited the question. This gives you a way of doing it, but in fact there is a better one using classes, in which case you can assign a feature and a serviceBlock too... I may do that later

            – Felipe
            Nov 19 '18 at 18:40











          • And how do I add a time to a dataset using the collection as ArrayList?

            – Marie
            Nov 19 '18 at 18:43











          • i added that in my last edit

            – Felipe
            Nov 19 '18 at 18:43














          1












          1








          1







          I am not sure if I understand what you are asking, but this may be an answer:



          to track the last 5 needed times you can use a dataset from the analysis palette, limiting the number of samples to 5...



          dataset



          you will update the dataset using dataset.add(yourTimeVariable); so you can leave the vertical axis value of the dataset empty.



          I assume you would need 1 dataset per feature



          Then you can calculate your moving average doing:



          dataset.getYMean();


          If you need 81 datasets, then you can create a collection as an ArrayList with element type DataSet
          And on Main properties, in On Startup you can add the following code and it will have the same effect.



          for(int i=0;i<81;i++){
          collection.add(new DataSet( 5, new DataUpdater_xjal() {
          double _lastUpdateX = Double.NaN;
          @Override
          public void update( DataSet _d ) {
          if ( time() == _lastUpdateX ) { return; }
          _d.add( time(), 0 );
          _lastUpdateX = time();
          }
          @Override
          public double getDataXValue() {
          return time();
          }
          } )
          );
          }


          you will only need to remember what corresponds to what serviceblock and feature and then you can just do



          collection.get(4).getYMean();


          and to add a new value to the dataset:



          collection.get(2).add(yourTimeVariable);





          share|improve this answer















          I am not sure if I understand what you are asking, but this may be an answer:



          to track the last 5 needed times you can use a dataset from the analysis palette, limiting the number of samples to 5...



          dataset



          you will update the dataset using dataset.add(yourTimeVariable); so you can leave the vertical axis value of the dataset empty.



          I assume you would need 1 dataset per feature



          Then you can calculate your moving average doing:



          dataset.getYMean();


          If you need 81 datasets, then you can create a collection as an ArrayList with element type DataSet
          And on Main properties, in On Startup you can add the following code and it will have the same effect.



          for(int i=0;i<81;i++){
          collection.add(new DataSet( 5, new DataUpdater_xjal() {
          double _lastUpdateX = Double.NaN;
          @Override
          public void update( DataSet _d ) {
          if ( time() == _lastUpdateX ) { return; }
          _d.add( time(), 0 );
          _lastUpdateX = time();
          }
          @Override
          public double getDataXValue() {
          return time();
          }
          } )
          );
          }


          you will only need to remember what corresponds to what serviceblock and feature and then you can just do



          collection.get(4).getYMean();


          and to add a new value to the dataset:



          collection.get(2).add(yourTimeVariable);






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 19 '18 at 18:36

























          answered Nov 19 '18 at 18:23









          FelipeFelipe

          1,9102721




          1,9102721













          • That means I need in sum 9*9 = 81 datasets? I hoped I could avoid that..

            – Marie
            Nov 19 '18 at 18:25











          • Oh I thought you would only need 9, in that case the answer is quite different, I will write an answer for that

            – Felipe
            Nov 19 '18 at 18:33











          • I edited the question. This gives you a way of doing it, but in fact there is a better one using classes, in which case you can assign a feature and a serviceBlock too... I may do that later

            – Felipe
            Nov 19 '18 at 18:40











          • And how do I add a time to a dataset using the collection as ArrayList?

            – Marie
            Nov 19 '18 at 18:43











          • i added that in my last edit

            – Felipe
            Nov 19 '18 at 18:43



















          • That means I need in sum 9*9 = 81 datasets? I hoped I could avoid that..

            – Marie
            Nov 19 '18 at 18:25











          • Oh I thought you would only need 9, in that case the answer is quite different, I will write an answer for that

            – Felipe
            Nov 19 '18 at 18:33











          • I edited the question. This gives you a way of doing it, but in fact there is a better one using classes, in which case you can assign a feature and a serviceBlock too... I may do that later

            – Felipe
            Nov 19 '18 at 18:40











          • And how do I add a time to a dataset using the collection as ArrayList?

            – Marie
            Nov 19 '18 at 18:43











          • i added that in my last edit

            – Felipe
            Nov 19 '18 at 18:43

















          That means I need in sum 9*9 = 81 datasets? I hoped I could avoid that..

          – Marie
          Nov 19 '18 at 18:25





          That means I need in sum 9*9 = 81 datasets? I hoped I could avoid that..

          – Marie
          Nov 19 '18 at 18:25













          Oh I thought you would only need 9, in that case the answer is quite different, I will write an answer for that

          – Felipe
          Nov 19 '18 at 18:33





          Oh I thought you would only need 9, in that case the answer is quite different, I will write an answer for that

          – Felipe
          Nov 19 '18 at 18:33













          I edited the question. This gives you a way of doing it, but in fact there is a better one using classes, in which case you can assign a feature and a serviceBlock too... I may do that later

          – Felipe
          Nov 19 '18 at 18:40





          I edited the question. This gives you a way of doing it, but in fact there is a better one using classes, in which case you can assign a feature and a serviceBlock too... I may do that later

          – Felipe
          Nov 19 '18 at 18:40













          And how do I add a time to a dataset using the collection as ArrayList?

          – Marie
          Nov 19 '18 at 18:43





          And how do I add a time to a dataset using the collection as ArrayList?

          – Marie
          Nov 19 '18 at 18:43













          i added that in my last edit

          – Felipe
          Nov 19 '18 at 18:43





          i added that in my last edit

          – Felipe
          Nov 19 '18 at 18:43


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53379796%2fanylogic-moving-average-of-processing-times%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to change which sound is reproduced for terminal bell?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

          Can I use Tabulator js library in my java Spring + Thymeleaf project?