102
Delft University of Technology FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING Department Marine and Transport Technology Mekelweg 2 2628 CD Delft the Netherlands Phone +31 (0)15-2782889 Fax +31 (0)15-2781397 www.mtt.tudelft.nl This report consists of 102 pages and 5 appendices. It may only be reproduced literally and as a whole. For commercial purposes only with written authorization of Delft University of Technology. Requests for consult are only taken into consideration under the condition that the applicant denies all legal rights on liabilities concerning the contents of the advice. Specialization: Production Engineering and Logistics Report number: 2011.PEL.7671 Title: Quantifying requirements during the design of the first automated container terminal Author: T.Smook Title (in Dutch) Het kwantificeren van de eisen voor het ontwerp van de eerste geautomatiseerde containerterminal Assignment: Simulation assignment Confidential: No Initiator (university): Dr.ir. H.P.M. Veeke Supervisor: Dr.ir. H.P.M. Veeke Date: June 01, 2011

FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

Delft University of Technology

FACULTY MECHANICAL, MARITIME AND

MATERIALS ENGINEERING Department Marine and Transport Technology

Mekelweg 2 2628 CD Delft

the Netherlands Phone +31 (0)15-2782889

Fax +31 (0)15-2781397 www.mtt.tudelft.nl

This report consists of 102 pages and 5 appendices. It may only be reproduced literally and as a whole. For

commercial purposes only with written authorization of Delft University of Technology. Requests for consult are only taken into consideration under the condition that the applicant denies all legal rights on liabilities concerning

the contents of the advice.

Specialization: Production Engineering and Logistics Report number: 2011.PEL.7671 Title: Quantifying requirements during

the design of the first automated container terminal

Author: T.Smook

Title (in Dutch) Het kwantificeren van de eisen voor het ontwerp van de eerste

geautomatiseerde containerterminal

Assignment: Simulation assignment

Confidential: No

Initiator (university): Dr.ir. H.P.M. Veeke

Supervisor: Dr.ir. H.P.M. Veeke

Date: June 01, 2011

Page 2: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

2

Contents

Preface 3

Summary 3

1 Introduction 4

1.1 The objective of this assignment ...................... 4

2 The Simulation 5

2.1 Brief description of the total system 5

2.2 Brief description of the simulated system 6

2.3 Objective of the simulation 6

2.4 Process model and process descriptions 7

2.5 Element classes 9

2.6 SET’s (queues) 9

2.7 Distributions 9

2.8 Assumptions 10

2.9 The variable parameters 11

2.10 Motivation of possibly confusing choices ......... 12

3 The simulation program 13

3.1 Requirements of the simulation program 13

3.2 Composition of the simulation program 14

3.3 Measures to ensure the user-friendliness and foolproofness 18

4 Model verification 23

4.1 Comparison with calculations and reasoning 23

4.2 Comparison with experiments in the book 25

4.3 Conclusion 27

References 27

Appendix A: the Process Description Language: PDL 28

Appendix B: user operations of the simulation program 32

Appendix C: hand calculation for verification simulation 36

Appendix D: the results of the experiments described in the book 38

Appendix E: The programming code 45

Page 3: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

3

Preface This report is part of my Simulation Assignment, which is a substitute of the Literature or

Research Assignment ME01PEL03 for my study program of the master Production

Engineering and Logistics at the faculty of Mechanical, Maritime and Materials Engineering

at the TU-Delft.

This Simulation Assignment is intended to provide a simulation application which can be

used for educational purposes, based on a case in the book: The Delft Systems Approach.

Because the process descriptions of the elements in the simulation were already described

in the book, the complexity of devising how the simulation should work was reduced.

Nevertheless I underestimated the complexity of building a user-friendly and foolproof

simulation program, although I deliberately challenged myself to include an elaborate

extension of the program, to help the user create a bat-file to run a batch of simulations on

the same program.

Furthermore I have chosen to write this report in English. For one part that is because the

book on which the simulation is based: The Delft Systems Approach, is in English and

consulted quite often for parts of this report. On the other hand I think it was good to

practice my English, because I am aware it has not such a high level.

Finally I would like to thank Dr.ir. H.P.M. Veeke for providing this assignment and guiding me

to the final result. I am convinced that by this assignment I learned several things that might

be useful for other simulations, for example during my MSc project.

Summary A simulation program has been built for the automated container terminal described in the

book: The Delft Systems Approach. In the simulation, on a global level in the design stage,

several parameters can be varied, in order to see their influence on the performance of the

terminal.

The simulation program is going to be used for educational purposes, in combination with

the case described in the book. Therefore additional requirements are that the program is

very user-friendly and 'studentproof' / foolproof.

This report describes how the simulation works, how the program is constructed and which

measures have been taken to ensure the user-friendliness and foolproofness of the

simulation program. Appendix E contains the programming code for the simulation program.

Furthermore the simulation of this simulation program has been verified by means of

comparisons with calculations, reasoning and the results from the experiments in the book.

Page 4: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

4

1 Introduction For this assignment, a simulation program is build. The simulation is based on the case

described in chapter eleven of the book: The Delft Systems Approach, from the authors

H.P.M. Veeke, J.A. Ottjes and G. Lodewijks. This case concerns the design of the first

automated container terminal, where an example of a TOMAS simulation is used to quantify

the requirements for the system. This simulation takes into account stochastic influences

and all the dependencies of the elements at the terminal.

1.1 The objective of this assignment The objective of this assignment is to make a simulation application for the automated

container terminal described in the book, where on a global level in the design stage several

parameters can be varied, in order to see their influence on the performance of the

terminal.

The simulation program is going to be used for educational purposes, in combination with

the case described in the book. The purpose of this is to demonstrate the students how a

simulation can be used in a design trajectory and possibly to let the students work with it

themselves. Therefore additional requirements are that the program is very user-friendly

and foolproof, so that it can be used by inexperienced people. The purpose of the

requirement to be user-friendly is that a user who is not very familiar with the simulation

program, is able to work with it and will not easily misinterpret a result. The purpose of the

requirement to be foolproof is that a user, either intentionally or unintentionally, cannot do

something that causes the simulation program to crash or give faulty results.

Since the simulation program will be used in combination with the book, it is assumed the

user is familiar with the content of the case. Due to this, the user should be able to recognize

and understand all items and parameters in the program, but it is unnecessary to explain

what they are and what they do.

The program for example does not explain what an ASC is and how it works, but does

explain that the ASC cycle times (including transfer times) are assumed to be uniformly

distributed, and shows the figure by which an ASC with a certain status is represented in the

animation.

The result of this assignment is the simulation application, accompanied by this report. The

quality of the simulation application will mainly be based on:

1. Whether the simulation is correct.

2. Whether the (simulation) program is user-friendly and foolproof.

Because of this distinction, this report also distinguishes the simulation itself and the

program around it.

Page 5: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

5

2 The Simulation The simulation is based on the case about the design of the first automated container

terminal, described in chapter eleven of the book: The Delft Systems Approach. To

understand what is being simulated, the simulated system is being described briefly, based

on the description in the book.

2.1 Brief description of the total system The container terminal is a system for container-handling. Containers arrive and leave the

terminal by means of rail, road or water and are exchanged at the terminal. The first

decisions in the design process prescribed the following combinations and resources at the

terminal:

• At the waterside, quay cranes (QC) will load and unload deep-sea ships and feeders.

• Automatic guided vehicles (AGV) will transport the containers between stacking area

and quay cranes.

• Automatic stacking cranes (ASC) will store and move containers in and out of the

stacking area.

• Straddle carriers (SC) will load and unload trucks and multi-trailer systems (MTS) at the

land-side of the terminal. Each MTS will transport up to five 40-foot containers between

a rail or barge terminal and the MSS terminal.

This is illustrated by figure 1:

feeder

AGV ASC

container storage

multi trailer system

truck

straddle carrier

quay crane

single container ‘waiting’

deep-sea ship

Figure 1: container movements at the container terminal

Page 6: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

6

2.2 Brief description of the simulated system In the case described in chapter eleven of the book, not the entire container terminal is

simulated, because that would be too elaborate. Therefore the simulation is restricted to the

import of containers from sea. According to the description, the landside operation is taken

into account up to the point at which a container is retrieved from the stack. This basically

means that the container is retrieved from the stack and placed at the point where it can be

picked up by a straddle carrier, since this is still part of the operations of the ASC.

As a result, the operations and resources at the terminal for the simulation can be described

as the following:

• At the waterside, quay cranes (QC) will unload deep-sea ships and feeders.

• Automatic guided vehicles (AGV) will transport the containers from the quay cranes to

the stacking area.

• Automatic stacking cranes (ASC) will store and move containers in and out of the

stacking area.

This is illustrated by figure 2:

2.3 Objective of the simulation As already mentioned before, the objective of the simulation is that on a global level in the

design, the influence of several parameters on the performance of the terminal can be

studied.

In the book for example, the simulation is used to define the maximum average cycle times

for the AGVs and the ASCs, and to investigate the strategy for AGVs to select quay cranes

and ASCs. In several experiments, the simulated performance of the terminal was therefore

compared to the desired minimum performance.

According to the case description in the book, the performance of the terminal is described

by the sea-side productivity (number of handled containers per net operational hour

(NOH)1).

1

NOH = Net Operational Hour. In this case it refers to the time a quay crane can actually operate (ship

with containers is available, all quay cranes are available).

System boundary

feeder

AGV ASC

container storage

multi trailer system

truck

straddle carrier

quay crane

single container ‘waiting’

deep-sea ship

Figure 2: container movements at the simulated part of the container terminal

Page 7: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

7

2.4 Process model and process descriptions A process model and process descriptions for the quay cranes, AGVs, ASCs and the

generation of land-side jobs are provided in the book. These depict the relations and

interactions between the different elements in the simulation, see figure 3 and the process

descriptions from the book:

Process for a Quay Crane

Repeat

Work “sample of QC’s cycle time”

Wait while no AGVs waiting

Select AGV

Load AGV in x seconds

Resume AGV’s process

Process for an AGV

Repeat

Select QC

Cycle = “sample of AGV’s cycle time”

Drive 0.5 × Cycle

Wait for QC

Select ASC

Drive 0.5 × Cycle

Wait for ASC

Process of an ASC

Repeat

Wait while no AGVs waiting and

no jobs on land-side

Cycle = “sample of ASC cycle time”

If AGVs waiting

Select AGV

Move to AGV in 0.5 × Cycle

Unload AGV in y seconds

Resume AGV’s process

Store container in 0.5 × Cycle

Else

Select land-side job

Work D seconds

Process of LandsideJobGenerator

Repeat

Wait(3600/90)

Select ASC

Create land-side job for ASC

Figure 3: process model of the import process of the container terminal (Delft Systems Approach, 2008)

Page 8: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

8

These process descriptions in the book describe the processes of the main elements in the

simulation. Besides these, there are some supporting processes:

• There is a process of a TimeManager, which basically controls the time of both the

simulation start-up and the simulation itself, and the actions related to it. This could be

integrated in the process of landside, but is kept separate to keep it clear.

• Then there is a process for the AnimationDrawer, which repaints every simulated

second. This could be a procedure called by another process, but is a process on its own,

to be able to easily draw a new picture every simulated second. Although repainting

every simulated second does not always give an exact representation of the status of the

simulation, it prevents repainting too often within a short period of simulated time2. For

the animation it is assumed this would not cause a problem.

• The procedure Initialization is a procedure to set all parameters, create all distributions,

queues and elements preceding the start of the simulation.

These processes can be described as follows. The more extended PDL is given in Appendix A.

Process for TimeManager

Set things for simulation start-up

Wait “simulation start-up time”

Set things for real simulation

Wait “simulation time”

Stop simulation

Set things for showing the results

Process for AnimationDrawer

Repeat

Repaint animation

Wait(1)

Initialization

Set all parameters of the simulation

Create all queues

Create all distributions

For all quay cranes

Create quay crane

Create quay crane’s queues

Place queue crane in queue

Start quay crane’s process

For all AGVs

Create AGV

Place AGV in queue

Start AGV’s process

For all ASCs

Create ASC

Create ASC’s queues

Place ASC in queue

Start ASC’s process

Create LandsideJobGenerator

Start LandsideJobGenerator’s process

Create TimeManager

Start TimeManager’s process

Create AnimationDrawer

Place AnimationDrawer in queue3

Start AnimationDrawer’s process

2 The animation does not always give an exact representation of the status of the simulation, for

example when a quay crane becomes idle at 1.1 seconds and busy again at 1.8 seconds, and the

AnimationDrawer repaints at 1.00 and 2.00 seconds, the user will never notify this quay crane being

idle. 3 Because the process of the AnimationDrawer can be turned on and off during the simulation, it

should be possible to call it during the simulation. One way to make that possible is to place it in a

queue.

Page 9: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

9

2.5 Element classes So far only the element classes with processes have been described, but also the land-side

job is an element class. A land-side job is in fact an order to a certain ASC, to get a container

from its stack and bring it to the point where it can be further operated by a straddle carrier.

An overview of the element classes:

• QuayCrane

• AGV

• ASC

• LandsideJob (no process)

• LandsideJobGenerator

• TimeManager

• AnimationDrawer

It might appear a little bit strange that a container itself is not an element class in this

simulation. That is because a container does not have to be, since it is always accompanied

by another element. First by the quay crane, until the moment it is placed on an AGV. In

between the quay crane cannot handle another container. Then it is accompanied by the

AGV, also when it is waiting at the ASC. A landside job on the contrary, is placed individually

at an ASC. Basically that means that on one hand AGVs and on the other hand landside jobs

are placed in a queue at an ASC. Therefore the landside job is an element class, while the

container is not.

The reason the TimeManager and AnimationDrawer are element classes, is because in this

way individual processes can be assigned to them.

All element classes in TOMAS have predefined properties. The AGV has two additional

properties for this simulation program: the Booleans statusIdle and statusWaiting, which are

used to calculate the time an AGV has been idle or waiting.

2.6 SET’s (queues) In general there are three queues for all ASCs, all AGVs and all quay cranes. If necessary

there is an additional queue for AGVs waiting in a central pool at the quay crane area

(depends on the quay crane selection strategy selected).

Furthermore all quay cranes contain a queue for AGVs waiting at this quay crane, and if

necessary a queue with AGVs that are on their way to this quay crane (also depends on the

quay crane selection strategy selected).

All ASCs contain both a queue for AGVs waiting at this ASC and a queue for land-side jobs

waiting at this ASC.

Finally there is a queue for the AnimationDrawer. The idea is that in this way the

AnimationDrawer can easily be called during the simulation, although it could also have

been declared globally.

2.7 Distributions The 'ship unload times for quay cranes' are assumed to be negatively exponentially

distributed. Therefore an exponential distribution is required.

The AGV and ASC cycle times are assumed to be uniformly distributed, so for that two

uniform distributions are required.

Finally one of the ASC selection strategies is a random selection of an ASC. This is realized by

a uniform distribution as well.

Page 10: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

10

2.8 Assumptions The simulation in based on several assumptions:

General assumption:

• The simulation only considers the incoming containers from sea.

• The simulation only considers net operational hours. This means that the input from the

sea side (ships) is permanently available and no breakdowns and other stops are

considered.

A few assumptions for the simulation originate from the process descriptions from the book:

• In one cycle, the time for an AGV to drive from a certain ASC to a quay crane is equal to

the time to drive from this quay crane to a new selected ASC.

• In one cycle, the time for an ASC to move from a certain position in the stack to an AGV

is equal to the time to move from this AGV to a new position in the stack.

• ASCs select sea-side jobs before land-side jobs.

• 90 land-side jobs will be created per hour. Therefore every 3600/90 = 40 seconds a land-

side jobs will be created.

Other assumptions from the case description in the book:

• The cycle times of the quay cranes are assumed to have a negative exponential

distribution.

• The cycle times of the AGVs and ASCs are assumed to be uniformly distributed. (The

cycle times will be the result of the (still unknown) routing algorithm to be used, as well

as traffic delays.)

• There are no upper limits on the number of AGVs waiting for a QC or ASC.

• Both quay cranes and ASCs select AGVs in first-in-first-out order.

Assumptions not defined in the book:

• The description of the case states that as a second ASC selection alternative, the AGVs

and land-side jobs select an ASC based on the workload already assigned to an ASC. This

selection is assumed to be performed at the moment of arrival. Therefore, in

contradiction to the process description in the book, the ASC is selected after driving

towards the ASC. For the first ASC selection alternative, where an ASC is selected

according a uniform distribution, this does not affect the results, since the AGV cycle

time is independent of the selected ASC.

• Landside operations cover both retrieving a container from the stack and placing it at

the point where it can be picked up by a straddle carrier. This assumption is made

because the book literally says: ‘the landside operation is taken into account up to the

point at which a container is retrieved from the stack’. Placing the container at the point

where it can be picked up by a straddle carrier is still being part of the operations of the

ASC. At This point there is no transfer time considered though, since the container is just

placed on the ground and no accurate positioning is required.

• The process description for ASCs defines an ASC landside operation as “work D seconds”.

Since this D is not further specified and a constant cycle time for landside operations is

unrealistic, it is assumed that the cycle times of landside operations are equal to the

cycle times for seaside operations. This means they will both be samples of the same

uniform distribution. The previous assumption supports the idea that the proceedings

(and thereby the cycle times) for sea-side and land-side operation are similar.

Page 11: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

11

2.9 The variable parameters The parameters for the simulation which can be specified by the user are:

• The simulation runtime; the timespan of the simulation.

• The start-up time; the time preceding the simulation, to start up the operations of the

simulation, so that the effects of starting up will not influence the results of the

simulation.

• The number of available quay cranes in the simulation.

• The ship unload time for quay crane; the average time a quay crane requires to unload a

container from a ship.

• The AGV load time for quay crane; the time a quay crane requires to load a container on

an AGV.

• The number of available AGVs in the simulation.

• The minimum and maximum AGV cycle time; the time an AGV requires to drive from an

ASC to a quay crane and drive back to an ASC.4

• The number of available ASCs in the simulation.

• The minimum and maximum ASC cycle time; the time an ASC requires to drive from the

place in the stack to the place where it can pick up a container from an AGV and drive

further to a new place in the stack to store this container.5

• The AGV unload time for ASC; the time an ASC requires to unload a container from an

AGV.

For the selection of ASCs and quay cranes several alternatives are discussed in the book. In

the simulation program, the user can choose between these alternatives:

• ASC selection alternative 1: Both AGVs and land-side jobs select an ASC according a

uniform distribution.

• ASC selection alternative 2: AGVs and land-side jobs select an ASC according the work

load already assigned to an ASC. (One should bear in mind

that workload-based selection is only possible for import

containers. Export containers are already in the stack and

thus the ASCs to handle them are determined beforehand.)

• QC selection alternative 1: AGVs do not select a quay crane at all. They are assumed to

arrive in a large pool of waiting AGVs, where each quay

crane can select an AGV instantaneously.

• QC selection alternative 2: AGVs select the destination quay crane at the moment of

arrival in the quay crane area.

• QC selection alternative 3: AGVs select a quay crane at the moment of departure from

the ASC.

4 Be aware that the AGV cycle time for the user in the simulation program is different, because it

includes transfer times. Therefore in the simulation program it is the time an AGV requires to let an

ASC unload a container, drive from the ASC to a quay crane, let the quay crane load a container and

drive back to an ASC. The reason for this is explained in paragraph 2.10. 5 Be aware that the ASC cycle time for the user in the simulation program is different, because it

includes transfer times. Therefore in the simulation program it is the time an ASC requires to drive

from a position in the stack to the place where it can pick up a container from an AGV, unload a

container from an AGV and drive further to a new position in the stack to store this container. The

reason for this is explained in paragraph 2.10.

Page 12: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

12

2.10 Motivation of possibly confusing choices During programming the simulation, many choices have been made. Two choices that might

cause some confusion are mentioned and explained:

• Representation of landside jobs in the animation

For illustration purposes, the landside jobs are represented in the animation of the

simulation program by blue rectangles on the left of the ASCs. Because they have the

same size as the rectangles representing the AGVs, it might be interpreted as incoming

landside containers. Since this possible misinterpretation does not affect the results6 it is

not further enlightened in the program.

• AGV and ASC cycle times including or excluding transfer times

The process descriptions in the book consider a different cycle time than the

experiments in the book. The process descriptions, on which the programming code of

the simulation program is based, consider a cycle time for both AGVs and ASCs as only

the time to drive from A to B and back to A. The transfer times, the time to load or

unload a container from an AGV, are not included in these cycle times. On the contrary,

the cycle times used for the experiments do actually include these transfer times.

Since the simulation program is to be used for educational purposes in combination with

the case described in the book, it is required that with identical input parameters, the

results of the simulation program match the results of the experiments described in the

book.

Keeping this in mind, three alternatives to deal with the transfer times in the program

are:

a) Consider the cycle times of the simulation program excluding the transfer times, just

like the process descriptions and the programming code.

b) Consider the cycle times of the simulation program including the transfer times, just

like the experiments described in the book.

c) Create a possibility for the user (a checkbox) to choose whether or not the transfer

times should be included in the cycle times.

To maintain the user-friendliness of the simulation program, alternative b is chosen.

Alternative c was expected to be possibly too confusing for the user. Since alternative b

is chosen, the same input for the cycle times of the experiments are required for the

simulation program, in order to obtain equivalent7 results.

8 The consequence is that in

the programming code, the transfer times should be subtracted from the cycle times of

the user. Although the user will not have to work with the programming code, it might

get in touch with the process descriptions (with a cycle time excluding transfer times) in

the case description in the book. It is assumed the description of the experiments in the

book as well as the simulation program is clear enough to indicate that their cycle times

include transfer times.

6

Outgoing land side containers are occupying the ASCs and thereby affecting the sea side production.

Since outgoing as well as incoming land side containers are occupying the ASCs identically, it does not

matter if the user incorrectly thinks the blue rectangle of the animation is representing an incoming

instead of outgoing land side container. 7 Realize the results are not expected to be identical, due to the stochastic processes in the

simulation. 8 This means that to obtain the result from the book with a cycle time (including transfer times) of

360 seconds, the user can directly fill in 360 seconds in the simulation program. Otherwise

(alternative a) the user should have been subtracting the transfer times itself, and filling in for

example a cycle time (excluding transfer times) of 345 seconds to obtain the results of the book with

a cycle time (including transfer times) of 360 seconds.

Page 13: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

13

3 The simulation program Around the simulation itself, a program is built to help the user run and understand a

simulation. This simulation program has its own requirements which can be derived from

the objective of this assignment.

3.1 Requirements of the simulation program

The objective of this assignment requires that the program is very user-friendly and

foolproof and that it can run a simulation of the container terminal, according to the

description in the book. The purpose of the simulation program requires furthermore:

• That the user can see the performance of the container terminal.

� Therefore the performance is calculated and presented to the user (unit 1:

SingleSimulation).

• That the user can change several parameters of the simulation.

� Therefore the user has the possibility to define several parameters before the

start of the simulation (unit 1: SingleSimulation).

• That the user can understand what is happening in the simulation.

� Therefore the simulation is being visualized by an animation with symbolic

figures of elements and their status (unit 1: SingleSimulation).

• That the user can see the utilization of the elements over the whole simulation, which

can help the user to decide which parameters to change9.

� Therefore the 'utilization over time' and the utilization distributions are showed

in different charts (unit 6: UtilizationCharts).

According to the purpose of the simulation program, the user is supposed to be able to

study the influence of a certain parameter on the performance of the terminal. In the book

the influence of certain parameters is showed, by displaying the results of a batch of

simulations where these parameters are changed for each simulation. Therefore it can also

be expected that the user is supposed to run such batches of simulations. Considering the

user-friendliness requirement, the program is additionally required to:

• Be able to help the user running a batch of simulations. Instead of running each

simulation for itself, this will be done by creating a bat-file, which can automatically run

all the simulations successively.

� Therefore a special option is built in the program, which helps the user to set the

parameter to be varied, the constant parameters and create the bat-file for

running a batch of simulations.

To examine the influence of a certain parameter, it is recommended to change

only one parameter at the time. Besides, in the book, a series of simulations is

run for different cases. Therefore first a form appears to set the parameter to be

varied, and subsequently a form to define constant parameters and specific

parameters for different cases (units 2 & 3: CreateBatch and BatchParameters).

9 The result of a simulation is the performance of the terminal. To understand how this result is

caused, the utilization charts of the elements can help. For example an unsatisfactory performance in

combination with a quay crane utilization of mainly the maximum number of quay cranes and

occasionally one less than the maximum number of quay cranes, an ASC utilization always below the

number of ASCs, and an AGV utilization of occasionally the maximum number of AGVs, simply might

increase by adding an AGV or decreasing the AGV cycle time and not by adding an ASC or decreasing

the ASC cycle time. In case for example the quay crane utilization is distributed over several numbers

of quay cranes, simply adding an AGV probably will not really increase the result and it might be

worth trying a different quay crane selection strategy to study its influence on the performance.

Page 14: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

14

3.2 Composition of the simulation program To meet these requirements, the simulation program is composed of 4 main units, all with

their own form (screen). To get an understanding of how the program works, in appendix B

the relations between the units and all the possible actions a user can do, are described for

each unit.

• SingleSimulation (unit 1)

The unit SingleSimulation is the main unit of the simulation program, where a single

simulation can be run. This is where the program starts and the unit where the

simulation itself is programmed. The form contains the animation, the results, the

buttons to operate the simulation (start, interrupt, resume, close), and the possibility for

the user to specify all parameters preceding the start of a simulation.

Figure 4: the form of unit 1: SingleSimulation

Page 15: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

15

• UtilizationCharts (unit 6)

The unit UtilizationCharts and its form contain the different utilization charts and what is

related to that.

• CreateBatch (unit 2)

The units CreateBatch and BatchParameters and their forms have nothing to do with the

simulation or its results themselves, but give the user the possibility to create a bat-file

to run a batch of different simulations. In CreateBatch the user is first asked to choose

one ‘main parameter to be varied’ in this batch of simulations. This way the user is

forced to vary one parameter in a regular way.

Figure 6: the form of unit 2: CreateBatch

Figure 5: the form of unit 6: UtilizationCharts

Page 16: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

16

• BatchParameters (unit 3)

The unit BatchParameters helps the user to further specify the parameters for the batch

of simulations. Therefore the user is asked to specify the constant parameters and, if he

wishes, to specify several case specific parameters.

Figure 7: the form of unit 3: BatchParameters

Page 17: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

17

Layout of the forms

The layout of the different forms of the simulation program is mainly a personal preference

of the writer. Most important is, that it has been tried to maintain the clarity and user-

friendliness, by grouping similar items and separating different groups of items with

different functions.

o For example in the form SingleSimulation, the operational buttons (start, interrupt,

resume, stop) are grouped together, but separated from the other buttons (create a

batch of simulations, show utilization charts). The results of the simulation are

grouped and accentuated by a black border. The input parameters for the

simulation are grouped together on the right of the form, and actually arranged

again in groups for time parameters, quay crane parameters, AGV parameters etc.

Finally everything is arranged such that the animation is not limited in the amount

of quay cranes and ASCs it can show. If necessary the border of the program can be

widened.

o For the form UtilizationCharts, it is chosen to place the similar graphs next to each

other in one row, and to accentuate the results with a grey border, where only the

most important results are presented in black. Furthermore the items to change the

line chart with the utilization of the elements over time are positioned close to the

chart. The buttons (zoom info and cancel) are positioned together as well on the

right of the form.

o For the form CreateBatch, a brief instruction with an example is placed on the top

and a memobox is placed to display clearly what the user has specified. To avoid

that the user had to fill a lot of repetitive numbers, the user is only asked for the

start value, the step size and the number of steps for this main parameter10

.

o For the form BatchParameters, the same layout for the input parameters as in

SingleSimulation and the same memobox as in CreateBatch are used to maintain

consistency.

10 If for example the start value is 36 AGVs, the step size 6 AGVs and the number of steps 3 steps, the

program calculates there will be 4 simulations with 36, 42, 48 and 54 AGVs.

Page 18: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

18

3.3 Measures to ensure the user-friendliness and fo olproofness Several measures which are not required for the simulation itself, have been taken to ensure

the user-friendliness and foolproofness of the simulation program, for example:

In general:

• Disabling all buttons, editboxes, checkboxes, radio buttons etc. in case they cannot be

clicked or changed by the user. As a result the user can immediately see what can be

clicked or changed, and confusion will be avoided. Furthermore the user can for example

expect something to happen if a button is clicked or that his changed value will be taken

if he is still able to change it.

• Checking all the user inputs, before using them. As a result no faulty user inputs are used

in the simulation. Therefore the input will be checked for:

o string conversion errors, in case the input cannot be converted to a value (e.g.

“r34#5”).

o non-integer values, in case an integer is required and the input is a non-integer

value.

o out-of-range values, in case there are some restrictions to the input (e.g. x > 0 or x ≥

1).

o min > max. Although for the simulation program it is not necessarily a problem, for

the user-friendliness the minimum and maximum value will be exchanged in case

min > max.

• Saving inputs to text files for the next session:

o If the checkbox is checked, the program automatically saves the current input to a

text file if the simulation is started or a batch of simulations will be created.

o If this text file is available while starting the simulation program, the input

parameters will be copied from this text file.

• Automatically closing the program when the create a batch of simulations form or the

case/simulation parameters form are closed instead of cancelled. Otherwise the user all

the time has to close all forms to close the program after creating a bat-file.

For the main form (SingleSimulation):

• Having a brief explanation on the main form of every parameter separately, when

placing your mouse pointer over it of one of its corresponding labels (see figure 8).

• Also displaying the sea-side production in terms of the total amount of containers and

showing the progress of the simulation (in seconds), instead of only displaying the

performance of the terminal (the sea-side production in containers/hour).

• Displaying the performance of the terminal, sea-side production, in terms of

containers/hour, instead of containers/NOH. It is assumed this will be better understood

by the user, and for the simulation itself it is already assumed only operational hours are

considered.

• Keeping the form with the animation and results visible after the simulation has finished.

• Automatically showing the utilization charts form after the simulation has finished.

Figure 8: a brief explanation of the parameter when the mouse pointer is placed over it

Page 19: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

19

During simulation:

• Having the possibility to interrupt and resume the simulation.

• Having the possibility to slow down the animation, in order to see better what is going

on.

• Reducing the calculation time of the simulation, in order to increase the speed of the

simulation. Therefore:

o the user has the possibility to switch off the animation.

o the bar charts are only updated completely if the utilization charts form is active (in

the foreground).

o the animation is being switched off automatically when the user opens the

utilization charts form during the simulation. It is still possible to switch on the

animation while the utilization charts form is showed. The animation is switched on

automatically if charts user closes the utilization charts form during the simulation,

to prevent the simulation continues too fast. If the user desires the simulation to

continue that fast, is has to switch off the animation again.

o the results will not be updated if both the animation is switched off and utilization

charts form is hided.

• Displaying a legend with an explanation of symbolic figures in

the animation, see figure 9.

o The legend is displayed every time the animation is being

enabled.

o The legend is automatically hided when the animation is

disabled.

o The legend is displayed in a separate form, so that it can

be closed and is not permanently in the foreground.

o The legend only includes the elements that can occur in

the animation. This means the element ‘AGV on its way

to a QC’ is only visible when the QC selection strategy

‘AGVs will select a quay crane at the moment of

departure from an ASC’ is chosen for the simulation.

• Repainting the animation in parts instead of all at once. First

the ASCs are repainted, then the AGVs and finally the quay cranes. This way extremely

flickering of the animation on the computer screen is partly prevented.

• Drawing a ‘ + ’ when too much elements are at a certain location in the animation. The

simulation program itself has (until a certain limit) no restriction on the number of

elements in the simulation, but the animation has. Therefore a ‘ + ’ indicates there are

more elements than drawn, see figure10.

Figure 9: legend

Figure 10: a ' + ' is drawn when there are too much elements at a certain location in the animation

Page 20: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

20

During simulation start-up:

• Announcing the user when the simulation is starting up, see figures 11 and 12.

o The simulation time on the main form is changed to ‘simulation start-up:’ while its

colour is dark red.

o The start-up time input parameter is also coloured dark red, to clarify that the

simulation is currently starting up the time that has been entered by the user.

o The utilization charts form shows ‘simulation start-up’ in dark red as well.

• Hiding (incorrect) results during the start-up of the simulation:

o The results on the main form are not updated.

o The utilization results on the utilization charts form are not displayed.

o The utilization distributions on the utilization charts form are not displayed.

• Presenting a negative simulation time when the simulation is starting up:

o The simulation time on the main form is negative. After the simulation start-up it

starts from zero and is therefore presenting the real simulation time (without start-

up).

o The time of the utilization over time chart on the utilization charts form is negative.

• Presenting the utilization over time in the chart during start-up, in order to:

o Observe the influence of starting up the simulation.

o Understand why it is necessary to do so.

o Judge whether the chosen start-up time is long enough.

Figure 11: main form during start-up of the simulation.

Figure 12: utilization charts form during start-up of the simulation.

Page 21: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

21

For the utilization charts (see figure 13): • Having the possibility to zoom into the charts to observe detailed information.

• Having the possibility to click on a button (zoom info) to receive an explanation of how

to zoom in and scroll through these charts.

• Having the possibility to change the range of the horizontal axis of the line chart with the

utilization of the elements over time.

• Having the possibility to easily scroll horizontally through the line chart with the

utilization of the elements over time with a scrollbar under the chart.

• Having the possibility to select in checkboxes which of the lines in the line chart should

be showed.

• Having the possibility to also observe the percentage of the waiting AGVs over the whole

simulation, because the animation also shows AGVs waiting at an ASC.

• Updating all the charts after all events when the utilization charts form is active.

Otherwise if the utilization of an element does not change for a long time, the charts can

give distorted data.

Figure 13: zooming and an explanation how to zoom in UtilizationCharts

Page 22: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

22

For creating the bat-file for a batch of simulations:

• Creating a bat-file that uses the same

simulation program, such that no additional

applications are required on the computer.

• Providing small steps with an explanation, to

force the user to choose one main parameter

to be varied and vary this one in a regular way.

Thereby reducing the effort for the user to

define a lot of similar simulations.

• Clearly distinguishing constant and non-

constant parameters.

• Constantly presenting the user what has is

going to be simulated in a clarifying way in a

memobox, see figure 14. A change will directly

be visible.

• Providing the possibility to define this batch of

simulations for different cases:

o The amount of cases is not limited.

o The user can add and delete cases, and

adjust all parameters as desired.

o The user can easily change a constant into a case-specific parameter.

• Enabling the user to define a batch of different simulations on its own, without choosing

one main parameter to be varied.

• Saving the content of the batch of simulations in a text file, in case the user wants to see

afterwards what he has defined.

• Announcing the user:

o that the bat-file is created.

o that the content of the batch of simulations is saved in a text file.

o that the results will be showed in an Excel document and also in a text file.

o how the batch of simulation can be started.

o where these files can be found on the computer.

For running a batch of simulations:

• Indicating the user when the simulation is in

progress, because the user does not see

anything happen. This is done by a form, see

figure 15. • Increasing the speed of the simulations by

skipping all the irrelevant actions and calculations required for, for example, loading and

opening all forms, drawing the animation or updating the charts.

• Displaying the results in an Excel sheet, so the results can easily be further processed.

• Checking if an Excel sheet can be opened before opening it11

.

• Checking if results can be written in the Excel sheet before writing them12

.

• Writing the results both in an Excel sheet and in a text file. The Excel sheet enables the

user to easily study the results, while the text file contains all results, even when the

simulation program was unable to write the results in Excel.

11

In case the computer on which the program is running for example does not have Microsoft Excel. 12

In case the user for example refused to wait and has closed Excel or is working in any Excel

worksheet at the moment the simulation program tries to write the result.

Figure 15: InProgressMessage

Figure 14: an overview of the simulations in the memobox

Page 23: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

23

4 Model verification In order to verify the simulation model, the results of different simulations are compared

with some calculations and some reasoning. Furthermore a comparison is done with the

results from experiments described in the book.

As verification is basically checking whether the simulation program works like it has been

designed, validation questions whether the simulation model is properly describing the

reality. Since in the first place no data from the reality is available and in the second place

this simulation program is not designed for use in practice but for educational purposes in

combination with the book, no validation of the simulation model has been done.

4.1 Comparison with calculations and reasoning

Maximum capacity of the quay cranes

In order to verify the results of the simulation program, the maximum capacity of the quay

cranes can be calculated and compared with results of the simulation program. Therefore

several simulations with a maximum utilization of the quay cranes are required. This can be

easily obtained by choosing enough AGVs in combination with small AGV and ASC cycle

times.

Calculation example:

In case the input would be a negatively distributed ship unload time with an average

of 95 seconds and an AGV load time of 15 seconds, it takes on average 110 seconds

per quay crane to handle a container. This means on average (3600/110) 32.7

containers/hour will be expected for each quay crane. So if a simulation is run with

the 100% utilization of the quay cranes, the sea-side production should be around

32.7 containers per hour per quay crane. For three quay cranes, the expected result

will be (3*3600/110) 98.2 containers per hour.

Several experiments with different values have verified the results of the simulation

program under these circumstances, see for example the results of ten experiments in table

1. It is clear that for all experiments the calculated (expected) result and the simulation

result are alike.

Nr. of

QCs

ship unload

time [s]

AGV load

Time [s]

utilization

QC

expected result

[cnr/hr]

result simulation

program [cnr/hr]

3 95 15 100% 98.2 98.3

3 36 43 100% 136.7 136.4

6 47 15 100% 348.4 347.2

6 26 62 100% 245.5 245.2

8 37 15 100% 553.8 553.9

8 78 12 100% 320.0 318.6

25 125 15 100% 642.9 644.4

25 5 18 100% 3913.0 3913.0

56 95 34 100% 1562.8 1562.6

56 95 3 100% 2057.1 2056.4

Table 1: Ten experiments to verify the simulation results in case of a maximum utilization of the quay cranes

Page 24: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

24

Non-maximum capacity of the quay cranes

Furthermore a calculation by hand has been done to verify the simulation in cases the

utilization of the quay cranes cannot be 100% and the maximum capacity of the quay cranes

cannot be reached. An explanation of this calculation is described in appendix C. The results

are shown in table 2, where it can be seen that the results of the simulation program are

matching the outcome of the calculations as well.

Nr. of

QCs

Nr. of

AGVs

AGV cycle

time [s]

result hand

calculation [cnr/hr]

result simulation

program [cnr/hr]

1 2 300 21.4 21.3

1 2 500 14.1 14.1

1 2 800 9.0 9.0

1 4 300 30.9 30.6

1 4 500 24.8 24.8

1 4 800 17.3 17.3

2 4 100 65.4 65.2

2 4 200 57.4 57.0

2 4 400 35.4 35.3

2 4 600 24.0 24.0

Table 2: Ten experiments to verify the simulation results in case of a maximum utilization of quay cranes

Reasoning

For more complicated simulations, it becomes too difficult to use hand calculations for

verification. Fortunately the animation, in combination with the utilization charts and

reasoning might help verifying the simulation. For example the addition of ASCs or AGVs to

the simulation should only be able to increase the performance of the terminal and never

reduce it. Increasing the ASC cycle time should increase the utilization of the ASCs, and

thereby as well the utilization of the AGVs when they have to wait for ASCs. As a result of

this, depending on the amount of AGVs and their cycle time, the performance of the

terminal can be reduced. A different ASC selection strategy, which reduces the waiting time

of AGVs at the ASCs, should increase the performance of the terminal.

This and other reasoning are confirmed by results of the simulation program, in order to

help verifying it.

Page 25: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

25

4.2 Comparison with experiments in the book Furthermore the results of the simulation program can and should be compared with the

results of the experiments in the book. Of course it cannot be assumed unthinkingly that the

results in the book are definitely correct, but in the first place a deviation might give a

reason to find out how this is caused, what might lead to an improvement. On the other

hand the purpose of the simulation program is that it can be used for educational purposes,

in combination with the case described in the book. Therefore it is necessary to compare the

results from the simulation program with the results from the book, in order to avoid

undesired surprises.

Brief description of the experiments in the book

The book describes three sets of experiments and discusses their results to determine an

indication of the maximum (average) cycle times for the AGVs and ASCs, given the intended

results of the system. All experiments have a simulated period of 100 consecutive net

operational hours, after an initial hour to start operations. The intended results of the

system are a sea-side productivity of 260 containers/NOH with eight quay cranes and 240

containers /NOH with six quay cranes.

� The first set of experiments is meant to provide an indication of the maximum (average)

cycle times for the AGVs. Therefore the cycle time of the ASCs and the time for an ASC to

unload a container (transfer time) are set to zero.

� In the second set of experiments also the cycle time of the ASCs and the time for an ASC

to unload a container (transfer time) are considered.

� In the third set of experiments, the effects of different quay crane and ASC selection

strategies are examined for chosen AGV and ASC cycle times.

Assumptions for the experiments in the book:

• The simulation runtime of each experiment will be 100 consecutive (net operational)

hours.

• The start-up time of each experiment will be 1 hour.

• The experiments will be carried out for both 6 and 8 quay cranes.

• 48 AGVs will be available.

• 25 ASCs will be available.

• The average QC cycle time for unloading a ship will be 95 seconds in case eight quay

cranes are operational and 75 seconds in case six quay cranes are operational.

• A quay crane will load an AGV in 15 seconds.

• An ASC will unload an AGV in 15 seconds.

• For the first and second set of experiments, both AGVs and land-side jobs select an ASC

according a uniform distribution (ASC selection alternative 1).

• For the first and second set of experiments, AGVs do not select a quay crane at all. They

are assumed to arrive in a large pool of waiting AGVs, where each quay crane can select

an AGV instantaneously (QC selection alternative 1).

In the next figures, for all experiments the coloured results of the simulation program can be

compared with the white dashed lines for the corresponding results from the book. It can be

seen that these are very alike. Since for example the chosen ‘seeds’ for the distributions in

the simulation influence the results, it cannot be expected that the results of the simulation

program are identical to the results in the book. In Appendix D you can find more detailed

data about the results of the simulation program for these experiments.

Page 26: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

26

First set of experiments

Second set of experiments

Figure 16: comparison of the coloured results of the simulation program with the white dashed lines for the corresponding results from the book, for the first set of experiments

Figures 17 and 18: comparison of the coloured results of the simulation program with the white dashed lines for the corresponding results from the book, for the second set of experiments

Page 27: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

27

Third set of experiments

4.3 Conclusion In this chapter the simulation has been verified by demonstrating that the results of the

simulation program are matching the expected results as a result of calculations, reasoning

and comparison with the results of the book.

References

• The Delft Systems Approach, H.P.M. Veeke, J.A. Ottjes and G. Lodewijks, Delft, 2008.

Figures 19 and 20: comparison of the coloured results of the simulation program with the white dashed lines for the corresponding results from the book, for the third set of experiments

Page 28: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

28

Appendix A: the Process Description Language: PDL The PDL is a more specific way to define the processes of the simulation model, which uses a limited

vocabulary in contradiction to the plain language used for the conceptual model and the process

description in the book and this report. In this appendix the PDL of only the simulation model will be

shown. The programming code of the simulation is based on this PDL, but might slightly differ in

specific cases. Many code required for features improving the user-friendliness as described in the

report as well, is not included in the PDL. As a result many additional lines are present in the

programming code, but they have no influence on the simulation itself. These lines are for example

required to obtain information for the animation, the charts or the utilization figures. The lines

changing the properties statusIdle and statusWaiting of the AGVs are an axample of this, which are

actually included in the PDL because these properties were also mentioned in the list of element

classes, both in this appendix and in the report.

A motivation why these element classes and processes are chosen this way can be found in the

report.

Classes:

QuayCrane = SimElement

- agvQueue = Queue

- agvOnItsWayQueue = Queue

- process

Agv = SimElement

- statusIdle

- statusWaiting

- process

Asc = SimElement

- agvQueue = Queue

- landsideQueue = Queue

- process

LandsideJobGenerator = SimElement

- process

LandsideJob = SimElement

TimeManager = SimElement

- process

AnimationDrawer = SimElement

- process

SET's:

quayCraneQueue = Queue

generalAgvQueue = Queue

agvsAtQuayCranesQueue = Queue

ascQueue = Queue

animationDrawerQueue = Queue

Distributions:

quayCraneUnloadTimeDistribution = Exponential Distribution

agvCycleTimeDistribution = Uniform Distribution

ascCycleTimeDistribution = Uniform Distribution

ascSelectionDistribution = Uniform Distribution

Page 29: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

29

Initialization:

runtime = read

startuptime = read

numberOfQuayCranes= read

meanshipUnloadTimeForQc = read

agvLoadTimeForQc = read

numberOfAgvs = read

lowerboundAgvCycleTime = read

upperboundAgvCycleTime = read

numberOfAscs = read

lowerboundAscCycleTime = read

upperboundAscCycleTime = read

agvUnloadTimeForAsc = read

ascSelectionForAgv = read

seasideProduction = 0 (containers)

quayCraneQueue = Queue.Create

generalAgvQueue = Queue.Create

if required then agvsAtQuayCranesQueue = Queue.Create (if QC selection strategy = 1)

ascQueue = Queue.Create

if required then animationDrawerQueue = Queue.Create (if this is not a batch of simulations)

quayCraneUnloadTimeDistribution = ExponentialDistribution.Create

agvCycleTimeDistribution = UniformDistribution.Create

ascCycleTimeDistribution = UniformDistribution.Create

if required then ascSelectionDistribution = UniformDistribution.Create (if ASC selection strategy = 1)

for all quay cranes (numberOfQuayCranes) do

newQuayCrane = QuayCrane.Create

newQuayCrane.agvQueue = Queue.Create

newQuayCrane.agvOnItsWayQueue = Queue.Create

newQuayCrane.EnterQueue(quayCraneQueue)

newQuayCrane.Start

for all AGVs (numberOfAgvs) do

newAgv = Agv.Create

newAgv.statusIdle = False

newAgv.statusWaiting = False

newAgv.EnterQueue(generalAgvQueue)

newAgv.Start

for all ASCs (numberOfAscs) do

newAsc = Asc.Create

newAsc.agvQueue = Queue.Create

newAsc.landsideQueue = Queue.Create

newAsc.EnterQueue(ascQueue)

newAsc.Start

newLandsideJobGenerator = LandsideJobGenerator.Create

newLandsideJobGenerator.Start

newTimeManager = TimeManager.Create

newTimeManager.Start

if required then newAnimationDrawer = AnimationDrawer.Create (if this is not a batch of simulations)

if required then newAnimationDrawer.Start (if this is not a batch of simulations)

QC selection strategy = 1 stands for:

AGVs do not select a quay crane at all.

They are assumed to arrive in a large

pool of waiting AGVs, where each

quay crane can select an AGV

instantaneously

QC selection strategy = 2 stands for:

AGVs select the destination quay

crane at the moment of arrival in the

quay crane area.

QC selection strategy = 3 stands for:

AGVs select a quay crane at the

moment of departure from the ASC.

ASC selection strategy = 1 stands for:

Both AGVs and land side jobs select an

ASC according a uniform distribution.

ASC selection strategy = 2 stands for:

AGVs and land side jobs select an ASC

according the work load already

assigned to an ASC.

read means that the value of this

parameter has to be obtained from for

example a text file or user input.

Page 30: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

30

QuayCrane.Process

Repeat

Hold(quayCraneUnloadTimeDistribution.Sample)

if required then (if QC selection strategy = 1)

if agvsAtQuayCranesQueue.Length < 1 then Suspend

newAgv = agvsAtQuayCranesQueue.FirstElement

newAgv.LeaveQueue(agvsAtQuayCranesQueue)

newAgv.EnterQueue(AgvQueue)

else then (if QC selection strategy = 2 or 3)

if AgvQueue.Length < 1 then Suspend

myAgv = AgvQueue.FirstElement

myAgv.statusIdle = False;

Hold(AGVLoadTimeForQc)

myAgv.Remove(AgvQueue)

myAgv.Resume

SeasideProduction = SeasideProduction + 1

Agv.Process

Repeat

cycleTime = agvCycleTimeDistribution.Sample

if required then (if QC selection strategy = 3)

myQuayCrane = quayCraneQueue.Element(selectQuayCrane)

EnterQueue (myQuayCrane.agvOnItsWayQueue)

Hold(cycleTime/2)

if required then (if QC selection strategy = 1)

Enterqueue(agvsAtQuayCranesQueue)

myQuayCrane = quayCraneQueue.Element(selectQuayCrane)

else then (if QC selection strategy = 2 or 3)

if required then (if QC selection strategy = 3)

LeaveQueue(myQuayCrane.agvOnItsWayQueue)

else then (if QC selection strategy = 2)

myQuayCrane = quayCraneQueue.Element(selectQuayCrane)

EnterQueue(myQuayCrane.AGVQueue)

if required then myQuayCrane.Resume (if status QC = idle (passive))

statusIdle = True

Suspend

Hold(cycleTime/2)

myAsc = ascQueue.Element(selectAsc)

EnterQueue(myAsc.AGVQueue)

if required then myAsc.Resume (if status ASC = idle (passive))

statusWaiting = True

Suspend

The underlined words stand for a

function that’s called, for example to

determine which quay crane will be

selected.

Page 31: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

31

Asc.Process

Repeat

if (AgvQueue.Length < 1) AND (landsideQueue.Length < 1) then Suspend

cycleTime = ascCycleTimeDistribution.Sample

if AgvQueue.Length > 0 then

myAgv = AgvQueue.FirstElement

myAgv.statusWaiting = False

Hold(cycleTime/2)

Hold(AgvUnloadTimeForAsc)

myAgv.Remove(AgvQueue)

myAgv.Resume

Hold(cycleTime/2);

else then (if AgvQueue.Length ≤ 0)

myLandsideJob = landsideQueue.FirstElement

Hold(cycleTime)

myLandsideJob.Destroy;

LandsideJobGenerator.Process

Repeat

Hold(3600/90)

myLandsideJob= LandsideJob.Create

myAsc = AscQueue.Element(selectAsc)

myLandsideJob.EnterQueue(myAsc.LandsideQueue)

if required then myAsc.Resume (if status ASC = idle (passive))

TimeManager.Process

if required then 'set all labels etc.' (if this is not a batch of simulations)

Hold(startuptime)

seasideProduction = 0

if required then 'set all labels etc.' (if this is not a batch of simulations)

Hold(RunTime)

if required then (if this is not a batch of simulations)

InterruptSimulation

'set all labels etc.'

else then (if this is a batch of simulations)

'write the results (to excel and text file)'

StopSimulation

AnimationDrawer.Process

Repeat

'repaint the entire animation'

Hold(1)

Actions between quotation marks, like

'set all labels etc.', stand for a bunch of

actions together (disable/enable labels,

buttons, checkboxes, adjust their

colours, calculate final results, etc.)

Page 32: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

32

Appendix B: user operations of the simulation program

To get an understanding of how the program works, in this appendix the relations between the units,

and all the possible actions a user can do and their consequences are described for each unit.

For the simulation program, a VCL-Form Application in Delphi is used. This way it is easy to make an

application with several forms which are accompanied by their own unit. As described before the

simulation program is composed of 4 main units and two additional units to present a separate

screen/message to the user (InProgressMessage and AnimationLegend). The relations between these

units are presented in figure B.1:

Figure B.17: The relations between the different units of the simulation program

When the program is started, it first calls the procedure ‘Initialization’ in unit 1: SingleSimulation,

which calls the procedure ‘CheckForBatchOfSimulations’ to check whether a batch of simulations is

running.

In that case the program starts up in a different way, loads only the form of unit 5 and starts the

simulation immediately. Otherwise the forms of unit 1, 2, 3, 4 and 6 are loaded, the form of unit 1 will

be activated and the program will wait for the user to start the simulation.

SingleSimulation (unit 1)

• So in case no batch of simulations is running, the form of the main unit (SingleSimulation) will be

activated first. This calls the procedure ‘FormCreate’, which checks if the text file with input

values from a previous session is available, in order to place these in the editboxes for the input

parameters. If not, then standard input values are taken.

• At any time the form is activated, the procedure ‘FormActivate’ is called which checks:

- Whether it should start up the animation after closing the utilization charts.

- Whether it should close the program, because the form CreateBatch has been closed by the

user in other ways then clicking the ‘cancel’-button.

• Clicking the ‘start’-button calls the procedure ‘BtnStartClick’ which:

- Calls the procedure ‘CheckInputs’ to check the inputs, and will only continue in case all inputs

are ok. In case the input is not ok, the procedure ‘CheckInputs’ will indicate what is wrong by

showing a message and selecting the faulty input in the editbox.

- Disables the editboxes, labels and buttons which cannot be changed or clicked anymore after

the simulation has started.

- Calls the procedure ‘InitializeSystem’ to initialize the simulation. Here the inputs are read,

results are set and all the elements (all quay cranes, AGVs, ASCs, a landside job generator, a

time manager and an animation drawer), distributions and queues are created.

- Calls the procedure ‘writeToTextfile’ to write the inputs to a text file.

- Starts the simulation.

UtilizationCharts

(unit 6) CreateBatch

(unit 2)

BatchParameters

(unit 3)

AnimationLegend

(unit 4) InProgressMessage

(unit 5)

SingleSimulation

(unit 1)

Page 33: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

33

• Clicking the ‘interrupt’-button calls the procedure ‘BtnInterruptClick’ which interrupts the

simulation.

• Clicking the ‘resume’-button calls the procedure ‘BtnResumeClick’ which resumes the simulation.

• Clicking the ‘close’-button calls the procedure ‘BtnCloseClick’ which closes the simulation

program.

• Clicking the ‘show utilization charts’-button calls the procedure ‘ButtonShowChartsClick’ which

turns off the animation, enables the labels for the results and shows the form UtilizationCharts

(unit 6).

• Clicking the ‘create a batch of simulations’-button calls the procedure ‘ButtonCreateBatchClick’

which:

- Calls the procedure ‘CheckInputs’ to check the inputs, and will continue directly in case all

inputs are ok and saves the inputs in a text file. In case the input is not ok, a message asks

the user whether it would like to:

o either adjust the faulty inputs. In that case a message will indicate what is wrong and the

faulty input in the editbox will be selected for the user to see directly which input was

wrong.

o or continue without saving these inputs. In that case the inputs are not saved in the text

file.

- Shows the form CreateBatch (unit 2).

• Clicking on the ‘enable visualization’-checkbox calls the procedure ‘CheckBoxAnimationClick’

which interrupts or resumes the AnimationDrawer for the animation. Every time the

AnimationDrawer is started or resumed, the form AnimationLegend (unit 4) is shown. This form is

closed by the user or when the AnimationDrawer is interrupted.

• Clicking on the ‘delay simulation’-checkbox calls the procedure ‘CheckBoxDelaySimulationClick’

which enables or disables delaying the simulation and thereby the animation.

• Clicking on the ‘remember input values’-checkbox does not call any procedure, but is consulted to

determine whether or not the input values should be written in a text file.

• Moving the mouse pointer over one of the checkboxes, editboxes or the corresponding labels,

calls the procedure ‘Label(…)MouseEnter’ which gives information about this checkbox or editbox

on the top of the form. Moving the mouse pointer away from this afterwards, calls the procedure

‘LabelMouseLeave’ which clears the information.

UtilizationCharts (form6)

• Clicking the ‘zoom info’-button calls the procedure ‘ButtonZoomInfoClick’ which shows a message

with an explanation of how to zoom in and scroll through the charts.

• Clicking the ‘cancel’-button calls the procedure ‘ButtonCancelClick’ which closes the form.

• Clicking on the checkboxes next to the line chart calls the procedures ‘CheckBox(…)Click’ which

show or hide the corresponding lines in the line chart.

• Scrolling through the scrollbar under the line chart calls the procedure

‘ScrollBarLineChartChange’. This checks whether there is the data in the line chart is exceeding

the range of the horizontal axis. In that case the part of the line chart is displayed according to

the position of the scrollbar.

• Leaving the editbox for changing the range of the horizontal axis of the line chart, calls the

procedure ‘EditRangeLineChartExit’. This checks whether the value in the editbox is correct. In

case the input is not correct, then a message will indicate what is wrong and the input in the

editbox will be selected to force the user to enter a correct value. Otherwise the new range of

the horizontal axis is set and the procedure ‘ScrollBarLineChartChange’ is called to reset the line

chart.

Page 34: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

34

CreateBatch (Form2)

• When the form is activated the procedure ‘StartUpForm’ is called, which checks:

- Whether it should close the program because the form BatchParameters has been closed by

the user in other ways then clicking the ‘cancel’-button.

- Whether the form BatchParameters is still open. In that case it closes the form

BatchParameters by calling the procedure ‘ButtonCancelClick’ of the form BatchParameters.

- Whether it can find a text file with data from a previous session. In that case the ‘retrieve

last session’-button is enabled.

• Clicking the ‘retrieve last session’-button calls the procedure ‘ButtonRetrieveLastClick’, which

takes the data from text file from the last session (and thereby changes the combo-box).

• The combo box gives the user certain parameters to choose from. After a change it calls the

procedure ‘Box1Change’ which:

- Enables or disables all required labels and edit boxes, with help of the procedures

‘EnableSecondBlockMainParameter’ and ‘DisableSecondBlockMainParameter’.

- Calls the procedure ‘EditExit’ to recalculate the values of the last variables and update the

memo box.

• After filling an edit box (and actually leaving it), the procedure ‘EditExit’ is called, which:

- Calls the procedure ‘CheckInputs’ to check whether the user gave an acceptable input.

- Calls the procedures ‘CalculateLastValue1’ and ‘CalculateLastValue2’ to calculate the last

values of the main parameters according to the other inputs.

- Calls the procedure ‘FillMemo’ to update the memo box.

• Clicking the ‘continue’-button calls the procedure ‘ButtonContinueClick’ which:

- Calls the procedure ‘CheckInputs’ to check whether the inputs are acceptable13

.

- Saves the data in a text file for future sessions.

- Copies the data to the form BatchParameters (unit 3) and activates this form.

- Calls the procedure ‘FillMemo’ to update the memo box14

.

• Clicking the ‘cancel’-button calls the procedure ‘ButtonCancelClick’ which closes the form.

BatchParameters (Form3)

• When the form is activated, the procedure ‘FormActivate’ is called which:

- Checks whether the form was activated already with the same ‘main parameter to be varied’

to be able to continue with these data. If not, the procedure ‘initialize’ is called , which:

o Creates a new set of constants, if possible from a text file with input values from the form

SingleSimulation.

o Disables the labels and editboxes of the ‘main parameter to be varied’ which cannot be

further specified in this unit.

o Calls the procedure ‘SaveParametersSimulationCase’ to save the values of all parameters.

- Gives the correct names to the buttons, which are different in case no ‘main parameter to be

varied’ is chosen and all different simulations are being defined by the user itself.

- Calls the procedure ‘SetFormVisualization’ which:

o Enables or disables the required buttons, editboxes and labels, and presents the values for

all parameters, with help of the procedures ‘Checkbox(…)Click’.

o Calls the procedure ‘FillMemo’ to update the memo box.

• Clicking a checkbox to make a certain parameter a constant or a case-specific parameter, calls the

procedure ‘Checkbox(…)Click’, which:

- Calls the procedure ‘FillMemo’ to update the memo box.

- Enables, disables, shows or hides the corresponding labels and edit boxes.

- Displays the value of all parameters and thereby calls the procedure ‘EditExit’.

• After filling an edit box (and actually leaving it), the procedure ‘EditExit’ is called which:

- Calls the procedure ‘CheckInputs’ to check whether the user gave an acceptable input.

- Calls the procedures ‘SaveParametersSimulationCase’ to save all values.

- Calls the procedure ‘FillMemo’ to update the memo box.

13

This might seem unnecessary, but it is required to check input the user did not fill in the editboxes, thus

coming from a corrupt text file. It is questionable if this is important to include in the program. 14

This might seem unnecessary, but is required in case the user continues without defining a main parameter to

be varied. In that case the memobox has not been updated yet.

Page 35: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

35

• Clicking the ‘add case’-button calls the procedure ‘ButtonAddCaseClick’, which creates a new

simulationCase, copies the values for all parameters from the constants and calls the procedure

‘SetFormVisualization’ to set (disable, enable) all buttons, editboxes and labels.

• Clicking the ‘delete case’-button calls the procedure ‘ButtonDeleteCaseClick’, which deletes the

current simulationCase, changes the names off all subsequent simulationCases and calls the

procedure ‘SetFormVisualization’ to set (disable, enable) all buttons, editboxes and labels.

• Clicking the ‘previous’-button calls the procedure ‘ButtonPrevClick’, which switches to the

previous simulationCase and calls the procedure ‘SetFormVisualization’ to set (disable, enable) all

buttons, editboxes and labels.

• Clicking the ‘next’-button calls the procedure ‘ButtonNextClick’, which switches to the next

simulationCase and calls the procedure ‘SetFormVisualization’ to set (disable, enable) all buttons,

editboxes and labels.

• Clicking the ‘OK’-button calls the procedure ‘ButtonOKClick’ which:

- Checks whether at least one SimulationCase exists. Otherwise it automatically creates one

and stops this procedure.

- Calls the procedure ‘CheckMinMaxCycleTimes’ to check whether for all simulations the

minimum and maximum cycle times for AGVs and ASCs are correct. If not, a message

explains the user in what simulation it is not correct and this procedure is stopped.

- Creates a bat-file.

- Calls the procedure ‘WriteContentBatchToFile’ to write the content of all simulations of this

batch to a text file.

- Shows a message to instruct the user what to do and where to find the generated files.

• Clicking the ‘cancel’-button calls the procedure ‘ButtonCancelClick’ which closes the form.

InProgressMessage (Form5)

The unit InProgressMessage does not contain any procedures. It only gives the message: "simulation

in progress, please wait!" when a batch of simulations is running.

AnimationLegend (Form4)

The unit AnimationLegend contains one procedure ‘drawLegenda’, to draw the symbols as used in the

animation. These are drawed here by a procedure, so that similar code as used in the animation can

be used here and the animation can be adapted in case ‘AGVs on their way to a QC’ are not present in

the animation15

. This unit is activated every time the animation drawer is started.

15 The element ‘AGV on its way to a QC’ is only visible when the QC selection strategy ‘AGVs will select a quay

crane at the moment of departure from an ASC’ is chosen for the simulation.

Page 36: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

36

0

100

200

300

400

500

600

700

800

Exponential distribution of ship unload time

Appendix C: hand calculation for verification simul ation To verify if the simulation model does what it is supposed to, hand calculations are

used for experiments with 1 or 2 quay cranes and 2 or 4 AGVs. To clarify these hand

calculations, the calculation with 2 quay cranes, 4 AGVs and an AGV cycle time of 200

seconds is demonstrated in this appendix.

In the first place over 3300 samples of an exponential distribution with an average of

95 are taken. These represent the ‘ship unload time for the quay cranes’. The

distribution of these samples is shown in figure C.1. To these values 15 is added for

the constant ‘AGV load time’.

Then several calculations are done in the excel sheet in figure C.2. Every row in the sheet stands for one container. Therefore for every container:

• The column ‘QC selected’ checks which of the quay cranes can start first, based on the time they become ready. This QC is selected for this container.

• The column ‘AGV selected’ checks which of the AGVs can start first, based on the time they become ready. This AGV is selected for this container.

• If a QC is selected, the time it starts is the maximum of the time it became ready itself and the time the selected AGV becomes ready. It finishes and becomes ready

again after the cycle time, which is a sample of the distribution for the ‘ship unload time’ and ‘AGV load time’. • Then this AGV starts at the moment the selected QC has started, finished after its cycle time and becomes ready for a new container.

This is done for over 3300 containers. Then the total amount containers divided by the total time of the hand calculation gives performance of the

terminal [cnr/hour]. In the example in figure C.2 this would be (38*3600/2361) 57.9 containers/hour.

Figure C.1: Exponential distribution of the ship unload time

Page 37: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

37

Figure C.2: hand calculations for the simulation with 2 quay cranes, 4 AGVs and an AGV cycle time of 200 seconds

Page 38: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

38

Appendix D: the results of the experiments describe d in the book

In this appendix, the results of the simulation program for the experiments described in the

book will be presented. First a brief description of the experiments and assumptions in the

book is shown, identical to the description in the report. Then for all sets of experiments, the

results of the simulation program are presented in both a table and a chart, together with

the required values for the input parameters.

Brief description of the experiments in the book

The book describes three sets of experiments and discusses their results to determine an

indication of the maximum (average) cycle times for the AGVs and ASCs, given the intended

results of the system. All experiments have a simulated period of 100 consecutive net

operational hours, after an initial hour to start operations. The intended results of the

system are a sea-side productivity of 260 containers/NOH with eight quay cranes and 240

containers /NOH with six quay cranes.

� The first set of experiments is meant to provide an indication of the maximum (average)

cycle times for the AGVs. Therefore the cycle time of the ASCs and the time for an ASC to

unload a container (transfer time) are set to zero.

� In the second set of experiments also the cycle time of the ASCs and the time for an ASC

to unload a container (transfer time) are considered.

� In the third set of experiments, the effects of different quay crane and ASC selection

strategies are examined for chosen AGV and ASC cycle times.

Assumptions for the experiments in the book:

• The simulation runtime of each experiment will be 100 consecutive (net operational)

hours.

• The start-up time of each experiment will be 1 hour.

• The experiments will be carried out for both 6 and 8 quay cranes.

• 48 AGVs will be available.

• 25 ASCs will be available.

• The average QC cycle time for unloading a ship will be 95 seconds in case eight quay

cranes are operational and 75 seconds in case six quay cranes are operational.

• A quay crane will load an AGV in 15 seconds.

• An ASC will unload an AGV in 15 seconds.

• For the first and second set of experiments, both AGVs and land-side jobs select an ASC

according a uniform distribution (ASC selection alternative 1).

• For the first and second set of experiments, AGVs do not select a quay crane at all. They

are assumed to arrive in a large pool of waiting AGVs, where each quay crane can select

an AGV instantaneously (QC selection alternative 1).

It is remarkable that the intended performance of the terminal with 6 quay cranes (240

cnr/hr) is equal to the maximum capacity of 6 quay cranes (240.0 cnr/hr), while the

intended performance of the terminal with 8 quay cranes (260 cnr/hr) is below to the

maximum capacity of 8 quay cranes (261.8 cnr/hr):

3600

75 + 15∗ 6 = 240.0���/ℎ�(���6����������)

3600

95 + 15∗ 8 = 261.8���/ℎ�(���8����������)

Page 39: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

39

First set of experiments

Table D.3: The results of the first set of experiments in the book [containers/hour]

Figure D.4: The results of the first set of experiments in the book

AGV cycletime

8 QC operation

(target 260 cnr/hr)

6 QC operation

(target 240 cnr/hr)

300 260,5 239,6

360 260,5 239,6

420 260,5 239,6

480 260,3 239,6

540 258,6 239,3

600 253,6 237,3

660 243,9 232,2

Page 40: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

40

run

tim

e

sta

rtu

p t

ime

nr

of

QC

s

ship

un

loa

d t

ime

fo

r Q

C

AG

V l

oa

d t

ime

fo

r Q

C

nr

of

AG

Vs

min

imu

m A

GV

cy

cle

tim

e

ma

xim

um

AG

V c

ycl

e t

ime

nr

of

AS

Cs

min

imu

m A

SC

cy

cle

tim

e

ma

xim

um

AS

C c

ycl

e t

ime

AG

V u

nlo

ad

tie

m f

or

AS

C

AS

C s

ele

ctio

n s

tra

teg

y

QC

se

lect

ion

str

ate

gy

100 1 8 95 15 48 300 300 25 0 0 0 1 1

100 1 8 95 15 48 360 360 25 0 0 0 1 1

100 1 8 95 15 48 420 420 25 0 0 0 1 1

100 1 8 95 15 48 480 480 25 0 0 0 1 1

100 1 8 95 15 48 540 540 25 0 0 0 1 1

100 1 8 95 15 48 600 600 25 0 0 0 1 1

100 1 8 95 15 48 660 660 25 0 0 0 1 1

100 1 6 75 15 48 300 300 25 0 0 0 1 1

100 1 6 75 15 48 360 360 25 0 0 0 1 1

100 1 6 75 15 48 420 420 25 0 0 0 1 1

100 1 6 75 15 48 480 480 25 0 0 0 1 1

100 1 6 75 15 48 540 540 25 0 0 0 1 1

100 1 6 75 15 48 600 600 25 0 0 0 1 1

100 1 6 75 15 48 660 660 25 0 0 0 1 1

Table D.2: The input parameters for the first set of experiments in the book

Second set of experiments

6 QC

ASC cycletime

AGV cycle time

= 480 sec

AGV cycle time

= 420 sec

AGV cycle time

= 360 sec

60 239,6 239,6 239,6

120 238,6 239,6 239,6

180 232,0 236,6 239,0

240 209,7 218,5 225,2

Table D.5: The results of the second set of experiments in the book [containers/hour] for 6 quay cranes

Page 41: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

41

8 QC

ASC cycletime

AGV cycle time

= 480 sec

AGV cycle time

= 420 sec

AGV cycle time

= 360 sec

60 259,9 260,5 260,5

120 256,6 259,8 260,4

180 242,3 251,3 256,8

240 212,9 222,4 231,8

Table D.6: The results of the second set of experiments in the book [containers/hour] for 8 quay cranes

Figure D.2: The results of the second set of experiments in the book for 6 quay cranes

Figure D.3: The results of the second set of experiments in the book for 8 quay cranes

Page 42: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

42

run

tim

e

sta

rtu

p t

ime

nr

of

QC

s

ship

un

loa

d t

ime

fo

r Q

C

AG

V l

oa

d t

ime

fo

r Q

C

nr

of

AG

Vs

min

imu

m A

GV

cy

cle

tim

e

ma

xim

um

AG

V c

ycl

e t

ime

nr

of

AS

Cs

min

imu

m A

SC

cy

cle

tim

e

ma

xim

um

AS

C c

ycl

e t

ime

AG

V u

nlo

ad

tie

m f

or

AS

C

AS

C s

ele

ctio

n s

tra

teg

y

QC

se

lect

ion

str

ate

gy

100 1 6 75 15 48 480 480 25 60 60 15 1 1

100 1 6 75 15 48 480 480 25 120 120 15 1 1

100 1 6 75 15 48 480 480 25 180 180 15 1 1

100 1 6 75 15 48 480 480 25 240 240 15 1 1

100 1 6 75 15 48 420 420 25 60 60 15 1 1

100 1 6 75 15 48 420 420 25 120 120 15 1 1

100 1 6 75 15 48 420 420 25 180 180 15 1 1

100 1 6 75 15 48 420 420 25 240 240 15 1 1

100 1 6 75 15 48 360 360 25 60 60 15 1 1

100 1 6 75 15 48 360 360 25 120 120 15 1 1

100 1 6 75 15 48 360 360 25 180 180 15 1 1

100 1 6 75 15 48 360 360 25 240 240 15 1 1

100 1 8 95 15 48 480 480 25 60 60 15 1 1

100 1 8 95 15 48 480 480 25 120 120 15 1 1

100 1 8 95 15 48 480 480 25 180 180 15 1 1

100 1 8 95 15 48 480 480 25 240 240 15 1 1

100 1 8 95 15 48 420 420 25 60 60 15 1 1

100 1 8 95 15 48 420 420 25 120 120 15 1 1

100 1 8 95 15 48 420 420 25 180 180 15 1 1

100 1 8 95 15 48 420 420 25 240 240 15 1 1

100 1 8 95 15 48 360 360 25 60 60 15 1 1

100 1 8 95 15 48 360 360 25 120 120 15 1 1

100 1 8 95 15 48 360 360 25 180 180 15 1 1

100 1 8 95 15 48 360 360 25 240 240 15 1 1

Table D.7: The input parameters for the second set of experiments in the book

Page 43: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

43

Third set of experiments

strategy

8 QC operation

AGV cycle time = 360 sec

ASC cycle time = 180 sec

6 QC operation

AGV cycle time = 360 sec

ASC cycle time = 180 sec

A1 256,8 239

A2 253,5 237,8

A3 243,4 232,9

Table D.8: The results of the third set of experiments in the book [containers/hour] for QC selection strategies

strategy

8 QC operation

AGV cycle time = 360 sec

ASC cycle time = 180 sec

6 QC operation

AGV cycle time = 360 sec

ASC cycle time = 180 sec

B1 260,5 239,6

B2 260 239,6

B3 254,9 238,3

Table D.9: The results of the third set of experiments in the book [containers/hour] for QC and ASC selection strategies

Figure D.4: The results of the third set of experiments in the book for QC selection strategies

Page 44: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

44

Figure D.5: The results of the third set of experiments in the book for QC and ASC selection strategies

run

tim

e

sta

rtu

p t

ime

nr

of

QC

s

ship

un

loa

d t

ime

fo

r Q

C

AG

V l

oa

d t

ime

fo

r Q

C

nr

of

AG

Vs

min

imu

m A

GV

cy

cle

tim

e

ma

xim

um

AG

V c

ycl

e t

ime

nr

of

AS

Cs

min

imu

m A

SC

cy

cle

tim

e

ma

xim

um

AS

C c

ycl

e t

ime

AG

V u

nlo

ad

tie

m f

or

AS

C

AS

C s

ele

ctio

n s

tra

teg

y

QC

se

lect

ion

str

ate

gy

100 1 8 95 15 48 360 360 25 180 180 15 1 1

100 1 8 95 15 48 360 360 25 180 180 15 1 2

100 1 8 95 15 48 360 360 25 180 180 15 1 3

100 1 6 75 15 48 360 360 25 180 180 15 1 1

100 1 6 75 15 48 360 360 25 180 180 15 1 2

100 1 6 75 15 48 360 360 25 180 180 15 1 3

100 1 8 95 15 48 360 360 25 180 180 15 2 1

100 1 8 95 15 48 360 360 25 180 180 15 2 2

100 1 8 95 15 48 360 360 25 180 180 15 2 3

100 1 6 75 15 48 360 360 25 180 180 15 2 1

100 1 6 75 15 48 360 360 25 180 180 15 2 2

100 1 6 75 15 48 360 360 25 180 180 15 2 3

Table D.10: The input parameters for the third set of experiments in the book

Page 45: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

45

Appendix E: The programming code This appendix contains the programming code of the main 4 units of the simulation program.

Index of procedures

unit SingleSimulation; 47

Functions & Supporting Procedures function selectQuayCrane ................................................................................................................................... 49 function selectAsc ................................................................................................................................................ 49 procedure writeToExcel ....................................................................................................................................... 50 procedure writeToTextfile ................................................................................................................................... 51 procedure updateResults .................................................................................................................................... 51 procedure checkInputs ........................................................................................................................................ 51

Chart Related Procedures procedure setAgvCharts ...................................................................................................................................... 55 procedure setQcCharts ........................................................................................................................................ 55 procedure setAscCharts ....................................................................................................................................... 56 procedure setCharts ............................................................................................................................................ 57 procedure resetChartData ................................................................................................................................... 57

Initialization procedure InitializeSystem .................................................................................................................................. 57 procedure CheckForBatchOfSimulations ............................................................................................................. 59

Processes procedure TQuayCrane.process .......................................................................................................................... 60 procedure TAgv.process ...................................................................................................................................... 60 procedure TAsc.process ....................................................................................................................................... 61 procedure TLandsideJobGenerator.process ........................................................................................................ 61 procedure TTimeManager.process ...................................................................................................................... 62 procedure TAnimationDrawer.process ................................................................................................................ 62

User Interface procedure TForm1.BtnStartClick ......................................................................................................................... 66 procedure TForm1.BtnInterruptClick .................................................................................................................. 66 procedure TForm1.BtnResumeClick .................................................................................................................... 66 procedure TForm1.BtnCloseClick ........................................................................................................................ 66 procedure TForm1.ButtonShowChartsClick ........................................................................................................ 66 procedure TForm1.ButtonCreateBatchClick ........................................................................................................ 67 procedure TForm1.CheckBoxAnimationClick ...................................................................................................... 67 procedure TForm1.CheckBoxDelaySimulationClick ............................................................................................. 67 procedure TForm1.FormActivate ........................................................................................................................ 68 procedure TForm1.FormCreate ........................................................................................................................... 68 procedure TForm1.CheckBoxAnimationMouseEnter .......................................................................................... 68 procedure TForm1.CheckBoxDelaySimulationMouseEnter ................................................................................. 68 procedure TForm1.CheckBoxRememberInputMouseEnter ................................................................................ 68 procedure TForm1.LabelRuntimeMouseEnter .................................................................................................... 69 procedure TForm1.LabelNrQcMouseEnter ......................................................................................................... 69 procedure TForm1.LabelShipUnloadtimeQcMouseEnter .................................................................................... 69 procedure TForm1.LabelAgvLoadtimeQcMouseEnter ........................................................................................ 69 procedure TForm1.LabelNrAgvMouseEnter ........................................................................................................ 69 procedure TForm1.LabelMinMaxAgvCysleTimeMouseEnter .............................................................................. 69 procedure TForm1.LabelNrAscMouseEnter ........................................................................................................ 69 procedure TForm1.LabelMinMaxAscCysleTimeMouseEnter ............................................................................... 69 procedure TForm1.LabelAgvLoadtimeAscMouseEnter ....................................................................................... 69 procedure TForm1.LabelMouseLeave ................................................................................................................. 69 Initialization ......................................................................................................................................................... 69

Page 46: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

46

Unit UtilizationCharts; 70

procedure TForm6.setResults .............................................................................................................................. 71 procedure TForm6.setFormForSimulationStartUp .............................................................................................. 71 procedure TForm6.resetResultsAfterSimulationStartup ..................................................................................... 72 procedure TForm6.ScrollBarLineChartChange .................................................................................................... 72 procedure TForm6.EditRangeLineChartExit......................................................................................................... 73 procedure TForm6.FormCreate ........................................................................................................................... 73 procedure TForm6.CheckBoxUtilAgvClick ........................................................................................................... 73 procedure TForm6.CheckBoxWaitAgvClick ......................................................................................................... 73 procedure TForm6.CheckBoxUtilQcClick ............................................................................................................. 73 procedure TForm6.CheckBoxUtilAscClick ............................................................................................................ 73 procedure TForm6.ButtonZoomInfoClick ............................................................................................................ 73 procedure TForm6.ButtonCancelClick ................................................................................................................. 73

unit CreateBatch; 74

Functions & Supporting Procedures

procedure EnableSecondBlockMainParameter ................................................................................................... 74 procedure DisableSecondBlockMainParameter .................................................................................................. 75 procedure calculateLastValue1............................................................................................................................ 75 procedure calculateLastValue2............................................................................................................................ 75 procedure fillMemo ............................................................................................................................................. 75 procedure checkInputs ........................................................................................................................................ 76

User Interface procedure TForm2.EditExit .................................................................................................................................. 77 procedure TForm2.Box1Change .......................................................................................................................... 78 procedure TForm2.ButtonCancelClick ................................................................................................................. 78 procedure TForm2.ButtonContinueClick ............................................................................................................. 78 procedure TForm2.ButtonRetrieveLastClick ........................................................................................................ 80 procedure TForm2.startUpForm ......................................................................................................................... 80

unit BatchParameters; 81

procedure fillMemo ............................................................................................................................................. 82 procedure WriteContentBatchToFile ................................................................................................................... 84 procedure TForm3.CheckBox1Click ..................................................................................................................... 85 procedure TForm3.CheckBox2Click ..................................................................................................................... 85 procedure TForm3.CheckBox3Click ..................................................................................................................... 86 procedure TForm3.CheckBox4Click ..................................................................................................................... 87 procedure TForm3.CheckBox5Click ..................................................................................................................... 87 procedure TForm3.CheckBox6Click ..................................................................................................................... 88 procedure TForm3.CheckBox7Click ..................................................................................................................... 88 procedure TForm3.CheckBox8Click ..................................................................................................................... 89 procedure TForm3.CheckBox9Click ..................................................................................................................... 89 procedure TForm3.CheckBox10Click ................................................................................................................... 90 procedure TForm3.CheckBox11Click ................................................................................................................... 90 procedure TForm3.CheckBox12Click ................................................................................................................... 90 procedure setFormVisualization .......................................................................................................................... 91 procedure checkMinMaxCycleTimes ................................................................................................................... 92 procedure checkInputs ........................................................................................................................................ 93 procedure saveParametersSimulationCase ......................................................................................................... 97 procedure TForm3.ButtonAddCaseClick .............................................................................................................. 98 procedure TForm3.ButtonOKClick ....................................................................................................................... 98 procedure TForm3.ButtonCancelClick ............................................................................................................... 100 procedure TForm3.ButtonDeleteCaseClick ....................................................................................................... 100 procedure TForm3.ButtonNextClick .................................................................................................................. 100 procedure TForm3.ButtonPrevClick .................................................................................................................. 100 procedure initialize ............................................................................................................................................ 100 procedure TForm3.FormActivate ...................................................................................................................... 102 procedure TForm3.EditExit ................................................................................................................................ 102

Page 47: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

47

unit SingleSimulation;

interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Tomas, StdCtrls, ExtCtrls, MaTh, ComObj; type TForm1 = class(TForm) procedure BtnCloseClick(Sender: TObject); procedure BtnInterruptClick(Sender: TObject); procedure BtnResumeClick(Sender: TObject); procedure BtnStartClick(Sender: TObject); procedure ButtonCreateBatchClick(Sender: TObject); procedure ButtonShowChartsClick(Sender: TObject); procedure CheckBoxAnimationClick(Sender: TObject); procedure CheckBoxAnimationMouseEnter(Sender: TObject); procedure CheckBoxDelaySimulationClick(Sender: TObject); procedure CheckBoxDelaySimulationMouseEnter(Sender: TObject); procedure CheckBoxRememberInputMouseEnter(Sender: TObject); procedure FormActivate(Sender: TObject); procedure FormCreate(Sender: TObject); procedure LabelAgvLoadtimeAscMouseEnter(Sender: TObject); procedure LabelAgvLoadtimeQcMouseEnter(Sender: TObject); procedure LabelMinMaxAgvCysleTimeMouseEnter(Sender: TObject); procedure LabelMinMaxAscCysleTimeMouseEnter(Sender: TObject); procedure LabelMouseLeave(Sender: TObject); procedure LabelNrAgvMouseEnter(Sender: TObject); procedure LabelNrAscMouseEnter(Sender: TObject); procedure LabelNrQcMouseEnter(Sender: TObject); procedure LabelRuntimeMouseEnter(Sender: TObject); procedure LabelShipUnloadTimeQcMouseEnter(Sender: TObject); private { Private declarations } public { Public declarations } end; TQuayCrane = class(TomasElement) public agvQueue : TomasQueue; agvOnItsWayQueue : TomasQueue; published procedure process; reintroduce; end; TAgv = class(TomasElement) public statusIdle : Boolean; statusWaiting : Boolean; published procedure process; reintroduce; end; TAsc = class(TomasElement) public agvQueue : TomasQueue; landsideQueue : TomasQueue; published procedure process; reintroduce; end; TLandsideJobGenerator = class(TomasElement) public published procedure process; reintroduce; end; TLandsideJob = class(TomasElement) public published end; TTimeManager = class(TomasElement) public published procedure process; reintroduce; end; TAnimationDrawer = class(TomasElement) public

Page 48: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

48

enableAnimation: Boolean; published procedure process; reintroduce; end; var Form1 : TForm1; quayCraneQueue : TomasQueue; generalAgvQueue : TomasQueue; agvsAtQuayCranesQueue : TomasQueue; ascQueue : TomasQueue; animationDrawerQueue : TomasQueue; quayCraneUnloadTimeDistribution : TExponentialDistribution; agvCycleTimeDistribution : TUniformDistribution; ascCycleTimeDistribution : TUniformDistribution; ascSelectionDistribution : TUniformDistribution; simulationStarted : Boolean; //used to make sure the program won't crash when the user clicks

immidiately (during the initialization) on the Close button, before TNow > 0.

batchSimulation : Boolean; //used to let the program pass over several precedures undesirable for a fast simulation.

inputOK1 : Boolean; //used to indicate the input-values are OK. seasideProduction : Integer; //the result [number of containers] simulationtime : Double; //the time the simulation is running at a certain moment //input parameters runtime : Double; //the total runtime of the simulation startuptime : Double; numberOfQuayCranes : Integer; numberOfAgvs : Integer; numberOfAscs : Integer; agvLoadTimeForQc : Double; agvUnloadTimeForAsc : Double; ascSelectionForAgv : Integer; {0,1} {unchecked,checked} {no selection based on workload ASCs,

indeed selection based on workload ASCs} qcSelectionForAgv : Integer; {1,2,3} {radiobutton 1,2,3} {central pool for AGVs, QC-selection

at arrival QC-area, QC-selection at departure ASC} //chart parameters lastTimeAgvChart : Double; lastValueAgvLineChart : Double; lastValueAgvWaitingLineChart : Double; lastValueAgvBarChart : Integer; lastTimeQcChart : Double; lastValueQcLineChart : Double; lastValueQcBarChart : Integer; lastTimeAscChart : Double; lastValueAscLineChart : Double; lastValueAscBarChart : Integer; utilizationArrayAgv : Array of Double; utilizationArrayQc : Array of Double; utilizationArrayAsc : Array of Double;

Page 49: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

49

implementation uses CreateBatch, AnimationLegenda, InProgressMessage, UtilizationCharts;

(******************************************************************************) (***** Functions & Supporting Procedures *****) (******************************************************************************)

function selectQuayCrane : Integer;

//function to determine to which QuayCrane the AGV will go. var myQuayCrane : TQuayCrane; i : Integer; minQueueLenght : Double; QcCurrentlyOperating : Double; begin //set the Queuelenght of the first QC as minimum. myQuayCrane := quayCraneQueue.FirstElement; if myQuayCrane.StatusToString = 'Passive' then QcCurrentlyOperating := 0 else QcCurrentlyOperating := 1/2;

//to pretent that an QC that's operating at this moment, has 1/2 extra job in it's Queue. minQueueLenght := myQuayCrane.agvQueue.Length + myQuayCrane.agvOnItsWayQueue.Length + QcCurrentlyOperating; selectQuayCrane := 0; //see if the Queuelenght of another QC is shorter and in that case, select this quay crane and adjust the

minimum queuelength. for i := 0 to quayCraneQueue.Length - 1 do begin myQuayCrane := quayCraneQueue.Element(i); if myQuayCrane.StatusToString = 'Passive' then QcCurrentlyOperating := 0 else QcCurrentlyOperating := 1/2;

//pretent that an QC that's operating at this moment, has 0.5 extra job in it's Queue if myQuayCrane.agvQueue.Length + myQuayCrane.agvOnItsWayQueue.Length + QcCurrentlyOperating <

minQueueLenght then begin minQueueLenght := myQuayCrane.agvQueue.Length + myQuayCrane.agvOnItsWayQueue.Length + QcCurrentlyOperating; selectQuayCrane := i; end; end; end;

function selectAsc : Integer;

//function to determine to which ASC the AGV of landside job will go. var myAsc : TAsc; i : Integer; minQueueLenght : Double; randomAsc : Double; AgvCurrentlyOperating : Double; begin if ascSelectionForAgv = 1 then begin //set the Queuelenght of the first ASC as minimum. myAsc := ascQueue.FirstElement; if myAsc.StatusToString = 'Passive' then AgvCurrentlyOperating := 0 else AgvCurrentlyOperating := 1/2;

//pretent that an ASC that's operating at this moment, has 0.5 extra job in it's Queue minQueueLenght := myAsc.agvQueue.Length + myAsc.landsideQueue.Length + AgvCurrentlyOperating; selectAsc := 0; //see if the Queuelenght of another ASC is shorter and in that case, select this ASC and adjust the minimum

queuelength. for i := 0 to ascQueue.Length - 1 do begin myAsc := ascQueue.Element(i); if myAsc.StatusToString = 'Passive' then AgvCurrentlyOperating := 0 else AgvCurrentlyOperating := 1/2;

//pretent that an ASC that's operating at this moment, has 0.5 extra job in it's Queue if myAsc.agvQueue.Length + myAsc.landsideQueue.Length + AgvCurrentlyOperating< minQueueLenght then begin minQueueLenght := myAsc.agvQueue.Length + myAsc.landsideQueue.Length + AgvCurrentlyOperating; selectAsc := i; end; end; end else begin //random selection of an ASC according to a uniform distribution. randomAsc := ascSelectionDistribution.Sample; selectAsc := trunc(randomAsc); end; end;

Page 50: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

50

procedure writeToExcel ;

//procedure to write the results of a batch of simulations to an excel- and to a //text-file. var XLApp,XLBook : Variant; excelAvailable : Boolean; myFile : TextFile; simcase,simulation : Integer; textCase,textSimul,textResult : String; begin //set parameters and calculate results simcase := StrToInt(ParamStr(2)); simulation := StrToInt(ParamStr(3)); textCase := 'Case ' + IntToStr(simcase) + ':'; textSimul := 'Simulation ' + IntToStr(simulation) + ':'; simulationtime := round(TNow)-startuptime; textResult := FloatToStr(round(SeasideProduction/simulationtime*3600*10)/10); excelAvailable := True; //create/open excel and text-files to write the results if (simcase = 1) and (simulation = 1) then begin try //try if excel is available on this computer XLApp := CreateOleObject('Excel.Application'); except excelAvailable := False; end; //write results to text-file AssignFile(myFile, 'Results batch of simulations.txt'); ReWrite(myFile); WriteLn(myFile, 'Simulation results: Sea side production [cnr/hour]'); WriteLn(myFile, ''); CloseFile(myFile); end; try XLApp := GetActiveOleObject('Excel.Application'); XLApp.application.Visible := True; except excelAvailable := False; end; //write results to excel-file if excelAvailable = True then begin if (simcase = 1) and (simulation = 1) then begin XLApp.Application.SheetsInNewWorkbook := 1; XLBook := XLApp.Workbooks.Add; XLApp.ActiveSheet.Columns.Columns[1].Columnwidth := 15; XLApp.ActiveSheet.Name := 'Simulation Results'; XLApp.ActiveSheet.cells[1,1].Font.Size := 15; XLApp.ActiveSheet.Columns.Columns[1].Font.Bold := True; XLApp.ActiveSheet.Rows.Rows[3].Font.Bold := True; XLApp.ActiveSheet.cells[1,1] := 'Simulation results: Sea side production [cnr/hour]'; end; try //try if excel is accesable at the moment XLApp.ActiveSheet.cells[3,simcase+1] := textCase; XLApp.ActiveSheet.cells[simulation+3,1] := textSimul; XLApp.ActiveSheet.cells[simulation+3,simcase+1] := textResult; except showmessage('The program is unable to write the results of this simulation in excel.'); //to attend the

user he probably did something on the computer he shouldn't do. end; end; //write results to text-file AssignFile(myFile, 'Results batch of simulations.txt'); Append(myFile); WriteLn(myFile, textCase + ' ' + textSimul + ' ' + textResult + ' cnr/hour'); CloseFile(myFile); end;

Page 51: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

51

procedure writeToTextfile ;

//procedure to write the current input and settings to a text-file. var myFile : TextFile; a : Integer; begin if Form1.CheckBoxRememberInput.Checked = True then begin AssignFile(myFile, 'Input1.txt'); ReWrite(myFile); WriteLn(myFile, (Form1.EditRuntime.Text)); WriteLn(myFile, (Form1.EditStartupTime.Text)); WriteLn(myFile, (Form1.EditNrQc.Text)); WriteLn(myFile, (Form1.EditShipUnloadtimeQc.Text)); WriteLn(myFile, (Form1.EditAgvLoadtimeQc.Text)); WriteLn(myFile, (Form1.EditNrAgv.Text)); WriteLn(myFile, (Form1.EditMinAgvCycleTime.Text)); WriteLn(myFile, (Form1.EditMaxAgvCycleTime.Text)); WriteLn(myFile, (Form1.EditNrAsc.Text)); WriteLn(myFile, (Form1.EditMinAscCycleTime.Text)); WriteLn(myFile, (Form1.EditMaxAscCycleTime.Text)); WriteLn(myFile, (Form1.EditAgvLoadtimeAsc.Text)); WriteLn(myFile, IntToStr(ascSelectionForAgv)); WriteLn(myFile, IntToStr(qcSelectionForAgv)); if Form1.CheckBoxAnimation.Checked then a := 1 else a := 0; WriteLn(myFile, IntToStr(a)); if Form1.CheckBoxDelaySimulation.Checked then a := 1 else a := 0; WriteLn(myFile, IntToStr(a)); CloseFile(myFile); end; end;

procedure updateResults ;

//procedure to update the results on the main form. begin simulationtime := round(TNow-startuptime); Form1.LabelRuntime.Caption := FloatToStr(simulationtime); if simulationTime > 0 then begin Form1.LabelseasideProduction.Caption := IntToStr(SeasideProduction); Form1.LabelseasideProduction2.Caption := FloatToStr(round(SeasideProduction/simulationtime*3600)); end; end;

procedure checkInputs (CheckForCreateBatch: Boolean);

//procedure to chech whether the input in the editboxes is ok. if not then //indicate what's wrong and set the focus to that editbox, so the user can't //deny it. var A : Extended; noStringConversionErrors : Boolean; temp : String; begin inputOK1 := False; noStringConversionErrors := True; //Catch string conversion errors. try A := StrToFloat(Form1.EditAgvLoadtimeAsc.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form1.EditAgvLoadtimeAsc.SetFocus; end; end; try A := StrToFloat(Form1.EditMaxAscCycleTime.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form1.EditMaxAscCycleTime.SetFocus; end; end;

Page 52: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

52

try A := StrToFloat(Form1.EditMinAscCycleTime.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form1.EditMinAscCycleTime.SetFocus; end; end; try A := StrToFloat(Form1.EditNrAsc.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form1.EditNrAsc.SetFocus; end; end; try A := StrToFloat(Form1.EditMaxAgvCycleTime.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form1.EditMaxAgvCycleTime.SetFocus; end; end; try A := StrToFloat(Form1.EditMinAgvCycleTime.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form1.EditMinAgvCycleTime.SetFocus; end; end; try A := StrToFloat(Form1.EditNrAgv.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form1.EditNrAgv.SetFocus; end; end; try A := StrToFloat(Form1.EditAgvLoadtimeQc.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form1.EditAgvLoadtimeQc.SetFocus; end; end; try A := StrToFloat(Form1.EditShipUnloadtimeQc.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form1.EditShipUnloadtimeQc.SetFocus; end; end; try A := StrToFloat(Form1.EditNrQc.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form1.EditNrQc.SetFocus; end; end; try A := StrToFloat(Form1.EditStartupTime.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form1.EditStartupTime.SetFocus; end; end;

Page 53: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

53

try A := StrToFloat(Form1.EditRuntime.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form1.EditRuntime.SetFocus; end; end; //Catch non-integer values for number of elements if noStringConversionErrors = True then begin try A := StrToInt(Form1.EditNrQc.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; showmessage('The number of quay cranes should be an integer value.'); Form1.EditNrQc.SetFocus; end; end; end; if noStringConversionErrors = True then begin try A := StrToInt(Form1.EditNrAgv.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; showmessage('The number of AGVs should be an integer value.'); Form1.EditNrAgv.SetFocus; end; end; end; if noStringConversionErrors = True then begin try A := StrToInt(Form1.EditNrAsc.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; showmessage('The number of ASCs should be an integer value.'); Form1.EditNrAsc.SetFocus; end; end; end; //Catch negative values. if noStringConversionErrors = True then begin if StrToFloat(Form1.EditRuntime.Text) <= 0 then begin if CheckForCreateBatch = False then showmessage('The runtime of the simulation can not be zero or

negative.'); Form1.EditRuntime.SetFocus; end else if StrToFloat(Form1.EditStartupTime.Text) < 0 then begin if CheckForCreateBatch = False then showmessage('The intitial time to start up the simulation can not be

negative.'); Form1.EditStartupTime.SetFocus; end else if StrToInt(Form1.EditNrQc.Text) < 1 then begin if CheckForCreateBatch = False then showmessage('The number of quay cranes can not be zero or negative.'); Form1.EditNrQc.SetFocus; end else if StrToFloat(Form1.EditShipUnloadtimeQc.Text) < 0 then begin if CheckForCreateBatch = False then showmessage('The time a quay crane needs to unload a container from a

ship can not be negative.'); Form1.EditShipUnloadtimeQc.SetFocus; end else if StrToFloat(Form1.EditAgvLoadtimeQc.Text) < 0 then begin if CheckForCreateBatch = False then showmessage('The time a quay crane needs to load a container on an AGV

can not be negative.'); Form1.EditAgvLoadtimeQc.SetFocus; end else if StrToFloat(Form1.EditAgvLoadtimeAsc.Text) < 0 then begin if CheckForCreateBatch = False then showmessage('The time an ASC needs to unload a container from an AGV can

not be negative.'); Form1.EditAgvLoadtimeAsc.SetFocus; end

Page 54: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

54

else if StrToInt(Form1.EditNrAgv.Text) < 1 then begin if CheckForCreateBatch = False then showmessage('The number of AGVs can not be zero or negative.'); Form1.EditNrAgv.SetFocus; end else if StrToFloat(Form1.EditMinAgvCycleTime.Text) < StrToFloat(Form1.EditAgvLoadtimeQc.Text) +

StrToFloat(Form1.EditAgvLoadtimeAsc.Text) then begin if CheckForCreateBatch = False then showmessage('The total AGV cycle time includes the transfer times.

Therefore the minimum cycle time of an AGV can not be smaller then the sum of the AGV load time for QC and the AGV unload time for ASC.');

Form1.EditMinAgvCycleTime.SetFocus; end else if StrToFloat(Form1.EditMaxAgvCycleTime.Text) < StrToFloat(Form1.EditAgvLoadtimeQc.Text) +

StrToFloat(Form1.EditAgvLoadtimeAsc.Text) then begin if CheckForCreateBatch = False then showmessage('The total AGV cycle time includes the transfer times.

Therefore the maximum cycle time of an AGV can not be smaller then the sum of the AGV load time for QC and the AGV unload time for ASC.');

Form1.EditMaxAgvCycleTime.SetFocus; end else if StrToInt(Form1.EditNrAsc.Text) < 1 then begin if CheckForCreateBatch = False then showmessage('The number of ASCs can not be zero or negative.'); Form1.EditNrAsc.SetFocus; end else if StrToFloat(Form1.EditMinAscCycleTime.Text) < StrToFloat(Form1.EditAgvLoadtimeAsc.Text) then begin if CheckForCreateBatch = False then showmessage('The total ASC cycle time includes the transfer time.

Therefore the minimum cycle time of an ASC can not be smaller then the AGV unload time for ASC.'); Form1.EditMinAscCycleTime.SetFocus; end else if StrToFloat(Form1.EditMaxAscCycleTime.Text) < StrToFloat(Form1.EditAgvLoadtimeAsc.Text) then begin if CheckForCreateBatch = False then showmessage('The total ASC cycle time includes the transfer time.

Therefore the maximum cycle time of an ASC can not be smaller then the AGV unload time for ASC.'); Form1.EditMaxAscCycleTime.SetFocus; end else if (StrToFloat(Form1.EditShipUnloadtimeQc.Text) = 0) and (StrToFloat(Form1.EditAGVLoadtimeQc.Text) = 0)

and (StrToFloat(Form1.EditMinAgvCycleTime.Text) = 0) and (StrToFloat(Form1.EditMaxAgvCycleTime.Text) = 0) and (StrToFloat(Form1.EditMinAscCycleTime.Text) = 0) and (StrToFloat(Form1.EditMaxAscCycleTime.Text) = 0) and (StrToFloat(Form1.EditAgvLoadtimeAsc.Text) = 0) then begin

if CheckForCreateBatch = False then begin showmessage('Not all time consuming parameters can be zero at once.'); Form1.EditShipUnloadtimeQc.SetFocus; Sleep(30); Form1.EditAgvLoadtimeQc.SetFocus; Sleep(30); Form1.EditMinAgvCycleTime.SetFocus; Sleep(30); Form1.EditMaxAgvCycleTime.SetFocus; Sleep(30); Form1.EditMinAscCycleTime.SetFocus; Sleep(30); Form1.EditMaxAscCycleTime.SetFocus; Sleep(30); Form1.EditAgvLoadtimeAsc.SetFocus; Sleep(800); end; Form1.EditAgvLoadtimeAsc.SetFocus; end else begin //change min and max values if max < min. if StrToFloat(Form1.EditMaxAgvCycleTime.Text) < StrToFloat(Form1.EditMinAgvCycleTime.Text) then begin temp := Form1.EditMaxAgvCycleTime.Text; Form1.EditMaxAgvCycleTime.Text := Form1.EditMinAgvCycleTime.Text; Form1.EditMinAgvCycleTime.Text := temp; end; if StrToFloat(Form1.EditMaxAscCycleTime.Text) < StrToFloat(Form1.EditMinAscCycleTime.Text) then begin temp := Form1.EditMaxAscCycleTime.Text; Form1.EditMaxAscCycleTime.Text := Form1.EditMinAscCycleTime.Text; Form1.EditMinAscCycleTime.Text := temp; end; //indicate the input is OK. inputOK1 := True; end; end; end;

Page 55: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

55

(******************************************************************************) (***** Chart Related Procedures *****) (******************************************************************************)

procedure setAgvCharts ;

var i,operatingAGVs,waitingAGVs : Integer; myAgv : TAgv; begin //determine the amount of operating AGVs operatingAGVs := 0; waitingAGVs := 0; for i := 0 to numberOfAgvs - 1 do begin myAgv := generalAgvQueue.Element(i); if myAgv.statusIdle = False then operatingAGVs := operatingAGVs + 1; if myAgv.statusWaiting = True then waitingAGVs := waitingAGVs + 1; end; //place the points in the utilization LineChart if (lastTimeAgvChart = TNow-startupTime) and (lastTimeAgvChart <> 0) then begin

//if the last point was set on the same time Form6.UtilizationLineChart.Series[0].Delete(Form6.UtilizationLineChart.Series[0].count - 1);

//then remove the last point Form6.UtilizationLineChart.Series[1].Delete(Form6.UtilizationLineChart.Series[1].count - 1); end else begin Form6.UtilizationLineChart.Series[0].AddXY(TNow-startupTime, lastValueAgvLineChart, '', clred);

//else place a point at the last amount Form6.UtilizationLineChart.Series[1].AddXY(TNow-startupTime, lastValueAgvWaitingLineChart, '', clOlive); end; Form6.UtilizationLineChart.Series[0].AddXY(TNow-startupTime, operatingAGVs/numberOfAgvs*100, '', clred);

//place a point at the current amount Form6.UtilizationLineChart.Series[1].AddXY(TNow-startupTime, waitingAGVs/numberOfAgvs*100, '', clOlive); if lastTimeAgvChart < TNow-startupTime then begin //update the AGV utilization BarChart utilizationArrayAgv[lastValueAgvBarChart]:= utilizationArrayAgv[lastValueAgvBarChart] + TNow - startupTime

– lastTimeAgvChart; if (TNow > startupTime) and (form6.Visible) then begin for i := 0 to Form6.UtilizationBarChartAgv.Series[0].Count - 1 do begin Form6.UtilizationBarChartAgv.Series[0].Delete(i); Form6.UtilizationBarChartAgv.Series[0].AddXY(i, utilizationArrayAgv[i]/(Tnow - startupTime)*100, '', clred); end; end; if TNow > startupTime then begin if lastValueAgvBarChart < Form6.minimumUtilizationAgv then Form6.minimumUtilizationAgv := lastValueAgvBarChart; if lastValueAgvBarChart > Form6.maximumUtilizationAgv then Form6.maximumUtilizationAgv := lastValueAgvBarChart; Form6.averageUtilizationAgv := (Form6.averageUtilizationAgv*(lastTimeAgvChart)+

lastValueAgvBarChart*(TNow - lastTimeAgvChart - startupTime))/(TNow-startupTime); end; end; lastValueAgvLineChart := operatingAGVs/numberOfAgvs*100; lastValueAgvWaitingLineChart := waitingAGVs/numberOfAgvs*100; lastValueAgvBarChart := operatingAGVs; lastTimeAgvChart := TNow-startupTime; end;

procedure setQcCharts (QcSuspendingNow:integer);

var i,operatingQCs : Integer; myQc : TQuayCrane; begin //determine the amount of operating QCs operatingQCs := 0; for i := 0 to numberOfQuayCranes - 1 do begin myQc := quayCraneQueue.Element(i); if myQc.StatusToString <> 'Passive' then operatingQCs := operatingQCs + 1; end; operatingQCs := operatingQCs - QcSuspendingNow; //place the points in the utilization LineChart if (lastTimeQcChart = TNow-startupTime) and (lastTimeQcChart <> 0) then begin

//if the last point was set on the same time Form6.UtilizationLineChart.Series[2].Delete(Form6.UtilizationLineChart.Series[2].count - 1); end else begin Form6.UtilizationLineChart.Series[2].AddXY(TNow-startupTime, lastValueQcLineChart, '', clgreen); end;

Page 56: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

56

Form6.UtilizationLineChart.Series[2].AddXY(TNow-startupTime, operatingQCs/numberOfQuayCranes*100, '', clgreen); if lastTimeQcChart < TNow-startupTime then begin //update the QC utilization BarChart utilizationArrayQc[lastValueQcBarChart]:= utilizationArrayQc[lastValueQcBarChart] + TNow - startupTime –

lastTimeQcChart; if (TNow > startupTime) and (form6.Visible) then begin for i := 0 to Form6.UtilizationBarChartQuayCrane.Series[0].Count - 1 do begin Form6.UtilizationBarChartQuayCrane.Series[0].Delete(i); Form6.UtilizationBarChartQuayCrane.Series[0].AddXY(i, utilizationArrayQc[i]/(Tnow - startupTime)*100,

'', clgreen); end; end; //set values Form6 if TNow > startupTime then begin if lastValueQcBarChart < Form6.minimumUtilizationQc then Form6.minimumUtilizationQc := lastValueQcBarChart; if lastValueQcBarChart > Form6.maximumUtilizationQc then Form6.maximumUtilizationQc := lastValueQcBarChart; Form6.averageUtilizationQc := (Form6.averageUtilizationQc*(lastTimeQcChart)+ lastValueQcBarChart*(TNow –

lastTimeQcChart - startupTime))/(TNow-startupTime); end; end; lastValueQcLineChart := operatingQCs/numberOfQuayCranes*100; lastValueQcBarChart := operatingQCs; lastTimeQcChart := TNow-startupTime; end;

procedure setAscCharts (AscSuspendingNow:integer);

var i,operatingAscs : Integer; myAsc : TAsc; begin //determine the amount of operating ASCs operatingAscs := 0; for i := 0 to numberOfAscs - 1 do begin myAsc := ascQueue.Element(i); if myAsc.StatusToString <> 'Passive' then operatingAscs := operatingAscs + 1; end; operatingAscs := operatingAscs - AscSuspendingNow; //place the points in the utilization LineChart if (lastTimeAscChart = TNow-startupTime) and (lastTimeAscChart <> 0) then begin

//if the last point was set on the same time Form6.UtilizationLineChart.Series[3].Delete(Form6.UtilizationLineChart.Series[3].count - 1); end else begin Form6.UtilizationLineChart.Series[3].AddXY(TNow-startupTime, lastValueAscLineChart, '', clblue); end; Form6.UtilizationLineChart.Series[3].AddXY(TNow-startupTime, operatingAScs/numberOfAscs*100, '', clblue); if lastTimeAscChart < TNow-startupTime then begin //update the ASC utilization BarChart utilizationArrayAsc[lastValueAscBarChart]:= utilizationArrayAsc[lastValueAscBarChart] + TNow - startupTime

- lastTimeAscChart; if (TNow > startupTime) and (form6.Visible) then begin for i := 0 to Form6.UtilizationBarChartAsc.Series[0].Count - 1 do begin Form6.UtilizationBarChartAsc.Series[0].Delete(i); Form6.UtilizationBarChartAsc.Series[0].AddXY(i, utilizationArrayAsc[i]/(Tnow - startupTime)*100, '', clblue); end; end; //set values Form6 if TNow > startupTime then begin if lastValueAscBarChart < Form6.minimumUtilizationAsc then Form6.minimumUtilizationAsc := lastValueAscBarChart; if lastValueAscBarChart > Form6.maximumUtilizationAsc then Form6.maximumUtilizationAsc := lastValueAscBarChart; Form6.averageUtilizationAsc := (Form6.averageUtilizationAsc*(lastTimeAscChart)+ lastValueAscBarChart

*(TNow - lastTimeAscChart - startupTime))/(TNow-startupTime); end; end; lastValueAscLineChart := operatingASCs/numberOfAscs*100; lastValueAscBarChart := operatingASCs; lastTimeAScChart := TNow-startupTime; end;

Page 57: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

57

procedure setCharts (Element, QcSuspendingNow, AscSuspendingNow:integer); //programmed this way, because

in one procedure, the program became very slow begin if TNow > 0 then begin if Form6.Active then begin //set charts for all three resources setAgvCharts; setQcCharts(QcSuspendingNow); setAscCharts(AscSuspendingNow); end else begin //set chart for only the changed resource if Element = 1 then setAgvCharts else if Element = 2 then setQcCharts(QcSuspendingNow) else if Element = 3 then setAscCharts(AscSuspendingNow); end; if TNow > startupTime then Form6.setResults; if Form6.visible then begin //update the results on the main form updateResults; //set horizontal axis Line Chart on the chart form if Tnow > Form6.rangeAgvChart then begin Form6.UtilizationLineChart.Axes.Bottom.Maximum:= Tnow - startupTime; Form6.UtilizationLineChart.Axes.Bottom.Minimum:= Tnow - startupTime - Form6.rangeAgvChart; Form6.ScrollBarLineChart.Position := 100; end; if Element = 1 then Form6.lastTimeLineChart := lastTimeAgvChart //required for scrollbar Form6 else if Element = 2 then Form6.lastTimeLineChart := lastTimeQcChart else if Element = 3 then Form6.lastTimeLineChart := lastTimeAscChart else Form6.lastTimeLineChart := max(lastTimeAgvChart,max(lastTimeQcChart,lastTimeAscChart)); end; end; end;

procedure resetChartData ;

var i : Integer; begin for i := 0 to numberOfAgvs do begin utilizationArrayAgv[i]:= 0; end; for i := 0 to numberOfQuayCranes do begin utilizationArrayQc[i]:= 0; end; for i := 0 to numberOfAscs do begin utilizationArrayAsc[i]:= 0; end; lastTimeAgvChart := 0; lastTimeQcChart := 0; lastTimeAscChart := 0; //reset chart data Form6 Form6.resetResultsAfterSimulationStartup; end;

(******************************************************************************) (***** Initialization *****) (******************************************************************************)

procedure InitializeSystem ;

//procedure to set all parameters, create all distributions, queues and elements //preceding the start of the simulation. var i : Integer; meanshipUnloadTimeForQc : Double; upperboundAgvCycleTime : Double; //be aware the the cycle time of the user includes the transfer times, but

here in the code it only represents the driving cycle without the transfer times. lowerboundAgvCycleTime : Double; //be aware the the cycle time of the user includes the transfer times, but

here in the code it only represents the driving cycle without the transfer times. upperboundAscCycleTime : Double; //be aware the the cycle time of the user includes the transfer times, but

here in the code it only represents the driving cycle without the transfer times. lowerboundAscCycleTime : Double; //be aware the the cycle time of the user includes the transfer times, but

here in the code it only represents the driving cycle without the transfer times. changeminmax : Double; myQuayCrane : TQuayCrane; myAgv : TAgv; myAsc : TAsc; myLandsideJobGenerator : TLandsideJobGenerator;

Page 58: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

58

myTimeManager : TTimeManager; myAnimationDrawer : TAnimationDrawer; begin TomasForm.Hide; //set variables if batchSimulation = False then begin //set variables from editboxes, checkbox and radio boxes runtime := 3600*StrToFloat(Form1.EditRuntime.Text); startuptime := 3600*StrToFloat(Form1.EditStartupTime.Text); numberOfQuayCranes := StrToInt(Form1.EditNrQc.Text); meanshipUnloadTimeForQc := StrToFloat(Form1.EditShipUnloadtimeQc.Text); agvLoadTimeForQc := StrToFloat(Form1.EditAgvLoadtimeQc.Text); agvUnloadTimeForAsc := StrToFloat(Form1.EditAgvLoadtimeAsc.Text); numberOfAgvs := StrToInt(Form1.EditNrAgv.Text); lowerboundAgvCycleTime := StrToFloat(Form1.EditMinAgvCycleTime.Text)-agvLoadTimeForQc-agvUnloadTimeForAsc;

//be aware the the cycle time of the user includes the transfer times, but here in the code it only represents the driving cycle without the transfer times.

upperboundAgvCycleTime := StrToFloat(Form1.EditMaxAgvCycleTime.Text)-agvLoadTimeForQc-agvUnloadTimeForAsc;

//be aware the the cycle time of the user includes the transfer times, but here in the code it only represents the driving cycle without the transfer times.

numberOfAscs := StrToInt(Form1.EditNrAsc.Text); lowerboundAscCycleTime := StrToFloat(Form1.EditMinAscCycleTime.Text)-agvUnloadTimeForAsc;

//be aware the the cycle time of the user includes the transfer times, but here in the code it only represents the driving cycle without the transfer times.

upperboundAscCycleTime := StrToFloat(Form1.EditMaxAscCycleTime.Text)-agvUnloadTimeForAsc; //be aware the the cycle time of the user includes the transfer times, but here in the code it only represents the driving cycle without the transfer times.

if Form1.CheckBoxSelectAsc.Checked = True then begin ascSelectionForAgv := 1; end else ascSelectionForAgv := 0; if Form1.RadioButtonAgvsAtQCs1.Checked = True then begin qcSelectionForAgv := 1; end else if Form1.RadioButtonAgvsAtQCs2.Checked = True then begin qcSelectionForAgv := 2; end else qcSelectionForAgv := 3; end else begin //set variables from bat-file i := 4; //because the first parameters should not be taken runtime := 3600*StrToFloat(ParamStr(i+0)); startuptime := 3600*StrToFloat(ParamStr(i+1)); numberOfQuayCranes := StrToInt(ParamStr(i+2)); meanshipUnloadTimeForQc := StrToFloat(ParamStr(i+3)); agvLoadTimeForQc := StrToFloat(ParamStr(i+4)); agvUnloadTimeForAsc := StrToFloat(ParamStr(i+11)); numberOfAgvs := StrToInt(ParamStr(i+5)); lowerboundAgvCycleTime := StrToFloat(ParamStr(i+6))-agvLoadTimeForQc-agvUnloadTimeForAsc; //be aware the the

cycle time of the user includes the transfer times, but here in the code it only represents the driving cycle without the transfer times.

upperboundAgvCycleTime := StrToFloat(ParamStr(i+7))-agvLoadTimeForQc-agvUnloadTimeForAsc; //be aware the the

cycle time of the user includes the transfer times, but here in the code it only represents the driving cycle without the transfer times.

numberOfAscs := StrToInt(ParamStr(i+8)); lowerboundAscCycleTime := StrToFloat(ParamStr(i+9)) -agvUnloadTimeForAsc; //be aware the

the cycle time of the user includes the transfer times, but here in the code it only represents the driving cycle without the transfer times.

upperboundAscCycleTime := StrToFloat(ParamStr(i+10))-agvUnloadTimeForAsc; //be aware the the

cycle time of the user includes the transfer times, but here in the code it only represents the driving cycle without the transfer times.

ascSelectionForAgv := StrToInt(ParamStr(i+12)); qcSelectionForAgv := StrToInt(ParamStr(i+13)); end; //set result SeasideProduction := 0; //create Queues quayCraneQueue := TomasQueue.create('quayCraneQueue'); generalAgvQueue := TomasQueue.create('generalAgvQueue'); ascQueue := TomasQueue.create('ascQueue'); if qcSelectionForAgv = 1 then agvsAtQuayCranesQueue := TomasQueue.create('agvsAtQuayCranesQueue'); //create Distributions quayCraneUnloadTimeDistribution := TExponentialDistribution.Create(300066,meanshipUnloadTimeForQc); agvCycleTimeDistribution := TUniformDistribution.Create(684545,lowerboundAgvCycleTime,

upperboundAgvCycleTime); ascCycleTimeDistribution := TUniformDistribution.Create(846545,lowerboundAscCycleTime,

upperboundAscCycleTime); if ascSelectionForAgv = 0 then ascSelectionDistribution := TUniformDistribution.Create(500000,0,numberOfAscs); //create QuayCranes for i := 0 to numberOfQuayCranes - 1 do begin

Page 59: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

59

myQuayCrane := TQuayCrane.Create('QuayCrane'); myQuayCrane.agvQueue := TomasQueue.create('AGVQueue'); myQuayCrane.agvOnItsWayQueue := TomasQueue.create('agvOnItsWayQueue'); quayCraneQueue.addToTail(myQuayCrane); myQuayCrane.Start(TNow); end;

//create AGVs for i := 0 to numberOfAgvs - 1 do begin myAgv := TAgv.Create('Agv'); myAgv.statusIdle := False; myAgv.statusWaiting := False; generalAgvQueue.addToTail(myAgv); myAgv.Start(TNow); end;

//create ASCs for i := 0 to numberOfAscs - 1 do begin myAsc := TAsc.Create('Asc'); myAsc.agvQueue := TomasQueue.create('AGVQueue'); myAsc.landsideQueue := TomasQueue.create('landsideQueue'); ascQueue.addToTail(myAsc); myAsc.Start(TNow); end;

//create LandsideJobGenerator myLandsideJobGenerator := TLandsideJobGenerator.Create('LandsideJobGenerator'); myLandsideJobGenerator.Start(TNow);

//create TimeManager myTimeManager := TTimeManager.Create('TimeManager'); myTimeManager.Start(TNow);

if batchSimulation = False then begin //set parameters for charts Form6.numberOfAgvs := numberOfAgvs; Form6.numberOfQuayCranes := numberOfQuayCranes; Form6.numberOfAscs := numberOfAscs; Form6.minimumUtilizationAgv := numberOfAgvs; Form6.maximumUtilizationAgv := 0; Form6.minimumUtilizationQc := numberOfQuayCranes; Form6.maximumUtilizationQc := 0; Form6.minimumUtilizationAsc := numberOfAscs; Form6.maximumUtilizationAsc := 0; Form6.startupTime := startupTime; lastTimeAgvChart := -startupTime; lastTimeQcChart := -startupTime; lastTimeAscChart := -startupTime; lastValueAgvLineChart := 0; lastValueAgvWaitingLineChart := 0; lastValueQcLineChart := 0; lastValueAscLineChart := 0; SetLength(utilizationArrayAgv, numberOfAgvs+1); SetLength(utilizationArrayQc, numberOfQuayCranes+1); SetLength(utilizationArrayAsc, numberOfAscs+1); for i := 0 to numberOfAgvs do begin utilizationArrayAgv[i] :=0; Form6.UtilizationBarChartAgv.Series[0].AddXY(i, 0, '', clred); end; for i := 0 to numberOfQuayCranes do begin utilizationArrayQc[i] := 0; Form6.UtilizationBarChartQuayCrane.Series[0].AddXY(i, 0, '', clgreen); end; for i := 0 to numberOfAscs do begin utilizationArrayAsc[i] := 0; Form6.UtilizationBarChartAsc.Series[0].AddXY(i, 0, '', clblue); end; Form6.UtilizationLineChart.Axes.Bottom.Minimum := -startupTime; Form6.UtilizationLineChart.Axes.Bottom.Maximum := Form6.rangeAgvChart-startupTime;

//create AnimationDrawer myAnimationDrawer := TAnimationDrawer.Create('AnimationDrawer'); AnimationDrawerQueue := TomasQueue.create('AnimationDrawerQueue'); AnimationDrawerQueue.AddToTail(myAnimationDrawer); myAnimationDrawer.Start(TNow); end; end;

procedure CheckForBatchOfSimulations ;

//procedure to check at the moment the program is started, whether this is a //simulation out of a batch of simulations or not. var batchindicator : Integer; begin

Page 60: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

60

try batchindicator := StrToInt(ParamStr(1)); except batchindicator := 0; end; if batchindicator = 1 then begin //in the case of batch simulations batchSimulation := True; InitializeSystem; end else begin //in case it's not a batch of simulations batchSimulation := False; end; end;

(******************************************************************************) (***** Processes *****) (******************************************************************************)

procedure TQuayCrane.process ;

var myAgv : TAgv; begin while TRUE do begin Hold(quayCraneUnloadTimeDistribution.Sample); {Work "sample of QCs cycle time"} if qcSelectionForAgv = 1 then begin //pool of AGVs at QCs if agvsAtQuayCranesQueue.Length < 1 then begin if batchSimulation = False then setCharts(2,1,0); //Qc suspending Suspend; {Wait while no AGVs waiting} end; myAgv:=agvsAtQuayCranesQueue.FirstElement; agvsAtQuayCranesQueue.Remove(myAgv); AgvQueue.AddToTail(myAgv); end else begin if AgvQueue.Length < 1 then begin if batchSimulation = False then setCharts(2,1,0); //Qc suspending Suspend; {Wait while no AGVs waiting} end; end; myAgv:=AgvQueue.FirstElement; {Select AGV} myAgv.statusIdle := False; if batchSimulation = False then setCharts(1,0,0); //statuschange AGV Hold(AGVLoadTimeForQc); {Load AGV in x seconds} AgvQueue.Remove(myAgv); myAgv.Resume(TNow); {Resume AGVs process} SeasideProduction:= SeasideProduction+1; //SeasideProduction is the result of

the simulation end; end;

procedure TAgv.process ;

var myQuayCrane : TQuayCrane; myAsc : TAsc; noQCSelected: Boolean; cycleTime : Double; i : Integer; begin while TRUE do begin cycleTime:= agvCycleTimeDistribution.Sample; {Cycle is "sample of AGVs cycle time"} if qcSelectionForAgv = 3 then begin myQuayCrane:= quayCraneQueue.Element(selectQuayCrane); {Select QC} //select QC after departure from ASC EnterQueue(myQuayCrane.agvOnItsWayQueue); end; Hold(cycleTime/2); {Drive 0.5 x Cycle} if qcSelectionForAgv = 1 then begin Enterqueue(agvsAtQuayCranesQueue); NoQCSelected:= True; for i := 0 to quayCraneQueue.Length - 1 do begin myQuayCrane:= quayCraneQueue.Element(i); //select QC is AGVs are certralised at CQs if NoQCSelected then begin if myQuayCrane.StatusToString = 'Passive' then begin myQuayCrane.Resume(TNow); {(if necesary, resume QC)} if batchSimulation = False then setCharts(2,0,0); //QC resuming noQCSelected:= False; end; end; end;

Page 61: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

61

end else begin if qcSelectionForAgv = 3 then begin LeaveQueue(myQuayCrane.agvOnItsWayQueue); end else begin myQuayCrane := quayCraneQueue.Element(selectQuayCrane); //select QC at arrival QC area end; Enterqueue(myQuayCrane.AGVQueue); if myQuayCrane.StatusToString = 'Passive' then begin myQuayCrane.Resume(TNow); {(if necesary, resume QC)} if batchSimulation = False then setCharts(2,0,0); //QC resuming end; end; statusIdle := True; if batchSimulation = False then setCharts(1,0,0); //statuschange AGV Suspend; {Wait for QC} Hold(cycleTime/2); {Drive 0.5 x Cycle} myAsc:= ascQueue.Element(selectAsc); {Select ASC} //the description of the case states

that as a second alternative the AGVs and landside select an ASC based on the workload already assigned to an ASC. This selection is assumed to be performed at the moment of arrival. Therefore in contradiction to the case description, the ASC is selected after driving towards the ASC. For the first alternative, where an ASC is selected according a uniform distribution, this doesn't affect the results.

Enterqueue(myAsc.AGVQueue); if myAsc.StatusToString = 'Passive' then begin myAsc.Resume(TNow); {(if necesary, resume ASC)} if batchSimulation = False then setCharts(3,0,0); //ASC resuming end; statusWaiting := True; if batchSimulation = False then setCharts(1,0,0); //statuschange AGV Suspend; {Wait for ASC} end; end;

procedure TAsc.process ;

var myAgv : TAgv; myLandsideJob: TLandsideJob; cycleTime : Double; begin while TRUE do begin if (AgvQueue.Length < 1) and (landsideQueue.Length < 1) then begin if batchSimulation = False then setCharts(3,0,1); //ASC suspending Suspend; {Wait while no AGVs waiting and no jobs on land side} end; cycleTime:= ascCycleTimeDistribution.Sample; {Cycle = sample of ASC cycle time} if AgvQueue.Length > 0 then begin {If AGVs waiting} myAgv:=AgvQueue.FirstElement; {Select AGV} myAgv.statusWaiting := False; if batchSimulation = False then setCharts(1,0,0); //statuschange AGV Hold(cycleTime/2); {Move to AGV in 0.5 x cycle} Hold(AgvUnloadTimeForAsc); {Unload AGV in y seconds} AgvQueue.Remove(myAgv); myAgv.Resume(TNow); {Resume AGV's process} Hold(cycleTime/2); {Store container in 0.5 x cycle} end else begin {Else} myLandsideJob:=landsideQueue.FirstElement; {Select land-side job} Hold(cycleTime); {Work D seconds} //since it's unknown whether this

is an arriving or leaving container, the landside job isn't released in the middle of the cycletime, It's assumed here the cycle time for a landside job is equal to the cycle time of a sea side job.

landsideQueue.Remove(myLandsideJob); myLandsideJob.Destroy; end; end; end;

procedure TLandsideJobGenerator.process ;

var myAsc : TAsc; myLandsideJob: TLandsideJob; begin while TRUE do begin Hold(3600/90); {Wait(3600/90)} myLandsideJob:= TLandsideJob.Create('LandsideJob'); {Create land-side job for ASC} myAsc:=AscQueue.Element(selectAsc); {Select ASC} myAsc.LandsideQueue.AddToTail(myLandsideJob); if myAsc.StatusToString = 'Passive' then begin myAsc.Resume(TNow); if batchSimulation = False then setCharts(3,0,0); //ASC resuming end; end; end;

Page 62: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

62

procedure TTimeManager.process ;

begin while TRUE do begin if batchSimulation = False then begin form1.LabelTimelabel.Font.Color := ClMaroon; form1.LabelStartupTime.Font.Color := ClMaroon; form1.LabelTimelabel.Caption := 'Simulation start-up:'; form6.setFormForSimulationStartUp; end else Form5.visible := True; hold(startuptime); //run simulation start-up seasideProduction := 0; //reset simulation results from start-up period if batchSimulation = False then begin form1.LabelTimelabel.Font.Color := Clblack; form1.LabelStartupTime.Font.Color := Clblack; form1.LabelTimelabel.Caption := 'Simulation time:'; resetChartData; end; hold(RunTime); //run simulation if batchSimulation = False then begin interruptSimulation; Form1.BtnInterrupt.Enabled := False; Form1.CheckBoxAnimation.Enabled := False; Form1.BtnClose.SetFocus; //enable and update labels in case the animation was turned off and present the final values Form1.LabelRuntime.Enabled := True; Form1.LabelseasideProduction.Enabled := True; Form1.LabelseasideProduction2.Enabled := True; updateResults; Form6.Show; setCharts(0,0,0); //set all charts (after Form6.show) end else begin writeToExcel; stopsimulation(TNow); end; hold(1); //to prevent the program from quiting immediately end; end;

procedure TAnimationDrawer.process ;

//procedure to draw the animation. var myAsc : TAsc; myAgv : TAgv; myQuaycrane : TQuaycrane; i,j,k,amountOfItems,amountOfItemsComing : Integer; drawingRightAsc,drawingLeftAsc,drawingBottomAsc : Integer; drawingBottomAgv,agvAtQCLeft : Integer; drawingLeftQc,drawingBottomQc,drawingBottomAgvAtQC : Integer; ascLeft,ascTop,widthAsc,heightAsc,spaceInBetweenAsc : Integer; agvLeft,agvTop,widthAgv,heightAgv,spaceInBetweenAgv : Integer; widthLandsideJob,heightLandsideJob,spaceInBetweenLandsideJob : Integer; QcLeft,QcTop,widthQc,heightQc,spaceInBetweenQc : Integer; maximumAgvsAtAsc,maximumLandsideJobsAtAsc,maximumAgvsAtQc : Integer; maximumAgvsHorizontal : Integer; begin //constants (for drawing) ascLeft := 60; ascTop := 135; widthAsc := 15; heightAsc := 10; spaceInBetweenAsc := 3; agvLeft := 220; agvAtQCLeft := 320; agvTop := ascTop; widthAgv := 10; heightAgv := 7; spaceInBetweenAgv := 2; widthLandsideJob := 7; heightLandsideJob := 10; spaceInBetweenLandsideJob := 2; qcLeft := 400; qcTop := ascTop; widthQc := 50; heightQc := 20; spaceInBetweenQc := 10; maximumAgvsAtAsc := 10; maximumLandsideJobsAtAsc := 5;

Page 63: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

63

maximumAgvsAtQc := 9; maximumAgvsHorizontal := 4; drawingRightAsc := ascLeft+widthAsc+spaceInBetweenAsc+widthAgv+(maximumAgvsAtAsc-1)*

(spaceInBetweenAgv+widthAgv)+8; drawingLeftAsc := ascLeft-maximumLandsideJobsAtAsc*(spaceInBetweenLandsideJob+widthLandsideJob)-8; drawingBottomAsc := ascTop+ascQueue.Length*(spaceInBetweenAsc+heightAsc); drawingBottomAgv := agvTop; drawingBottomAgvAtQC := agvTop; drawingLeftQc := qcLeft-maximumAgvsAtQc*(spaceInBetweenAgv+widthAgv)-8; drawingBottomQc := qcTop+quaycraneQueue.Length*(spaceInBetweenQc+heightQc); if qcSelectionForAgv = 1 then drawingLeftQc := qcLeft-1*(spaceInBetweenAgv+widthAgv); //check whether the animation should be displayed. In that case, show the legenda. if Form1.CheckBoxAnimation.Checked = True then begin enableAnimation := True; //show legenda if qcSelectionForAgv = 3 then begin Form4.agvsToQcOn := True; end else Form4.agvsToQcOn := False; Form4.Show; Form4.drawLegenda; Form4.drawLegenda; end else begin enableAnimation := False; end; Form1.CheckBoxDelaySimulationClick(Form1); //set Tomas.Trace on or off while TRUE do begin //in case the animation is switched off during the simulation: if enableAnimation = False then begin //prepare to suspend. Form4.Hide; Form1.canvas.Pen.Color := clBtnFace ; Form1.canvas.Brush.Color := clBtnFace; Form1.canvas.rectangle(drawingLeftAsc,ascTop,drawingRightAsc,drawingBottomAsc); Form1.canvas.rectangle(agvLeft,agvTop,agvLeft+maximumAgvsHorizontal*(spaceInBetweenAgv+widthAgv),

drawingBottomAgv); Form1.canvas.rectangle(agvAtQCLeft,agvTop,agvAtQCLeft+maximumAgvsHorizontal*(spaceInBetweenAgv+widthAgv),

drawingBottomAgvAtQC); Form1.canvas.rectangle(drawingLeftQc,qcTop,qcLeft+widthQc,drawingBottomQc); if Form6.Visible = False then Form1.LabelRuntime.Enabled := False; if Form6.Visible = False then Form1.LabelseasideProduction.Enabled := False; if Form6.Visible = False then Form1.LabelseasideProduction2.Enabled := False; Suspend; //in case the simulation is Resumed (after being suspended): Form1.LabelRuntime.Enabled := True; Form1.LabelseasideProduction.Enabled := True; Form1.LabelseasideProduction2.Enabled := True; enableAnimation := True; //show legenda if qcSelectionForAgv = 3 then begin Form4.agvsToQcOn := True; end else Form4.agvsToQcOn := False; Form4.Show; Form4.drawLegenda; Form4.drawLegenda; end; updateResults; //clear ASCs Form1.canvas.Pen.Color := clBtnFace ; Form1.canvas.Brush.Color := clBtnFace; Form1.canvas.rectangle(drawingLeftAsc,ascTop,drawingRightAsc,drawingBottomAsc); //draw ASCs if ascQueue.Length > 0 then begin Form1.canvas.Pen.Color := clblack; for i := 0 to ascQueue.Length - 1 do begin myAsc := ascQueue.Element(i); Form1.canvas.Brush.Color := clred; if myAsc.StatusToString = 'Passive' then Form1.canvas.Brush.Color := clgreen; Form1.canvas.rectangle(ascLeft,ascTop+i*(spaceInBetweenAsc+heightAsc),ascLeft+widthAsc,ascTop+heightAsc

+i*(spaceInBetweenAsc+heightAsc)); //define if there are to much AGVs at ASC, if so, draw a +. amountOfItems := myAsc.agvQueue.Length; if myAsc.agvQueue.Length > maximumAgvsAtAsc then begin amountOfItems := maximumAgvsAtAsc; Form1.canvas.rectangle(ascLeft+widthAsc+maximumAgvsAtAsc*(spaceInBetweenAgv+widthAgv)+3,ascTop+

i*(spaceInBetweenAsc+heightAsc)+3,ascLeft+widthAsc+maximumAgvsAtAsc*(spaceInBetweenAgv+widthAgv)+9,ascTop+i*(spaceInBetweenAsc+heightAsc)+5);

Form1.canvas.rectangle(ascLeft+widthAsc+maximumAgvsAtAsc*(spaceInBetweenAgv+widthAgv)+5,ascTop+

Page 64: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

64

i*(spaceInBetweenAsc+heightAsc)+1,ascLeft+widthAsc+maximumAgvsAtAsc*(spaceInBetweenAgv+widthAgv)+7,ascTop+i*(spaceInBetweenAsc+heightAsc)+7);

end; //draw AGVs at ASC for j := 0 to amountOfItems - 1 do begin myAgv:= myAsc.agvQueue.Element(j); if myAgv.statusWaiting = False then begin Form1.canvas.Brush.Color := clRed; end else Form1.canvas.Brush.Color := clYellow; Form1.canvas.rectangle((ascLeft+widthAsc+spaceInBetweenAsc+j*(spaceInBetweenAgv+widthAgv)),

ascTop+i*(spaceInBetweenAsc+heightAsc),(ascLeft+widthAsc+spaceInBetweenAsc+widthAgv+j*(spaceInBetweenAgv+widthAgv)),ascTop+i*(spaceInBetweenAsc+heightAsc)+heightAgv);

end; ///define if there are to much Landside Jobs at ASC, if so, draw a +. amountOfItems := myAsc.landsideQueue.Length; if myAsc.landsideQueue.Length > maximumLandsideJobsAtAsc then begin amountOfItems := maximumLandsideJobsAtAsc; Form1.canvas.rectangle(ascLeft-maximumLandsideJobsAtAsc*(spaceInBetweenLandsideJob+widthLandsideJob)

-8,ascTop+i*(spaceInBetweenAsc+heightAsc)+4,ascLeft-maximumLandsideJobsAtAsc*(spaceInBetweenLandsideJob+widthLandsideJob)-2,ascTop+i*(spaceInBetweenAsc+heightAsc)+6);

Form1.canvas.rectangle(ascLeft-maximumLandsideJobsAtAsc*(spaceInBetweenLandsideJob+widthLandsideJob)- 6,ascTop+i*(spaceInBetweenAsc+heightAsc)+2,ascLeft-maximumLandsideJobsAtAsc*(spaceInBetweenLandsideJob+widthLandsideJob)-4,ascTop+i*(spaceInBetweenAsc+heightAsc)+8);

end; //draw Landside Jobs at ASC Form1.canvas.Brush.Color := clblue; for j := 0 to amountOfItems - 1 do begin Form1.canvas.rectangle(ascLeft-(j+1)*(spaceInBetweenLandsideJob+widthLandsideJob),ascTop+i*

(spaceInBetweenAsc+heightAsc),ascLeft-(j)*(spaceInBetweenLandsideJob+widthLandsideJob)-spaceInBetweenLandsideJob,ascTop+i*(spaceInBetweenAsc+heightAsc)+heightLandsideJob);

end; end; end; //clear driving AGVs Form1.canvas.Pen.Color := clBtnFace ; Form1.canvas.Brush.Color := clBtnFace; Form1.canvas.rectangle(agvLeft,agvTop,agvLeft+maximumAgvsHorizontal*(spaceInBetweenAgv+widthAgv),

drawingBottomAgv); drawingBottomAgv := agvTop; //draw driving AGVs if GeneralAgvQueue.Length > 0 then begin Form1.canvas.Pen.Color := clblack; Form1.canvas.Brush.Color := clred; j:=0; k:=0; for i := 0 to GeneralAgvQueue.Length - 1 do begin myAgv :=GeneralAgvQueue.Element(i); if myAgv.StatusToString <> 'Passive' then begin Form1.canvas.rectangle(agvLeft + k*(spaceInBetweenAgv+widthAgv),agvTop+j*(spaceInBetweenAgv+heightAgv),

agvLeft+widthAgv+ k*(spaceInBetweenAgv+widthAgv),agvTop+heightAgv+ j*(spaceInBetweenAgv+heightAgv));

k:=k+1; if k >= maximumAgvsHorizontal then begin k:=0; j:=j+1; end; end; end; drawingBottomAgv := agvTop+heightAgv+(j)*(spaceInBetweenAgv+heightAgv); end; if qcSelectionForAgv = 1 then begin //clear AGVs in centralized quay crane queue Form1.canvas.Pen.Color := clBtnFace; Form1.canvas.Brush.Color := clBtnFace; Form1.canvas.rectangle(agvAtQCLeft,agvTop,agvAtQCLeft+maximumAgvsHorizontal*

(spaceInBetweenAgv+widthAgv),drawingBottomAgvAtQC); drawingBottomAgvAtQC := agvTop; //draw AGVs in centralized quay crane queue if agvsAtQuayCranesQueue.Length > 0 then begin Form1.canvas.Pen.Color := clblack; Form1.canvas.Brush.Color := clgreen; j:=0; k:=0; for i := 0 to agvsAtQuayCranesQueue.Length - 1 do begin Form1.canvas.rectangle(agvAtQCLeft + k*(spaceInBetweenAgv+widthAgv),agvTop+j*(spaceInBetweenAgv+

heightAgv),agvAtQCLeft+widthAgv+ k*(spaceInBetweenAgv+widthAgv),agvTop+heightAgv+j*(spaceInBetweenAgv+heightAgv));

k:=k+1; if k >= maximumAgvsHorizontal then begin k:=0;

Page 65: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

65

j:=j+1; end; end; drawingBottomAgvAtQC := agvTop+heightAgv+(j)*(spaceInBetweenAgv+heightAgv); end; end; //clear QCs Form1.canvas.Pen.Color := clBtnFace ; Form1.canvas.Brush.Color := clBtnFace; Form1.canvas.rectangle(drawingLeftQc,qcTop,qcLeft+widthQc,drawingBottomQc); //draw QCs if quaycraneQueue.Length > 0 then begin Form1.canvas.Pen.Color := clblack; for i := 0 to quaycraneQueue.Length - 1 do begin myQuaycrane := quaycraneQueue.Element(i); Form1.canvas.Brush.Color := clred; if myQuaycrane.StatusToString = 'Passive' then Form1.canvas.Brush.Color := clgreen; Form1.canvas.rectangle(qcLeft,qcTop+i*(spaceInBetweenQc+heightQc),qcLeft+widthQc,qcTop+

heightQc+i*(spaceInBetweenQc+heightQc)); //define if there are to much AGVs at a quay crane, if so, draw a +. amountOfItems := myQuaycrane.agvQueue.Length; amountOfItemsComing := myQuaycrane.agvOnItsWayQueue.Length; if amountOfItems + amountOfItemsComing > maximumAgvsAtQc then begin if amountOfItems > maximumAgvsAtQc then begin amountOfItems := maximumAgvsAtQc; amountOfItemsComing := 0; end else begin amountOfItemsComing := maximumAgvsAtQc - amountOfItems; end; Form1.canvas.rectangle(qcLeft-maximumAgvsAtQc*(spaceInBetweenAgv+widthAgv)-8,qcTop+

i*(spaceInBetweenQc+heightQc)+3,qcLeft-maximumAgvsAtQc*(spaceInBetweenAgv+widthAgv)-2,qcTop+i*(spaceInBetweenQc+heightQc)+5);

Form1.canvas.rectangle(qcLeft-maximumAgvsAtQc*(spaceInBetweenAgv+widthAgv)-6,qcTop+ i*(spaceInBetweenQc+heightQc)+1,qcLeft-maximumAgvsAtQc*(spaceInBetweenAgv+widthAgv)-4,qcTop+i*(spaceInBetweenQc+heightQc)+7);

end; //draw AGVs currently at a quay crane. for j := 0 to amountOfItems - 1 do begin myAgv:= myQuaycrane.agvQueue.Element(j); if myAgv.statusIdle = False then begin Form1.canvas.Brush.Color := clRed; end else Form1.canvas.Brush.Color := clGreen; Form1.canvas.rectangle(qcLeft-(j+1)*(spaceInBetweenAgv+widthAgv),qcTop+i*(spaceInBetweenQc+heightQc),

qcLeft-(j)*(spaceInBetweenAgv+widthAgv)-spaceInBetweenAgv,qcTop+i*(spaceInBetweenQc+heightQc)+heightAgv); end; //draw AGVs on their way to a quay crane. Form1.canvas.Pen.Color := clGray; Form1.canvas.Brush.Color := clBtnFace; for j := amountOfItems to amountOfItems + amountOfItemsComing - 1 do begin Form1.canvas.rectangle(qcLeft-(j+1)*(spaceInBetweenAgv+widthAgv),qcTop+i*(spaceInBetweenQc+heightQc),

qcLeft-(j)*(spaceInBetweenAgv+widthAgv)-spaceInBetweenAgv,qcTop+i*(spaceInBetweenQc+heightQc)+heightAgv); end; Form1.canvas.Pen.Color := clblack; end; end; hold(1); //refresh the drawing every simulationstep end; end;

Page 66: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

66

(******************************************************************************) (***** User Interface *****) (******************************************************************************)

procedure TForm1.BtnStartClick (Sender: TObject);

//procedure to disable editboxes, checkboxes of the simulation parameters, //initialize the program and start the simulation. begin checkInputs(False); if inputOK1 = True then begin simulationStarted := True; //disable editboxes, buttons, checkboxes EditNrQc.Enabled := False; EditNrAsc.Enabled := False; EditNrAgv.Enabled := False; EditShipUnloadtimeQc.Enabled := False; EditAgvLoadtimeQc.Enabled := False; EditAgvLoadtimeAsc.Enabled := False; EditStartupTime.Enabled := False; EditRuntime.Enabled := False; EditMaxAgvCycleTime.Enabled := False; EditMinAgvCycleTime.Enabled := False; EditMaxAscCycleTime.Enabled := False; EditMinAscCycleTime.Enabled := False; BtnStart.Enabled := False; BtnInterrupt.Enabled := True; RadioButtonAgvsAtQCs1.Enabled := False; RadioButtonAgvsAtQCs2.Enabled := False; RadioButtonAgvsAtQCs3.Enabled := False; CheckBoxSelectAsc.Enabled := False; CheckBoxRememberInput.Enabled := False; InitializeSystem; writeToTextfile; //needs to be after InitializeSystem

(ascSelectionForAgv,qcSelectionForAgv) startsimulation; end; end;

procedure TForm1.BtnInterruptClick (Sender: TObject);

begin if TNow > 0 then begin interruptSimulation; BtnResume.Enabled:= True; BtnResume.SetFocus; BtnInterrupt.Enabled:= False; end; end;

procedure TForm1.BtnResumeClick (Sender: TObject);

begin if TNow > 0 then begin resumeSimulation; BtnResume.Enabled:= False; BtnInterrupt.Enabled:= True; BtnInterrupt.SetFocus; end; end;

procedure TForm1.BtnCloseClick (Sender: TObject);

begin if TNow < 1 then begin if not simulationStarted = true then startsimulation; //to make sure the program won't crash when the

user clicks immidiately (during the initialization) on the Close button, before TNow > 0. end; resumeSimulation; stopsimulation(TNow); end;

procedure TForm1.ButtonShowChartsClick (Sender: TObject);

begin Form1.CheckBoxAnimation.Checked := False; Form1.labelRuntime.Enabled := True; Form1.LabelseasideProduction.Enabled := True; Form1.LabelseasideProduction2.Enabled := True; Form6.chartFormDisabledAnimation := True; Form6.show; end;

Page 67: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

67

procedure TForm1.ButtonCreateBatchClick (Sender: TObject);

var buttonSelected : Integer; begin buttonSelected:= 0; checkInputs(True); if inputOK1 = True then begin writeToTextfile; end else buttonSelected := MessageDlg('One or more input values seem to be incorrect. Therefore the current

input values can not be saved and used in the next step. ' + #13#10 + 'Press OK to continue or Cancel to correct the current input values',mtWarning, [mbOK, mbCancel] , 0);

if buttonSelected = mrCancel then begin checkInputs(False); end else begin if Form2.Visible = True then Form2.show; Form2.Visible:= True; if Form1.CheckBoxRememberInput.Checked = True then Form2.writeInputToTextfile:= True else

Form2.writeInputToTextfile:= False; end; end;

procedure TForm1.CheckBoxAnimationClick (Sender: TObject);

var myAnimationDrawer : TAnimationDrawer; begin //show or hide the checkbox to delay the simulation. if CheckBoxAnimation.Checked = False then begin CheckBoxDelaySimulation.Visible := False; CheckBoxDelaySimulation.Checked := False; end else begin CheckBoxDelaySimulation.Visible := True; CheckBoxDelaySimulation.Checked := True; end; //enable the the animation drawer to stop or (if necessary) resume it. if TNow > 0 then begin myAnimationDrawer:= animationDrawerQueue.FirstElement; if CheckBoxAnimation.Checked = False then begin myAnimationDrawer.enableAnimation := False; end else begin myAnimationDrawer.enableAnimation := True; if myAnimationDrawer.StatusToString = 'Passive' then myAnimationDrawer.Resume(TNow); end; end; end;

procedure TForm1.CheckBoxDelaySimulationClick (Sender: TObject);

//delay the simulation by enabling the trace function of the TOMAS-form (which is not visible to the user). begin if CheckBoxDelaySimulation.Checked = True then begin tomasform.Trace:= True; end else begin tomasform.Trace:= False; end; end;

Page 68: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

68

procedure TForm1.FormActivate (Sender: TObject);

//procedure to check whether it should start up the animation again after closing the utilization charts and whether or not this form should close when it's activated. begin if (Form6.chartFormDisabledAnimation = True) and (Form6.Visible = False) and (TNow < runtime + startupTime) then Form1.CheckBoxAnimation.Checked := True; if (Form2.quitProgramIndicator = True) and (Form2.Visible = False) then BtnCloseClick(Form1); end;

procedure TForm1.FormCreate (Sender: TObject);

//procedure to read if possible input from a text-file when the form is created. var myFile : TextFile; inputValue : String; begin //read input from a text-file if FileExists('Input1.txt') then begin AssignFile(myFile, 'Input1.txt'); Reset(myFile); ReadLn(myFile,inputValue); Form1.EditRuntime.Text :=inputValue; ReadLn(myFile,inputValue); Form1.EditStartupTime.Text :=inputValue; ReadLn(myFile,inputValue); Form1.EditNrQc.Text :=inputValue; ReadLn(myFile,inputValue); Form1.EditShipUnloadtimeQc.Text :=inputValue; ReadLn(myFile,inputValue); Form1.EditAgvLoadtimeQc.Text :=inputValue; ReadLn(myFile,inputValue); Form1.EditNrAgv.Text :=inputValue; ReadLn(myFile,inputValue); Form1.EditMinAgvCycleTime.Text :=inputValue; ReadLn(myFile,inputValue); Form1.EditMaxAgvCycleTime.Text :=inputValue; ReadLn(myFile,inputValue); Form1.EditNrAsc.Text :=inputValue; ReadLn(myFile,inputValue); Form1.EditMinAscCycleTime.Text :=inputValue; ReadLn(myFile,inputValue); Form1.EditMaxAscCycleTime.Text :=inputValue; ReadLn(myFile,inputValue); Form1.EditAgvLoadtimeAsc.Text :=inputValue; ReadLn(myFile,inputValue); if inputValue = '0' then Form1.CheckBoxSelectAsc.Checked := False else Form1.CheckBoxSelectAsc.Checked :=

True; ReadLn(myFile,inputValue); if inputValue = '3' then begin Form1.RadioButtonAgvsAtQCs3.Checked := True; end else if inputValue = '2' then begin Form1.RadioButtonAgvsAtQCs2.Checked := True; end else Form1.RadioButtonAgvsAtQCs1.Checked := True; ReadLn(myFile,inputValue); if inputValue = '0' then Form1.CheckBoxAnimation.Checked := False else Form1.CheckBoxAnimation.Checked :=

True; ReadLn(myFile,inputValue); if inputValue = '0' then Form1.CheckBoxDelaySimulation.Checked := False else

Form1.CheckBoxDelaySimulation.Checked := True; CloseFile(myFile); end; end; //procedures to give information about a certain parameter when the user places //the mouse pointer over it.

procedure TForm1.CheckBoxAnimationMouseEnter (Sender: TObject);

begin LabelInformation1.Caption:= 'The animation of the simulation enables you to see what is happening.'; end;

procedure TForm1.CheckBoxDelaySimulationMouseEnter (Sender: TObject);

begin LabelInformation1.Caption:= 'The animation can be delayed to reduce the speed of the animation.'; end;

procedure TForm1.CheckBoxRememberInputMouseEnter (Sender: TObject);

begin LabelInformation1.Caption:= 'Mark this box to save the current input values in a text file for the next time

you start the program.' ; end;

Page 69: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

69

procedure TForm1.LabelRuntimeMouseEnter (Sender: TObject);

begin LabelInformation1.Caption:= 'The simulation runtime is the timespan of the simulation. The start-up time is the

time preceding the simulation, to start up the operations '; LabelInformation2.Caption:= 'of the simulation, so that the effects of starting up will not influence the

results of the simulation.'; end;

procedure TForm1.LabelNrQcMouseEnter (Sender: TObject);

begin LabelInformation1.Caption:= 'This is the number of quay cranes in the simulation.'; end;

procedure TForm1.LabelShipUnloadtimeQcMouseEnter (Sender: TObject);

begin LabelInformation1.Caption:= 'The ship unload times for quay cranes are assumed to be negatively exponentially

distributed. The ship unload time for quay crane is'; LabelInformation2.Caption:= 'the average time a quay crane requires to unload a container from a ship.'; end;

procedure TForm1.LabelAgvLoadtimeQcMouseEnter (Sender: TObject);

begin LabelInformation1.Caption:= 'The AGV load time for quay cranes is assumed to be constant. The AGV load time for

quay crane is the time a quay crane requires'; LabelInformation2.Caption:= 'to load a container on an AGV.'; end;

procedure TForm1.LabelNrAgvMouseEnter (Sender: TObject);

begin LabelInformation1.Caption:= 'This is the number of AGVs in the simulation.'; end;

procedure TForm1.LabelMinMaxAgvCysleTimeMouseEnter (Sender: TObject);

begin LabelInformation1.Caption:= 'The AGV cycle times (including transfer times) are assumed to be uniformly

distributed between a minimum and maximum AGV cycle time.'; LabelInformation2.Caption:= 'It is the time an AGV requires to let an ASC unload a container, drive from the

ASC to a quay crane, let the quay crane load a container'; LabelInformation3.Caption:= 'and drive back to an ASC.'; end;

procedure TForm1.LabelNrAscMouseEnter (Sender: TObject);

begin LabelInformation1.Caption:= 'This is the number of ASCs in the simulation.'; end;

procedure TForm1.LabelMinMaxAscCysleTimeMouseEnter (Sender: TObject);

begin LabelInformation1.Caption:= 'The ASC cycle times (including transfer times) are assumed to be uniformly

distributed between a minimum and maximum ASC cycle time. It'; LabelInformation2.Caption:= 'is the time an ASC requires to drive from the place in the stack to the place

where it can pick up a container from an AGV, unload a'; LabelInformation3.Caption:= 'container from an AGV and drive further to a new place in the stack to store this

container.'; end;

procedure TForm1.LabelAgvLoadtimeAscMouseEnter (Sender: TObject);

begin LabelInformation1.Caption:= 'The AGV unload time for ASCs is assumed to be constant. The AGV unload time for

ASC is the time an ASC requires to unload a'; LabelInformation2.Caption:= 'container from an AGV.'; end;

procedure TForm1.LabelMouseLeave (Sender: TObject);

begin LabelInformation1.Caption:= ' '; LabelInformation2.Caption:= ' '; LabelInformation3.Caption:= ' '; end;

Initialization ;

CheckForBatchOfSimulations; end.

Page 70: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

70

Unit UtilizationCharts; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, DB, TeeData, TeEngine, ExtCtrls, TeeProcs, Chart, Series; type TForm6 = class(TForm) procedure ButtonZoomInfoClick(Sender: TObject); procedure ButtonCancelClick(Sender: TObject); procedure CheckBoxUtilAgvClick(Sender: TObject); procedure CheckBoxUtilAscClick(Sender: TObject); procedure CheckBoxUtilQcClick(Sender: TObject); procedure CheckBoxWaitAgvClick(Sender: TObject); procedure EditRangeLineChartExit(Sender: TObject); procedure FormCreate(Sender: TObject); procedure resetResultsAfterSimulationStartup; procedure ScrollBarLineChartChange(Sender: TObject); procedure setFormForSimulationStartUp; procedure setResults; private { Private declarations } public { Public declarations } chartFormDisabledAnimation : Boolean; rangeAgvChart : Integer; startupTime : Double; lastTimeLineChart : Double; numberOfQuayCranes : Integer; numberOfAgvs : Integer; numberOfAscs : Integer; averageUtilizationAgv : Double; minimumUtilizationAgv : Integer; maximumUtilizationAgv : Integer; averageNrOfWaitingAgv : Double; minimumNrOfWaitingAgv : Integer; maximumNrOfWaitingAgv : Integer; averageUtilizationQc : Double; minimumUtilizationQc : Integer; maximumUtilizationQc : Integer; averageUtilizationAsc : Double; minimumUtilizationAsc : Integer; maximumUtilizationAsc : Integer; end; var Form6 : TForm6; implementation

Page 71: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

71

procedure TForm6.setResults ;

//procedure to set the average, minimum and maximum utilization. begin labelAvAgv.Caption:= FloatToStr(Round(10*averageUtilizationAgv/numberOfAgvs*100)/10) + ' %'; labelAvAgv2.Caption:= ' (' + FloatToStr(Round(10*averageUtilizationAgv)/10) + ' out of ' +

IntToStr(numberOfAgvs) + ' AGVs)'; labelMinAgv.Caption:= FloatToStr(Round(10*minimumUtilizationAgv/numberOfAgvs*100)/10) + ' %'; labelMinAgv2.Caption:= ' (' + IntToStr(minimumUtilizationAgv) + ' out of ' + IntToStr(numberOfAgvs) + ' AGVs)'; labelMaxAgv.Caption:= FloatToStr(Round(10*maximumUtilizationAgv/numberOfAgvs*100)/10) + ' %'; labelMaxAgv2.Caption:= ' (' + IntToStr(maximumUtilizationAgv) + ' out of ' + IntToStr(numberOfAgvs) + ' AGVs)'; labelAvQc.Caption:= FloatToStr(Round(10*averageUtilizationQc/numberOfQuayCranes*100)/10) + ' %'; labelAvQc2.Caption:= ' (' + FloatToStr(Round(10*averageUtilizationQc)/10) + ' out of ' +

IntToStr(numberOfQuayCranes) + ' QCs)'; labelMinQc.Caption:= FloatToStr(Round(10*minimumUtilizationQc/numberOfQuayCranes*100)/10) + ' %'; labelMinQc2.Caption:= ' (' + IntToStr(minimumUtilizationQc) + ' out of ' + IntToStr(numberOfQuayCranes) + ' QCs)'; labelMaxQc.Caption:= FloatToStr(Round(10*maximumUtilizationQc/numberOfQuayCranes*100)/10) + ' %'; labelMaxQc2.Caption:= ' (' + IntToStr(maximumUtilizationQc) + ' out of ' + IntToStr(numberOfQuayCranes) + ' QCs)'; labelAvAsc.Caption:= FloatToStr(Round(10*averageUtilizationAsc/numberOfAscs*100)/10) + ' %'; labelAvAsc2.Caption:= ' (' + FloatToStr(Round(10*averageUtilizationAsc)/10) + ' out of ' +

IntToStr(numberOfAscs) + ' ASCs)'; labelMinAsc.Caption:= FloatToStr(Round(10*minimumUtilizationAsc/numberOfAscs*100)/10) + ' %'; labelMinAsc2.Caption:= ' (' + IntToStr(minimumUtilizationAsc) + ' out of ' + IntToStr(numberOfAscs) + ' ASCs)'; labelMaxAsc.Caption:= FloatToStr(Round(10*maximumUtilizationAsc/numberOfAscs*100)/10) + ' %'; labelMaxAsc2.Caption:= ' (' + IntToStr(maximumUtilizationAsc) + ' out of ' + IntToStr(numberOfAscs) + ' ASCs)'; end;

procedure TForm6.setFormForSimulationStartUp ;

//procedure to disable labels during the simulation startup. begin Form6.LabelSimulationStartup.Visible := True; Form6.Label3.Enabled := False; Form6.Label5.Enabled := False; Form6.Label6.Enabled := False; Form6.Label10.Enabled := False; Form6.Label11.Enabled := False; Form6.Label12.Enabled := False; Form6.Label13.Enabled := False; Form6.Label14.Enabled := False; Form6.Label15.Enabled := False; Form6.LabelAvAgv.Enabled := False; Form6.LabelMinAgv.Enabled := False; Form6.LabelMaxAgv.Enabled := False; Form6.LabelAvQc.Enabled := False; Form6.LabelMinQc.Enabled := False; Form6.LabelMaxQc.Enabled := False; Form6.LabelAvAsc.Enabled := False; Form6.LabelMinAsc.Enabled := False; Form6.LabelMaxAsc.Enabled := False; end;

Page 72: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

72

procedure TForm6.resetResultsAfterSimulationStartup ;

//procedure to enable the labels and reset the results after the simulation startup. begin minimumUtilizationAgv := numberOfAgvs; maximumUtilizationAgv := 0; minimumUtilizationQc := numberOfQuayCranes; maximumUtilizationQc := 0; minimumUtilizationAsc := numberOfAscs; maximumUtilizationAsc := 0; averageUtilizationAgv := 0; averageUtilizationQc := 0; averageUtilizationAsc := 0; Form6.LabelSimulationStartup.Visible := False; Form6.Label3.Enabled := True; Form6.Label5.Enabled := True; Form6.Label6.Enabled := True; Form6.Label10.Enabled := True; Form6.Label11.Enabled := True; Form6.Label12.Enabled := True; Form6.Label13.Enabled := True; Form6.Label14.Enabled := True; Form6.Label15.Enabled := True; Form6.LabelAvAgv.Enabled := True; Form6.LabelMinAgv.Enabled := True; Form6.LabelMaxAgv.Enabled := True; Form6.LabelAvQc.Enabled := True; Form6.LabelMinQc.Enabled := True; Form6.LabelMaxQc.Enabled := True; Form6.LabelAvAsc.Enabled := True; Form6.LabelMinAsc.Enabled := True; Form6.LabelMaxAsc.Enabled := True; end;

procedure TForm6.ScrollBarLineChartChange (Sender: TObject);

//procedure to scroll the line chart. var position : Integer; min,max : Integer; begin position := Form6.ScrollBarLineChart.Position; min := round(-startupTime + position/100 * (Form6.lastTimeLineChart - rangeAgvChart + startupTime)); max := round(-startupTime + position/100 * (Form6.lastTimeLineChart - rangeAgvChart + startupTime) +

rangeAgvChart); if min < -startupTime then begin min := round(-startupTime); max := round(-startupTime + rangeAgvChart); end; if min >= Form6.UtilizationLineChart.Axes.Bottom.Maximum then begin Form6.UtilizationLineChart.Axes.Bottom.Maximum := max; Form6.UtilizationLineChart.Axes.Bottom.Minimum := min; end else begin Form6.UtilizationLineChart.Axes.Bottom.Minimum := min; Form6.UtilizationLineChart.Axes.Bottom.Maximum := max; end; end;

Page 73: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

73

procedure TForm6.EditRangeLineChartExit (Sender: TObject);

//procedure to check the input and initiate the procedure ScrollBarLineChartChange. var valueInteger : Boolean; begin valueInteger := False; try rangeAgvChart := StrToInt(Form6.EditRangeLineChart.Text); valueInteger := True; except Form6.EditRangeLineChart.SetFocus; showmessage('Please enter a valid integer value.'); end; if valueInteger then begin if rangeAgvChart <= 0 then begin Form6.EditRangeLineChart.SetFocus; showmessage('The range of the horizontal axis can not be zero or negative.'); end else begin Form6.ScrollBarLineChartChange(Form6); end; end; end;

procedure TForm6.FormCreate (Sender: TObject);

//procedure to set up the form the moment it's created. begin rangeAgvChart := 5000; Form6.EditRangeLineChart.Text := '5000'; UtilizationLineChart.Axes.Bottom.Minimum := 0; UtilizationLineChart.Axes.Bottom.Maximum := rangeAgvChart; CheckBoxUtilAgvClick(Form6); CheckBoxWaitAgvClick(Form6); CheckBoxUtilQcClick(Form6); CheckBoxUtilAscClick(Form6); chartFormDisabledAnimation := False; end; //procedures to enable/disable one of the series in the line chart.

procedure TForm6.CheckBoxUtilAgvClick (Sender: TObject);

begin if CheckBoxUtilAgv.Checked = True then Form6.UtilizationLineChart.Series[0].Visible := True else Form6.UtilizationLineChart.Series[0].Visible := False; end;

procedure TForm6.CheckBoxWaitAgvClick (Sender: TObject);

begin if CheckBoxWaitAgv.Checked = True then Form6.UtilizationLineChart.Series[1].Visible := True else Form6.UtilizationLineChart.Series[1].Visible := False; end;

procedure TForm6.CheckBoxUtilQcClick (Sender: TObject);

begin if CheckBoxUtilQc.Checked = True then Form6.UtilizationLineChart.Series[2].Visible := True else Form6.UtilizationLineChart.Series[2].Visible := False; end;

procedure TForm6.CheckBoxUtilAscClick (Sender: TObject);

begin if CheckBoxUtilAsc.Checked = True then Form6.UtilizationLineChart.Series[3].Visible := True else Form6.UtilizationLineChart.Series[3].Visible := False; end;

procedure TForm6.ButtonZoomInfoClick (Sender: TObject); //to give information about the zooming

possibilities begin Showmessage('To zoom in on one a chart, press the left mouse button at the top left hand corner of the area you

wish to zoom in on and, maintaining the mouse button pressed, drag out the rectangle to the bottom right-hand corner of the zoom area.' + #13#10 + #13#10 + 'To scroll a across a chart, press the right mouse button and, maintaining the mouse button pressed, drag the mouse in the direction you wish to scroll the chart.' + #13#10 + #13#10 + 'To go back to the originally defined chart area, press the left mouse button anywhere on the chart area and drag up and left with the mouse button pressed.');

end;

procedure TForm6.ButtonCancelClick (Sender: TObject); //to close the form.

begin Form6.Close; end; end.

Page 74: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

74

unit CreateBatch; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm2 = class(TForm) procedure ButtonCancelClick(Sender: TObject); procedure ButtonContinueClick(Sender: TObject); procedure ButtonRetrieveLastClick(Sender: TObject); procedure startUpForm(Sender: TObject); procedure Box1Change(Sender: TObject); procedure EditExit(Sender: TObject); private { Private declarations } public { Public declarations } quitProgramIndicator : Boolean; writeInputToTextfile : Boolean; end; var Form2 : TForm2; inputOK : Boolean; mpStart1 : Double; mpStart2 : Double; mpLast1 : Double; mpLast2 : Double; mpStepsize1 : Double; mpStepsize2 : Double; mpNrSteps : Integer; implementation uses BatchParameters;

(******************************************************************************) (***** Functions & Supporting Procedures *****) (******************************************************************************)

procedure EnableSecondBlockMainParameter ;

//procedure to enable all labels and editboxes in case both a minimum and //maximum value of a parameter should be specified. begin Form2.Label5.Visible := True; Form2.Label6.Visible := True; Form2.Label21.Visible := True; Form2.Label22.Visible := True; Form2.Label23.Visible := True; Form2.Label24.Visible := True; Form2.Label25.Visible := True; Form2.Label26.Visible := True; Form2.Label27.Visible := True; Form2.Label28.Visible := True; Form2.Label29.Visible := True; Form2.Label30.Visible := True; Form2.Edit21.Visible := True; Form2.Edit22.Visible := True; Form2.Edit21.Text := Form2.Edit11.Text; Form2.Edit22.Text := Form2.Edit12.Text; Form2.Label30.Caption := Form2.Edit13.Text; Form2.EditExit(Form2); end;

Page 75: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

75

procedure DisableSecondBlockMainParameter ;

//procedure to disable all labels and editboxes in case not both a minimum and //maximum value of a parameter should be specified. begin Form2.Label5.Visible := False; Form2.Label6.Visible := False; Form2.Label21.Visible := False; Form2.Label22.Visible := False; Form2.Label23.Visible := False; Form2.Label24.Visible := False; Form2.Label25.Visible := False; Form2.Label26.Visible := False; Form2.Label27.Visible := False; Form2.Label28.Visible := False; Form2.Label29.Visible := False; Form2.Label30.Visible := False; Form2.Edit21.Visible := False; Form2.Edit22.Visible := False; end;

procedure calculateLastValue1 ;

//procedure to recalculate the value of the last first parameter of the batch of //simulations. begin mpLast1 := mpstart1 + mpStepsize1 * mpNrSteps; Form2.Label19.Caption := FloatToStr(mpLast1); end;

procedure calculateLastValue2 ;

//procedure to recalculate the value of the last second parameter of the batch of //simulations. begin mpLast2 := mpstart2 + mpStepsize2 * mpNrSteps; Form2.Label29.Caption := FloatToStr(mpLast2); end;

procedure fillMemo ;

//procedure to update the memo box. var i : Integer; parameter1,parameter2 : String; nameUnit : String; twoParameters : Boolean; begin Form2.ListBox1.Clear; twoParameters := False; if Form2.ComboBox1.ItemIndex = 5 then twoParameters := True; if Form2.ComboBox1.ItemIndex = 7 then twoParameters := True; if twoParameters = True then begin parameter1 := 'minimum ' + Form2.ComboBox1.Text; parameter2 := 'maximum ' + Form2.ComboBox1.Text; end else parameter1 := Form2.ComboBox1.Text; nameUnit := Form2.label15.Caption; Form2.ListBox1.Items.Add(' '); if Form2.ComboBox1.ItemIndex <= 0 then begin Form2.ListBox1.Items.Add(' <main parameter not defined>'); end else begin for i := 0 to mpNrSteps do begin Form2.ListBox1.Items.Add(' simulation ' + IntToStr(i+1) + ':'); Form2.ListBox1.Items.Add(' ' + parameter1 + ' = ' + FloatToStr(mpstart1+mpStepsize1*i) + ' ' + nameUnit); if twoParameters = True then Form2.ListBox1.Items.Add(' ' + parameter2 + ' = ' +

FloatToStr(mpstart2+mpStepsize2*i) + ' ' + nameUnit); end; end; Form2.ListBox1.Items.Add(' '); end;

Page 76: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

76

procedure checkInputs ;

//procedure to chech whether the input in the editboxes is ok. if not then //indicate what's wrong and set the focus to that editbox, so the user can't //deny it. var A : Extended; noStringConversionErrors : Boolean; integerValue : Boolean; begin inputOK := False; noStringConversionErrors := True; integerValue := False; if Form2.ComboBox1.ItemIndex = 1 then integerValue := True; if Form2.ComboBox1.ItemIndex = 4 then integerValue := True; if Form2.ComboBox1.ItemIndex = 6 then integerValue := True; //Catch string conversion errors if integerValue = True then begin try A := StrToInt(Form2.Edit11.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form2.Edit11.SetFocus; showmessage('Please enter an integer.'); end; end; end else begin try A := StrToFloat(Form2.Edit11.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form2.Edit11.SetFocus; end; end; end; if integerValue = True then begin try A := StrToInt(Form2.Edit12.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form2.Edit12.SetFocus; showmessage('Please enter an integer.'); end; end; end else begin try A := StrToFloat(Form2.Edit12.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form2.Edit12.SetFocus; end; end; end; try A := StrToInt(Form2.Edit13.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form2.Edit13.SetFocus; showmessage('The number of steps should be an integer.'); end; end; try A := StrToFloat(Form2.Edit21.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form2.Edit21.SetFocus; end; end; try A := StrToFloat(Form2.Edit22.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form2.Edit22.SetFocus;

Page 77: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

77

end; end; //Catch negative values if noStringConversionErrors = True then begin if StrToFloat(Form2.Edit11.Text) < 0 then begin showmessage('The start value can not be negative.'); Form2.Edit11.SetFocus; end else if StrToFloat(Form2.Edit12.Text) < 0 then begin showmessage('The stepsize can not be negative.'); Form2.Edit12.SetFocus; end else if StrToInt(Form2.Edit13.Text) < 0 then begin showmessage('The number of steps can not be negative.'); Form2.Edit13.SetFocus; end else if StrToFloat(Form2.Edit21.Text) < 0 then begin showmessage('The start value can not be negative.'); Form2.Edit21.SetFocus; end else if StrToFloat(Form2.Edit22.Text) < 0 then begin showmessage('The stepsize can not be negative.'); Form2.Edit22.SetFocus; end //indicate the input is OK. else inputOK := True; end; end;

(******************************************************************************) (***** User Interface *****) (******************************************************************************)

procedure TForm2.EditExit (Sender: TObject);

//procedure to obtain the data from the editboxes in order to recalculate //the value of the last parameters of the batch of simulations. var integerValue : Boolean; begin checkInputs; if inputOK = True then begin integerValue:= False; if ComboBox1.ItemIndex = 1 then integerValue:= True; if ComboBox1.ItemIndex = 4 then integerValue:= True; if ComboBox1.ItemIndex = 6 then integerValue:= True; if integerValue = True then begin mpStart1 := StrToInt(Edit11.Text); mpStepsize1 := StrToInt(Edit12.Text); end else begin mpStart1 := StrToFloat(Edit11.Text); mpStepsize1 := StrToFloat(Edit12.Text); end; mpNrSteps := StrToInt(Edit13.Text); mpStart2 := StrToFloat(Edit21.Text); mpStepsize2 := StrToFloat(Edit22.Text); calculateLastValue1; calculateLastValue2; Label30.Caption := Edit13.Text; //copy nr of steps fillmemo; end; end;

Page 78: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

78

procedure TForm2.Box1Change (Sender: TObject);

//procedure to enable or disable the corresponding labels and edit boxes. begin disableSecondBlockMainParameter; if ComboBox1.ItemIndex > 0 then begin Label11.Enabled := True; Label12.Enabled := True; Label13.Enabled := True; Label14.Enabled := True; Label17.Enabled := True; Label19.Enabled := True; Edit11.Enabled := True; Edit12.Enabled := True; Edit13.Enabled := True; if ComboBox1.ItemIndex = 1 then begin //number of QCs Label15.Caption := 'QCs'; Label16.Caption := 'QCs'; Label18.Caption := 'QCs'; end else if ComboBox1.ItemIndex = 4 then begin //number of AGVs Label15.Caption := 'AGVs'; Label16.Caption := 'AGVs'; Label18.Caption := 'AGVs'; end else if ComboBox1.ItemIndex = 6 then begin //number of ASCs Label15.Caption := 'ASCs'; Label16.Caption := 'ASCs'; Label18.Caption := 'ASCs'; end else begin Label15.Caption := 'sec'; Label16.Caption := 'sec'; Label18.Caption := 'sec'; end; if ComboBox1.ItemIndex = 5 then begin //AGV Cycle time EnableSecondBlockMainParameter; Label5.Caption := 'Minimum AGV cycle time:'; Label6.Caption := 'Maximum AGV cycle time:'; end else if ComboBox1.ItemIndex = 7 then begin //ASC Cycle time EnableSecondBlockMainParameter; Label5.Caption := 'Minimum ASC cycle time:'; Label6.Caption := 'Maximum ASC cycle time:'; end; end else begin Label11.Enabled := False; Label12.Enabled := False; Label13.Enabled := False; Label14.Enabled := False; Label17.Enabled := False; Label19.Enabled := False; Edit11.Enabled := False; Edit12.Enabled := False; Edit13.Enabled := False; Edit11.Text := '0'; Edit12.Text := '0'; Edit13.Text := '0'; mpstart1 := 0; mpstart2 := 0; mpStepsize1 := 0; mpStepsize2 := 0; mpNrSteps := 0; Label15.Caption := ''; Label16.Caption := ''; Label18.Caption := ''; Label19.Caption := '0'; end; Form2.EditExit(Form2); end;

procedure TForm2.ButtonCancelClick (Sender: TObject);

//procedure to close this form (without closing the entire program). begin Form2.quitProgramIndicator := False; Form2.Close; end;

procedure TForm2.ButtonContinueClick (Sender: TObject);

//procedure to write the input values to a text.file, copy them to form3 and //show form3. var MyFile : TextFile; begin

Page 79: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

79

if Form2.ComboBox1.ItemIndex > 0 then begin checkInputs; //Here in case the input retreived

from the file is wrong, therefore maybe unnecesary. if inputOK = True then begin if Form2.writeInputToTextfile= True then begin //write current input main parameter to a text-file AssignFile(myFile, 'Input2.txt'); ReWrite(myFile); WriteLn(myFile, (ComboBox1.ItemIndex)); WriteLn(myFile, (Edit11.Text)); WriteLn(myFile, (Edit12.Text)); WriteLn(myFile, (Edit13.Text)); if Edit21.Visible = True then begin WriteLn(myFile, (Edit21.Text)); WriteLn(myFile, (Edit22.Text)); end else begin WriteLn(myFile, ('1')); WriteLn(myFile, ('0')); mpStart2 := 0; //necesary to be able to see in Form3 whether there are too much zeros (in checkInputs). end; CloseFile(myFile); end; //copy the values for the main parameter to be varied in the simulation to Form3 Form3.batchAlreadyActivatedBefore := True; if Form3.mainParameter <> Form2.ComboBox1.ItemIndex then Form3.batchAlreadyActivatedBefore:= False; Form3.mainParameter := Form2.ComboBox1.ItemIndex; Form3.nameMainParameter := Form2.ComboBox1.Text; Form3.unitMainParameter := Form2.label15.Caption; Form3.mpStart1 := mpStart1; Form3.mpStart2 := mpStart2; Form3.mpLast1 := mpLast1; Form3.mpLast2 := mpLast2; Form3.mpStepsize1 := mpStepsize1; Form3.mpStepsize2 := mpStepsize2; Form3.mpNrSteps := mpNrSteps; Form3.Visible := True; fillMemo; end; end else begin Form2.ComboBox1.ItemIndex:= -1; Form3.batchAlreadyActivatedBefore := True; if Form3.mainParameter <> Form2.ComboBox1.ItemIndex then Form3.batchAlreadyActivatedBefore:= False; Form3.mainParameter := Form2.ComboBox1.ItemIndex; Form3.mpNrSteps := mpNrSteps; Form3.Visible := True; fillMemo; end; end;

Page 80: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

80

procedure TForm2.ButtonRetrieveLastClick (Sender: TObject);

//procedure to obtain the input values from a text.file var myFile : TextFile; inputValue : string; begin if FileExists('Input2.txt') then begin AssignFile(myFile, 'Input2.txt'); Reset(myFile); ReadLn(myFile,inputValue); ComboBox1.ItemIndex := StrToInt(inputValue); ReadLn(myFile,inputValue); Edit11.Text := inputValue; ReadLn(myFile,inputValue); Edit12.Text := inputValue; ReadLn(myFile,inputValue); Edit13.Text := inputValue; Form2.Box1Change(Form2); ReadLn(myFile,inputValue); Edit21.Text := inputValue; ReadLn(myFile,inputValue); Edit22.Text := inputValue; CloseFile(myFile); EditExit(Form2); ButtonContinue.SetFocus; end else begin showmessage('The file with the input parameters of the last session is not available.'); end; end;

procedure TForm2.startUpForm (Sender: TObject);

//procedure to check whether this form should close, form3 should close or //ButtonRetrieveLast should be enabled. begin if (Form3.quitProgramIndicator = True) and (Form3.Visible = False) then Form2.close; if Form3.Visible = True then Form3.ButtonCancelClick(Form3); if FileExists('Input2.txt') then form2.ButtonRetrieveLast.Enabled := True; Form2.quitProgramIndicator := True; end; end.

Page 81: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

81

unit BatchParameters; interface

uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Tomas;

type TForm3 = class(TForm) procedure ButtonAddCaseClick(Sender: TObject); procedure ButtonCancelClick(Sender: TObject); procedure ButtonDeleteCaseClick(Sender: TObject); procedure ButtonNextClick(Sender: TObject); procedure ButtonOKClick(Sender: TObject); procedure ButtonPrevClick(Sender: TObject); procedure CheckBox10Click(Sender: TObject); procedure CheckBox11Click(Sender: TObject); procedure CheckBox12Click(Sender: TObject); procedure CheckBox1Click(Sender: TObject); procedure CheckBox2Click(Sender: TObject); procedure CheckBox3Click(Sender: TObject); procedure CheckBox4Click(Sender: TObject); procedure CheckBox5Click(Sender: TObject); procedure CheckBox6Click(Sender: TObject); procedure CheckBox7Click(Sender: TObject); procedure CheckBox8Click(Sender: TObject); procedure CheckBox9Click(Sender: TObject); procedure EditExit(Sender: TObject); procedure FormActivate(Sender: TObject);

private { Private declarations } public { Public declarations } mainParameter : Integer; {1,2,3,4,5,6,7,8} batchAlreadyActivatedBefore : Boolean; quitProgramIndicator: Boolean; mpStart1 : Double; mpStart2 : Double; mpLast1 : Double; mpLast2 : Double; mpStepsize1 : Double; mpStepsize2 : Double; mpNrSteps : Integer; nameMainParameter : String; unitMainParameter : String; end;

simulationCase = class(TomasElement) //a simulationCase can be a Case of a simulation itself. The first element will contain constants

public name : String; explanation : String; runtime : Double; startupTime : Double; numberOfQcs : Integer; shipUnloadTimeForQc : Double; AGVLoadTimeForQc : Double; numberOfAgvs : Integer; MinAgvCycleTime : Double; MaxAgvCycleTime : Double; numberOfAscs : Integer; MinAscCycleTime : Double; MaxAscCycleTime : Double; AgvUnloadTimeForAsc : Double; AscSelectionForAgv : Integer; {0,1} QcSelectionForAgv : Integer; {1,2,3} published end;

var Form3 : TForm3; casesQueue : TomasQueue; currentCase : Integer; inputOK : Boolean; MinMaxCycleTimesOK : Boolean; //to check whether the minimum and maximum cycle times of AGVs and

ASCs are OK. allowSavingAndMemo : Boolean; //to prevent the programm from filling the memo 12 times in a row

and saving 'previous' parameters when displaying the 'current' ones. implementation

Page 82: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

82

procedure fillMemo ;

//procedure to update the memo box. var i,j : Integer; parameter1 : String; parameter2 : String; printLine : String; twoParameters : Boolean; mySimulationCase : SimulationCase; begin if allowSavingAndMemo then begin Form3.ListBox1.Clear; twoParameters:= False; if Form3.mainParameter = 5 then twoParameters:= True; if Form3.mainParameter = 7 then twoParameters:= True; if twoParameters = True then begin parameter1 := 'minimum ' + Form3.nameMainParameter; parameter2 := 'maximum ' + Form3.nameMainParameter; end else parameter1 := Form3.nameMainParameter; Form3.ListBox1.Items.Add('Constants:'); if Form3.batchAlreadyActivatedBefore = False then begin Form3.ListBox1.Items.Add(' <not defined yet>'); end else begin //display contants mySimulationCase := casesQueue.Element(0); Form3.ListBox1.Items.Add(' simulation runtime = ' + FloatToStr(mySimulationCase.runtime)

+' sec'); Form3.ListBox1.Items.Add(' simulation startup time = ' + FloatToStr(mySimulationCase.startupTime)

+' sec'); if (Form3.CheckBox1.Checked = False) and (Form3.mainParameter <> 1) then Form3.ListBox1.Items.Add('

number of QCs = ' + IntToStr(mySimulationCase.numberOfQcs) +' QCs'); if (Form3.CheckBox2.Checked = False) and (Form3.mainParameter <> 2) then Form3.ListBox1.Items.Add('

ship unload time for QC = ' + FloatToStr(mySimulationCase.shipUnloadTimeForQc)+' sec'); if (Form3.CheckBox3.Checked = False) and (Form3.mainParameter <> 3) then Form3.ListBox1.Items.Add('

AGV load time for QC = ' + FloatToStr(mySimulationCase.AGVLoadTimeForQc) +' sec'); if (Form3.CheckBox4.Checked = False) and (Form3.mainParameter <> 4) then Form3.ListBox1.Items.Add('

number of AGVs = ' + IntToStr(mySimulationCase.numberOfAgvs) +' AGVs'); if (Form3.CheckBox5.Checked = False) and (Form3.mainParameter <> 5) then Form3.ListBox1.Items.Add('

minimum AGV cycle time = ' + FloatToStr(mySimulationCase.MinAgvCycleTime) +' sec'); if (Form3.CheckBox6.Checked = False) and (Form3.mainParameter <> 5) then Form3.ListBox1.Items.Add('

maximum AGV cycle time = ' + FloatToStr(mySimulationCase.MaxAgvCycleTime) +' sec'); if (Form3.CheckBox7.Checked = False) and (Form3.mainParameter <> 6) then Form3.ListBox1.Items.Add('

number of ASCs = ' + IntToStr(mySimulationCase.numberOfAscs) +' ASCs'); if (Form3.CheckBox8.Checked = False) and (Form3.mainParameter <> 7) then Form3.ListBox1.Items.Add('

minimum ASC cycle time = ' + FloatToStr(mySimulationCase.MinAscCycleTime) +' sec'); if (Form3.CheckBox9.Checked = False) and (Form3.mainParameter <> 7) then Form3.ListBox1.Items.Add('

maximum ASC cycle time = ' + FloatToStr(mySimulationCase.MaxAscCycleTime) +' sec'); if (Form3.CheckBox10.Checked = False) and (Form3.mainParameter <> 8) then Form3.ListBox1.Items.Add('

AGV unload time for ASC = ' + FloatToStr(mySimulationCase.AgvUnloadTimeForAsc)+' sec'); if (Form3.CheckBox11.Checked = False) then begin if mySimulationCase.AscSelectionForAgv = 0 then begin Form3.ListBox1.Items.Add(' ASC selection =

random (uniformly distributed)'); end else Form3.ListBox1.Items.Add(' ASC selection = based on work load ASC'); end; if (Form3.CheckBox12.Checked = False) then begin if mySimulationCase.QcSelectionForAgv = 1 then begin Form3.ListBox1.Items.Add(' QC selection =

none (central pool at QC area)'); end else if mySimulationCase.QcSelectionForAgv = 2 then begin Form3.ListBox1.Items.Add(' QC

selection = at arrival QC area'); end else Form3.ListBox1.Items.Add(' QC selection = at departure ASC'); end; end;

Page 83: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

83

Form3.ListBox1.Items.Add(''); //display case-specific parameters if Form3.batchAlreadyActivatedBefore = True then begin if casesQueue.Length > 1 then begin for j := 1 to casesQueue.Length - 1 do begin mySimulationCase := casesQueue.Element(j); Form3.ListBox1.Items.Add(mySimulationCase.name); if (Form3.CheckBox1.Checked = False) and (Form3.CheckBox2.Checked = False) and (Form3.CheckBox3.Checked

= False) and (Form3.CheckBox4.Checked = False) and (Form3.CheckBox5.Checked = False) and (Form3.CheckBox6.Checked = False) and (Form3.CheckBox7.Checked = False) and (Form3.CheckBox8.Checked = False) and (Form3.CheckBox9.Checked = False) and (Form3.CheckBox10.Checked = False) and (Form3.CheckBox11.Checked = False) and (Form3.CheckBox12.Checked = False) then begin

if Form3.mainParameter <> -1 then Form3.ListBox1.Items.Add(' <no case-specific parameters defined>') else Form3.ListBox1.Items.Add(' <no specific parameters defined>');

end else begin if Form3.CheckBox1.Checked = True then Form3.ListBox1.Items.Add(' number of QCs = '

+ IntToStr(mySimulationCase.numberOfQcs) +' QCs'); if Form3.CheckBox2.Checked = True then Form3.ListBox1.Items.Add(' ship unload time for QC = '

+ FloatToStr(mySimulationCase.shipUnloadTimeForQc)+' sec'); if Form3.CheckBox3.Checked = True then Form3.ListBox1.Items.Add(' AGV load time for QC = '

+ FloatToStr(mySimulationCase.AGVLoadTimeForQc) +' sec'); if Form3.CheckBox4.Checked = True then Form3.ListBox1.Items.Add(' number of AGVs = '

+ IntToStr(mySimulationCase.numberOfAgvs) +' AGVs'); if Form3.CheckBox5.Checked = True then Form3.ListBox1.Items.Add(' minimum AGV cycle time = ' +

FloatToStr(mySimulationCase.MinAgvCycleTime) +' sec'); if Form3.CheckBox6.Checked = True then Form3.ListBox1.Items.Add(' maximum AGV cycle time = '

+ FloatToStr(mySimulationCase.MaxAgvCycleTime) +' sec'); if Form3.CheckBox7.Checked = True then Form3.ListBox1.Items.Add(' number of ASCs = '

+ IntToStr(mySimulationCase.numberOfAscs) +' ASCs'); if Form3.CheckBox8.Checked = True then Form3.ListBox1.Items.Add(' minimum ASC cycle time = '

+ FloatToStr(mySimulationCase.MinAscCycleTime) +' sec'); if Form3.CheckBox9.Checked = True then Form3.ListBox1.Items.Add(' maximum ASC cycle time = '

+ FloatToStr(mySimulationCase.MaxAscCycleTime) +' sec'); if Form3.CheckBox10.Checked = True then Form3.ListBox1.Items.Add(' AGV unload time for ASC = '

+ FloatToStr(mySimulationCase.AgvUnloadTimeForAsc)+' sec'); if Form3.CheckBox11.Checked = True then begin if mySimulationCase.AscSelectionForAgv = 0 then begin Form3.ListBox1.Items.Add(' ASC

selection = random (uniformly distributed)'); end else Form3.ListBox1.Items.Add(' ASC selection = based on work load ASC'); end; if Form3.CheckBox12.Checked = True then begin if mySimulationCase.QcSelectionForAgv = 1 then begin Form3.ListBox1.Items.Add(' QC selection

= none (central pool at QC area)'); end else if mySimulationCase.QcSelectionForAgv = 2 then begin Form3.ListBox1.Items.Add(' QC

selection = at arrival QC area'); end else Form3.ListBox1.Items.Add(' QC selection = at departure ASC'); end; end; Form3.ListBox1.Items.Add(''); if Form3.mainParameter > 0 then begin //display simulation parameters for i := 0 to Form3.mpNrSteps do begin Form3.ListBox1.Items.Add(' simulation ' +IntToStr(j) + '.' + IntToStr(i+1) + ':'); Form3.ListBox1.Items.Add(' ' + parameter1 + ' = ' +

FloatToStr(Form3.mpstart1+Form3.mpStepsize1*i) + ' ' + Form3.unitMainParameter); if twoParameters = True then Form3.ListBox1.Items.Add(' ' + parameter2 + ' = ' +

FloatToStr(Form3.mpstart2+Form3.mpStepsize2*i) + ' ' + Form3.unitMainParameter); end; Form3.ListBox1.Items.Add(''); end; end; end; end; end; end;

Page 84: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

84

procedure WriteContentBatchToFile ;

//procedure to write the content of all simulations of this batch to a text file //it is basically a copy of the procedure fillmemo. var myFile : TextFile; i,j : Integer; parameter1 : String; parameter2 : String; printLine : String; twoParameters : Boolean; mySimulationCase : SimulationCase; begin AssignFile(myFile, 'Content batch of simulations.txt'); ReWrite(myFile); twoParameters:= False; if Form3.mainParameter = 5 then twoParameters:= True; if Form3.mainParameter = 7 then twoParameters:= True; if twoParameters = True then begin parameter1 := 'minimum ' + Form3.nameMainParameter; parameter2 := 'maximum ' + Form3.nameMainParameter; end else parameter1 := Form3.nameMainParameter; WriteLn(myFile, 'Constants:'); //display contants mySimulationCase := casesQueue.Element(0); WriteLn(myFile,(' simulation runtime = ' + FloatToStr(mySimulationCase.runtime) +' sec')); WriteLn(myFile,(' simulation startup time = ' + FloatToStr(mySimulationCase.startupTime) +' sec')); if (Form3.CheckBox1.Checked = False) and (Form3.mainParameter <> 1) then WriteLn(myFile,(' number of QCs

= ' + IntToStr(mySimulationCase.numberOfQcs) +' QCs')); if (Form3.CheckBox2.Checked = False) and (Form3.mainParameter <> 2) then WriteLn(myFile,(' ship unload

time for QC = ' + FloatToStr(mySimulationCase.shipUnloadTimeForQc)+' sec')); if (Form3.CheckBox3.Checked = False) and (Form3.mainParameter <> 3) then WriteLn(myFile,(' AGV load time

for QC = ' + FloatToStr(mySimulationCase.AGVLoadTimeForQc) +' sec')); if (Form3.CheckBox4.Checked = False) and (Form3.mainParameter <> 4) then WriteLn(myFile,(' number of

AGVs = ' + IntToStr(mySimulationCase.numberOfAgvs) +' AGVs')); if (Form3.CheckBox5.Checked = False) and (Form3.mainParameter <> 5) then WriteLn(myFile,(' minimum AGV

cycle time = ' + FloatToStr(mySimulationCase.MinAgvCycleTime) +' sec')); if (Form3.CheckBox6.Checked = False) and (Form3.mainParameter <> 5) then WriteLn(myFile,(' maximum AGV

cycle time = ' + FloatToStr(mySimulationCase.MaxAgvCycleTime) +' sec')); if (Form3.CheckBox7.Checked = False) and (Form3.mainParameter <> 6) then WriteLn(myFile,(' number of ASCs

= ' + IntToStr(mySimulationCase.numberOfAscs) +' ASCs')); if (Form3.CheckBox8.Checked = False) and (Form3.mainParameter <> 7) then WriteLn(myFile,(' minimum ASC

cycle time = ' + FloatToStr(mySimulationCase.MinAscCycleTime) +' sec')); if (Form3.CheckBox9.Checked = False) and (Form3.mainParameter <> 7) then WriteLn(myFile,(' maximum ASC

cycle time = ' + FloatToStr(mySimulationCase.MaxAscCycleTime) +' sec')); if (Form3.CheckBox10.Checked = False) and (Form3.mainParameter <> 8) then WriteLn(myFile,(' AGV unload

time for ASC = ' + FloatToStr(mySimulationCase.AgvUnloadTimeForAsc)+' sec')); if (Form3.CheckBox11.Checked = False) then begin if mySimulationCase.AscSelectionForAgv = 0 then begin WriteLn(myFile,(' ASC selection = random

(uniformly distributed)')); end else WriteLn(myFile,(' ASC selection = based on work load ASC')); end; if (Form3.CheckBox12.Checked = False) then begin if mySimulationCase.QcSelectionForAgv = 1 then begin WriteLn(myFile,(' QC selection = none (central

pool at QC area)')); end else if mySimulationCase.QcSelectionForAgv = 2 then begin WriteLn(myFile,(' QC selection = at

arrival QC area')); end else WriteLn(myFile,(' QC selection = at departure ASC')); end; WriteLn(myFile,('')); //display case-specific parameters if casesQueue.Length > 1 then begin for j := 1 to casesQueue.Length - 1 do begin mySimulationCase := casesQueue.Element(j); WriteLn(myFile,(mySimulationCase.name)); if Form3.CheckBox1.Checked = True then WriteLn(myFile,(' number of QCs = ' +

IntToStr(mySimulationCase.numberOfQcs) +' QCs')); if Form3.CheckBox2.Checked = True then WriteLn(myFile,(' ship unload time for QC = ' +

FloatToStr(mySimulationCase.shipUnloadTimeForQc)+' sec')); if Form3.CheckBox3.Checked = True then WriteLn(myFile,(' AGV load time for QC = ' +

FloatToStr(mySimulationCase.AGVLoadTimeForQc) +' sec')); if Form3.CheckBox4.Checked = True then WriteLn(myFile,(' number of AGVs = ' +

IntToStr(mySimulationCase.numberOfAgvs) +' AGVs')); if Form3.CheckBox5.Checked = True then WriteLn(myFile,(' minimum AGV cycle time = ' +

FloatToStr(mySimulationCase.MinAgvCycleTime) +' sec')); if Form3.CheckBox6.Checked = True then WriteLn(myFile,(' maximum AGV cycle time = ' +

FloatToStr(mySimulationCase.MaxAgvCycleTime) +' sec')); if Form3.CheckBox7.Checked = True then WriteLn(myFile,(' number of ASCs = ' +

Page 85: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

85

IntToStr(mySimulationCase.numberOfAscs) +' ASCs')); if Form3.CheckBox8.Checked = True then WriteLn(myFile,(' minimum ASC cycle time = ' +

FloatToStr(mySimulationCase.MinAscCycleTime) +' sec')); if Form3.CheckBox9.Checked = True then WriteLn(myFile,(' maximum ASC cycle time = ' +

FloatToStr(mySimulationCase.MaxAscCycleTime) +' sec')); if Form3.CheckBox10.Checked = True then WriteLn(myFile,(' AGV unload time for ASC = ' +

FloatToStr(mySimulationCase.AgvUnloadTimeForAsc)+' sec')); if Form3.CheckBox11.Checked = True then begin if mySimulationCase.AscSelectionForAgv = 0 then begin WriteLn(myFile,(' ASC selection = random

(uniformly distributed)')); end else WriteLn(myFile,(' ASC selection = based on work load ASC')); end; if Form3.CheckBox12.Checked = True then begin if mySimulationCase.QcSelectionForAgv = 1 then begin WriteLn(myFile,(' QC selection = none

(central pool at QC area))')); end else if mySimulationCase.QcSelectionForAgv = 2 then begin WriteLn(myFile,(' QC selection = at

arrival QC area')); end else WriteLn(myFile,(' QC selection = at departure ASC')); end; if Form3.mainParameter > 0 then begin WriteLn(myFile,('')); //display simulation parameters for i := 0 to Form3.mpNrSteps do begin WriteLn(myFile,(' simulation ' +IntToStr(j) + '.' + IntToStr(i+1) + ':')); WriteLn(myFile,(' ' + parameter1 + ' = ' + FloatToStr(Form3.mpstart1+Form3.mpStepsize1*i) + ' '

+ Form3.unitMainParameter)); if twoParameters = True then WriteLn(myFile,(' ' + parameter2 + ' = ' +

FloatToStr(Form3.mpstart2+Form3.mpStepsize2*i) + ' ' + Form3.unitMainParameter)); end; end; WriteLn(myFile,('')); end; end; CloseFile(myFile); end;

procedure TForm3.CheckBox1Click (Sender: TObject);

//these procedures enable/disable editboxes and labels for the corresponding //parameters and show their values. var myContants : SimulationCase; begin fillMemo; if currentCase > 0 then begin if CheckBox1.Checked then begin LabelNrQc.Enabled := True; LabelNrQcUnit.Enabled := True; EditNrQc.Visible := True; EditNrQc.Enabled := True; myContants := casesQueue.Element(currentCase); EditNrQc.Text := IntToStr(myContants.numberOfQcs); end else begin LabelNrQc.Enabled := False; LabelNrQcUnit.Enabled := False; EditNrQc.Enabled := False; myContants := casesQueue.Element(0); EditNrQc.Text := IntToStr(myContants.numberOfQcs); end; end else begin if CheckBox1.Checked then begin LabelNrQc.Enabled := False; LabelNrQcUnit.Enabled := False; EditNrQc.Visible := False; EditNrQc.Enabled := False; //seems dubble, but is necesary for checkinputs end else begin LabelNrQc.Enabled := True; LabelNrQcUnit.Enabled := True; EditNrQc.Visible := True; EditNrQc.Enabled := True; end; end; end;

procedure TForm3.CheckBox2Click (Sender: TObject);

var myContants : SimulationCase; begin fillMemo; if currentCase > 0 then begin if CheckBox2.Checked then begin LabelShipUnloadtimeQc.Enabled := True;

Page 86: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

86

LabelShipUnloadtimeQcUnit.Enabled := True; EditShipUnloadtimeQc.Visible := True; EditShipUnloadtimeQc.Enabled := True; myContants := casesQueue.Element(currentCase); EditShipUnloadtimeQc.Text := FloatToStr(myContants.shipUnloadTimeForQc); end else begin LabelShipUnloadtimeQc.Enabled := False; LabelShipUnloadtimeQcUnit.Enabled := False; EditShipUnloadtimeQc.Enabled := False; myContants := casesQueue.Element(0); EditShipUnloadtimeQc.Text := FloatToStr(myContants.shipUnloadTimeForQc); end; end else begin if CheckBox2.Checked then begin LabelShipUnloadtimeQc.Enabled := False; LabelShipUnloadtimeQcUnit.Enabled := False; EditShipUnloadtimeQc.Visible := False; EditShipUnloadtimeQc.Enabled := False; end else begin LabelShipUnloadtimeQc.Enabled := True; LabelShipUnloadtimeQcUnit.Enabled := True; EditShipUnloadtimeQc.Visible := True; EditShipUnloadtimeQc.Enabled := True; end; end; end;

procedure TForm3.CheckBox3Click (Sender: TObject);

var myContants : SimulationCase; begin fillMemo; if currentCase > 0 then begin if CheckBox3.Checked then begin LabelAgvLoadtimeQc.Enabled := True; LabelAgvLoadtimeQcUnit.Enabled := True; EditAgvLoadtimeQc.Visible := True; EditAgvLoadtimeQc.Enabled := True; myContants := casesQueue.Element(currentCase); EditAgvLoadtimeQc.Text := FloatToStr(myContants.AGVLoadTimeForQc); end else begin LabelAgvLoadtimeQc.Enabled := False; LabelAgvLoadtimeQcUnit.Enabled := False; EditAgvLoadtimeQc.Enabled := False; myContants := casesQueue.Element(0); EditAgvLoadtimeQc.Text := FloatToStr(myContants.AGVLoadTimeForQc); end; end else begin if CheckBox3.Checked then begin LabelAgvLoadtimeQc.Enabled := False; LabelAgvLoadtimeQcUnit.Enabled := False; EditAgvLoadtimeQc.Visible := False; EditAgvLoadtimeQc.Enabled := False; end else begin LabelAgvLoadtimeQc.Enabled := True; LabelAgvLoadtimeQcUnit.Enabled := True; EditAgvLoadtimeQc.Visible := True; EditAgvLoadtimeQc.Enabled := True; end; end; end;

Page 87: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

87

procedure TForm3.CheckBox4Click (Sender: TObject);

var myContants : SimulationCase; begin fillMemo; if currentCase > 0 then begin if CheckBox4.Checked then begin LabelNrAgv.Enabled := True; LabelNrAgvUnit.Enabled := True; EditNrAgv.Visible := True; EditNrAgv.Enabled := True; myContants := casesQueue.Element(currentCase); EditNrAgv.Text := IntToStr(myContants.numberOfAgvs); end else begin LabelNrAgv.Enabled := False; LabelNrAgvUnit.Enabled := False; EditNrAgv.Enabled := False; myContants := casesQueue.Element(0); EditNrAgv.Text := IntToStr(myContants.numberOfAgvs); end; end else begin if CheckBox4.Checked then begin LabelNrAgv.Enabled := False; LabelNrAgvUnit.Enabled := False; EditNrAgv.Visible := False; EditNrAgv.Enabled := False; end else begin LabelNrAgv.Enabled := True; LabelNrAgvUnit.Enabled := True; EditNrAgv.Visible := True; EditNrAgv.Enabled := True; end; end; end;

procedure TForm3.CheckBox5Click (Sender: TObject);

var myContants : SimulationCase; begin fillMemo; if currentCase > 0 then begin if CheckBox5.Checked then begin LabelMinAgvCycleTime.Enabled := True; LabelMinAgvCycleTimeUnit.Enabled := True; EditMinAgvCycleTime.Visible := True; EditMinAgvCycleTime.Enabled := True; myContants := casesQueue.Element(currentCase); EditMinAgvCycleTime.Text := FloatToStr(myContants.MinAgvCycleTime); end else begin LabelMinAgvCycleTime.Enabled := False; LabelMinAgvCycleTimeUnit.Enabled := False; EditMinAgvCycleTime.Enabled := False; myContants := casesQueue.Element(0); EditMinAgvCycleTime.Text := FloatToStr(myContants.MinAgvCycleTime); end; end else begin if CheckBox5.Checked then begin LabelMinAgvCycleTime.Enabled := False; LabelMinAgvCycleTimeUnit.Enabled := False; EditMinAgvCycleTime.Visible := False; EditMinAgvCycleTime.Enabled := False; end else begin LabelMinAgvCycleTime.Enabled := True; LabelMinAgvCycleTimeUnit.Enabled := True; EditMinAgvCycleTime.Visible := True; EditMinAgvCycleTime.Enabled := True; end; end; end;

Page 88: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

88

procedure TForm3.CheckBox6Click (Sender: TObject);

var myContants : SimulationCase; begin fillMemo; if currentCase > 0 then begin if CheckBox6.Checked then begin LabelMaxAgvCycleTime.Enabled := True; LabelMaxAgvCycleTimeUnit.Enabled := True; EditMaxAgvCycleTime.Visible := True; EditMaxAgvCycleTime.Enabled := True; myContants := casesQueue.Element(currentCase); EditMaxAgvCycleTime.Text := FloatToStr(myContants.MaxAgvCycleTime); end else begin LabelMaxAgvCycleTime.Enabled := False; LabelMaxAgvCycleTimeUnit.Enabled := False; EditMaxAgvCycleTime.Enabled := False; myContants := casesQueue.Element(0); EditMaxAgvCycleTime.Text := FloatToStr(myContants.MaxAgvCycleTime); end; end else begin if CheckBox6.Checked then begin LabelMaxAgvCycleTime.Enabled := False; LabelMaxAgvCycleTimeUnit.Enabled := False; EditMaxAgvCycleTime.Visible := False; EditMaxAgvCycleTime.Enabled := False; end else begin LabelMaxAgvCycleTime.Enabled := True; LabelMaxAgvCycleTimeUnit.Enabled := True; EditMaxAgvCycleTime.Visible := True; EditMaxAgvCycleTime.Enabled := True; end; end; end;

procedure TForm3.CheckBox7Click (Sender: TObject);

var myContants : SimulationCase; begin fillMemo; if currentCase > 0 then begin if CheckBox7.Checked then begin LabelNrAsc.Enabled := True; LabelNrAscUnit.Enabled := True; EditNrAsc.Visible := True; EditNrAsc.Enabled := True; myContants := casesQueue.Element(currentCase); EditNrAsc.Text := IntToStr(myContants.numberOfAscs); end else begin LabelNrAsc.Enabled := False; LabelNrAscUnit.Enabled := False; EditNrAsc.Enabled := False; myContants := casesQueue.Element(0); EditNrAsc.Text := IntToStr(myContants.numberOfAscs); end; end else begin if CheckBox7.Checked then begin LabelNrAsc.Enabled := False; LabelNrAscUnit.Enabled := False; EditNrAsc.Visible := False; EditNrAsc.Enabled := False; end else begin LabelNrAsc.Enabled := True; LabelNrAscUnit.Enabled := True; EditNrAsc.Visible := True; EditNrAsc.Enabled := True; end; end; end;

Page 89: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

89

procedure TForm3.CheckBox8Click (Sender: TObject);

var myContants : SimulationCase; begin fillMemo; if currentCase > 0 then begin if CheckBox8.Checked then begin LabelMinAscCycleTime.Enabled := True; LabelMinAscCycleTimeUnit.Enabled := True; EditMinAscCycleTime.Visible := True; EditMinAscCycleTime.Enabled := True; myContants := casesQueue.Element(currentCase); EditMinAscCycleTime.Text := FloatToStr(myContants.MinAscCycleTime); end else begin LabelMinAscCycleTime.Enabled := False; LabelMinAscCycleTimeUnit.Enabled := False; EditMinAscCycleTime.Enabled := False; myContants := casesQueue.Element(0); EditMinAscCycleTime.Text := FloatToStr(myContants.MinAscCycleTime); end; end else begin if CheckBox8.Checked then begin LabelMinAscCycleTime.Enabled := False; LabelMinAscCycleTimeUnit.Enabled := False; EditMinAscCycleTime.Visible := False; EditMinAscCycleTime.Enabled := False; end else begin LabelMinAscCycleTime.Enabled := True; LabelMinAscCycleTimeUnit.Enabled := True; EditMinAscCycleTime.Visible := True; EditMinAscCycleTime.Enabled := True; end; end; end;

procedure TForm3.CheckBox9Click (Sender: TObject);

var myContants : SimulationCase; begin fillMemo; if currentCase > 0 then begin if CheckBox9.Checked then begin LabelMaxAscCycleTime.Enabled := True; LabelMaxAscCycleTimeUnit.Enabled := True; EditMaxAscCycleTime.Visible := True; EditMaxAscCycleTime.Enabled := True; myContants := casesQueue.Element(currentCase); EditMaxAscCycleTime.Text := FloatToStr(myContants.MaxAscCycleTime); end else begin LabelMaxAscCycleTime.Enabled := False; LabelMaxAscCycleTimeUnit.Enabled := False; EditMaxAscCycleTime.Enabled := False; myContants := casesQueue.Element(0); EditMaxAscCycleTime.Text := FloatToStr(myContants.MaxAscCycleTime); end; end else begin if CheckBox9.Checked then begin LabelMaxAscCycleTime.Enabled := False; LabelMaxAscCycleTimeUnit.Enabled := False; EditMaxAscCycleTime.Visible := False; EditMaxAscCycleTime.Enabled := False; end else begin LabelMaxAscCycleTime.Enabled := True; LabelMaxAscCycleTimeUnit.Enabled := True; EditMaxAscCycleTime.Visible := True; EditMaxAscCycleTime.Enabled := True; end; end; end;

Page 90: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

90

procedure TForm3.CheckBox10Click (Sender: TObject);

var myContants : SimulationCase; begin fillMemo; if currentCase > 0 then begin if CheckBox10.Checked then begin LabelAgvLoadtimeAsc.Enabled := True; LabelAgvLoadtimeAscUnit.Enabled := True; EditAgvLoadtimeAsc.Visible := True; EditAgvLoadtimeAsc.Enabled := True; myContants := casesQueue.Element(currentCase); EditAgvLoadtimeAsc.Text := FloatToStr(myContants.AgvUnloadTimeForAsc); end else begin LabelAgvLoadtimeAsc.Enabled := False; LabelAgvLoadtimeAscUnit.Enabled := False; EditAgvLoadtimeAsc.Enabled := False; myContants := casesQueue.Element(0); EditAgvLoadtimeAsc.Text := FloatToStr(myContants.AgvUnloadTimeForAsc); end; end else begin if CheckBox10.Checked then begin LabelAgvLoadtimeAsc.Enabled := False; LabelAgvLoadtimeAscUnit.Enabled := False; EditAgvLoadtimeAsc.Visible := False; EditAgvLoadtimeAsc.Enabled := False; end else begin LabelAgvLoadtimeAsc.Enabled := True; LabelAgvLoadtimeAscUnit.Enabled := True; EditAgvLoadtimeAsc.Visible := True; EditAgvLoadtimeAsc.Enabled := True; end; end; end;

procedure TForm3.CheckBox11Click (Sender: TObject);

var mySimulationCase : SimulationCase; begin fillMemo; if currentCase > 0 then begin if CheckBox11.Checked then begin CheckBoxSelectAsc.Enabled := True; mySimulationCase := casesQueue.Element(currentCase); if mySimulationCase.AscSelectionForAgv = 0 then CheckBoxSelectAsc.Checked := False else

CheckBoxSelectAsc.Checked := True; end else begin CheckBoxSelectAsc.Enabled := False; mySimulationCase := casesQueue.Element(0); if mySimulationCase.AscSelectionForAgv = 0 then CheckBoxSelectAsc.Checked := False else

CheckBoxSelectAsc.Checked := True; end; end else begin if CheckBox11.Checked then begin CheckBoxSelectAsc.Enabled := False; end else begin CheckBoxSelectAsc.Enabled := True; end; end; end;

procedure TForm3.CheckBox12Click (Sender: TObject);

var mySimulationCase : SimulationCase; begin fillMemo; if currentCase > 0 then begin if CheckBox12.Checked then begin RadioButtonAgvsAtQcs1.Enabled := True; RadioButtonAgvsAtQcs2.Enabled := True; RadioButtonAgvsAtQcs3.Enabled := True; mySimulationCase := casesQueue.Element(currentCase); if mySimulationCase.QcSelectionForAgv = 3 then begin RadioButtonAgvsAtQcs3.Checked := True; end else if mySimulationCase.QcSelectionForAgv = 2 then begin RadioButtonAgvsAtQcs2.Checked := True; end else RadioButtonAgvsAtQcs1.Checked := True; end else begin RadioButtonAgvsAtQcs1.Enabled := False; RadioButtonAgvsAtQcs2.Enabled := False; RadioButtonAgvsAtQcs3.Enabled := False; mySimulationCase := casesQueue.Element(0); if mySimulationCase.QcSelectionForAgv = 3 then begin RadioButtonAgvsAtQcs3.Checked := True; end else if mySimulationCase.QcSelectionForAgv = 2 then begin RadioButtonAgvsAtQcs2.Checked := True;

Page 91: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

91

end else RadioButtonAgvsAtQcs1.Checked := True; end; end else begin if CheckBox12.Checked then begin RadioButtonAgvsAtQcs1.Enabled := False; RadioButtonAgvsAtQcs2.Enabled := False; RadioButtonAgvsAtQcs3.Enabled := False; end else begin RadioButtonAgvsAtQcs1.Enabled := True; RadioButtonAgvsAtQcs2.Enabled := True; RadioButtonAgvsAtQcs3.Enabled := True; end; end; end;

procedure setFormVisualization ;

//procedure to set (disable, enable) all buttons, editboxes and labels according //to the current simulationCase. var mySimulationCase : SimulationCase; begin mySimulationCase := casesQueue.Element(currentCase); Form3.LabelCaseName.Caption := mySimulationCase.name; Form3.LabelCaseDescription.Caption := mySimulationCase.explanation; //enable buttons previous + next + delete Form3.ButtonPrev.Enabled := True; Form3.Buttonnext.Enabled := True; Form3.ButtonDeleteCase.Enabled := True; if currentCase = 0 then Form3.ButtonPrev.Enabled := False; if currentCase = 0 then Form3.ButtonDeleteCase.Enabled := False; if currentCase >= casesQueue.Length-1 then Form3.ButtonNext.Enabled := False; if currentCase = 0 then begin // enable runtime and startuptime parameters Form3.LabelRuntime.Enabled := True; Form3.LabelRuntimeUnit.Enabled := True; Form3.LabelStartupTime.Enabled := True; Form3.LabelStartupTimeUnit.Enabled := True; Form3.EditRuntime.Enabled := True; Form3.EditStartupTime.Enabled := True; end else begin // disable runtime and startuptime parameters Form3.LabelRuntime.Enabled := False; Form3.LabelRuntimeUnit.Enabled := False; Form3.LabelStartupTime.Enabled := False; Form3.LabelStartupTimeUnit.Enabled := False; Form3.EditRuntime.Enabled := False; Form3.EditStartupTime.Enabled := False; end; //Click all Checkboxes in order to determine whether or not to enable and show the parameters allowSavingAndMemo:= False; if Form3.mainParameter <> 1 then Form3.CheckBox1Click(Form3); if Form3.mainParameter <> 2 then Form3.CheckBox2Click(Form3); if Form3.mainParameter <> 3 then Form3.CheckBox3Click(Form3); if Form3.mainParameter <> 4 then Form3.CheckBox4Click(Form3); if Form3.mainParameter <> 5 then Form3.CheckBox5Click(Form3); if Form3.mainParameter <> 5 then Form3.CheckBox6Click(Form3); if Form3.mainParameter <> 6 then Form3.CheckBox7Click(Form3); if Form3.mainParameter <> 7 then Form3.CheckBox8Click(Form3); if Form3.mainParameter <> 7 then Form3.CheckBox9Click(Form3); if Form3.mainParameter <> 8 then Form3.CheckBox10Click(Form3); Form3.CheckBox11Click(Form3); Form3.CheckBox12Click(Form3); allowSavingAndMemo:= True; fillMemo; end;

Page 92: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

92

procedure checkMinMaxCycleTimes ;

//procedure to check the minimum and maximum AGV and ASC cycle times before the //bat-file will be created. var myConstants : SimulationCase; myCase : SimulationCase; noInsufficientParameterFound : Boolean; j : Integer; AGVLoadTimeForQc,AgvUnloadTimeForAsc : Double; MinAgvCycleTime,MaxAgvCycleTime : Double; MinAscCycleTime,MaxAscCycleTime : Double; text : String; begin MinMaxCycleTimesOK := True; noInsufficientParameterFound := True; myConstants:= casesQueue.Element(0); for j := 1 to casesQueue.Length - 1 do begin if noInsufficientParameterFound = True then begin myCase := casesQueue.Element(j); //set all parameters if Form3.mainParameter <> 3 then begin if Form3.CheckBox3.Checked then AGVLoadTimeForQc := myCase.AGVLoadTimeForQc else

AGVLoadTimeForQc := myConstants.AGVLoadTimeForQc; end else AGVLoadTimeForQc := Form3.mpStart1; if Form3.mainParameter <> 5 then begin if Form3.CheckBox5.Checked then MinAgvCycleTime := myCase.MinAgvCycleTime else

MinAgvCycleTime := myConstants.MinAgvCycleTime; if Form3.CheckBox6.Checked then MaxAgvCycleTime := myCase.MaxAgvCycleTime else

MaxAgvCycleTime := myConstants.MaxAgvCycleTime; end else begin MinAgvCycleTime := Form3.mpStart1; MaxAgvCycleTime := Form3.mpStart2; end; if Form3.mainParameter <> 7 then begin if Form3.CheckBox8.Checked then MinAscCycleTime := myCase.MinAscCycleTime else

MinAscCycleTime := myConstants.MinAscCycleTime; if Form3.CheckBox9.Checked then MaxAscCycleTime := myCase.MaxAscCycleTime else

MaxAscCycleTime := myConstants.MaxAscCycleTime; end else begin MinAscCycleTime := Form3.mpStart1; MaxAscCycleTime := Form3.mpStart2; end; if Form3.mainParameter <> 8 then begin if Form3.CheckBox10.Checked then AgvUnloadTimeForAsc := myCase.AgvUnloadTimeForAsc else

AgvUnloadTimeForAsc := myConstants.AgvUnloadTimeForAsc; end else AgvUnloadTimeForAsc := Form3.mpStart1; //check whether the minimum and maximum cycle times of AGVs and ASCs are OK if Form3.mainParameter = -1 then text := 'simulation ' + IntToStr(j) else text := 'case ' + IntToStr(j); if MinAgvCycleTime < AGVLoadTimeForQc + AgvUnloadTimeForAsc then begin showmessage('The total AGV cycle time includes the transfer times. Therefore the minimum cycle time of an

AGV in ' + text + ' (' + FloatToStr(MinAgvCycleTime) + ' seconds) can not be smaller then the sum of the AGV load time for QC (' + FloatToStr(AGVLoadTimeForQc) + ' seconds) and the AGV unload time for ASC (' + FloatToStr(AgvUnloadTimeForAsc) + ' seconds).');

MinMaxCycleTimesOK := False; noInsufficientParameterFound := False; end else if MaxAgvCycleTime < AGVLoadTimeForQc + AgvUnloadTimeForAsc then begin showmessage('The total AGV cycle time includes the transfer times. Therefore the maximum cycle time of an

AGV in ' + text + ' (' + FloatToStr(MaxAgvCycleTime) + ' seconds) can not be smaller then the sum of the AGV load time for QC (' + FloatToStr(AGVLoadTimeForQc) + ' seconds) and the AGV unload time for ASC (' + FloatToStr(AgvUnloadTimeForAsc) + ' seconds).');

MinMaxCycleTimesOK := False; noInsufficientParameterFound := False; end else if MinAscCycleTime < AgvUnloadTimeForAsc then begin showmessage('The total ASC cycle time includes the transfer time. Therefore the minimum cycle time of an

ASC in ' + text + ' (' + FloatToStr(MinAscCycleTime) + ' seconds) can not be smaller then the AGV unload time for ASC (' + FloatToStr(AgvUnloadTimeForAsc) + ' seconds).');

MinMaxCycleTimesOK := False; noInsufficientParameterFound := False; end else if MaxAscCycleTime < AgvUnloadTimeForAsc then begin showmessage('The total ASC cycle time includes the transfer time. Therefore the maximum cycle time of an

ASC in ' + text + ' (' + FloatToStr(MaxAscCycleTime) + ' seconds) can not be smaller then the AGV unload time for ASC (' + FloatToStr(AgvUnloadTimeForAsc) + ' seconds).');

MinMaxCycleTimesOK := False; noInsufficientParameterFound := False; end; end; end; end;

Page 93: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

93

procedure checkInputs ;

//procedure to chech whether the input in the editboxes is ok. if not then //indicate what's wrong and set the focus to that editbox, so the user can't //deny it. var A : Extended; noStringConversionErrors : Boolean; focusSet : Boolean; begin inputOK := False; noStringConversionErrors := True; //Catch string conversion errors try A := StrToFloat(Form3.EditRuntime.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form3.EditRuntime.SetFocus; end; end; try A := StrToFloat(Form3.EditStartupTime.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; Form3.EditStartupTime.SetFocus; end; end; try A := StrToFloat(Form3.EditNrQc.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; if Form3.EditNrQc.Enabled = True then begin Form3.EditNrQc.SetFocus; end else begin Form3.EditNrQc.text := '1'; checkInputs; end; end; end; try A := StrToFloat(Form3.EditShipUnloadtimeQc.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; if Form3.EditShipUnloadtimeQc.Enabled = True then begin Form3.EditShipUnloadtimeQc.SetFocus; end else begin Form3.EditShipUnloadtimeQc.text := '0'; checkInputs; end; end; end; try A := StrToFloat(Form3.EditAgvLoadtimeQc.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; if Form3.EditAgvLoadtimeQc.Enabled = True then begin Form3.EditAgvLoadtimeQc.SetFocus; end else begin Form3.EditAgvLoadtimeQc.text := '0'; checkInputs; end; end; end;

Page 94: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

94

try A := StrToFloat(Form3.EditNrAgv.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; if Form3.EditNrAgv.Enabled = True then begin Form3.EditNrAgv.SetFocus; end else begin Form3.EditNrAgv.text := '1'; checkInputs; end; end; end; try A := StrToFloat(Form3.EditMinAgvCycleTime.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; if Form3.EditMinAgvCycleTime.Enabled = True then begin Form3.EditMinAgvCycleTime.SetFocus; end else begin Form3.EditMinAgvCycleTime.text := '0'; checkInputs; end; end; end; try A := StrToFloat(Form3.EditMaxAgvCycleTime.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; if Form3.EditMaxAgvCycleTime.Enabled = True then begin Form3.EditMaxAgvCycleTime.SetFocus; end else begin Form3.EditMaxAgvCycleTime.text := '0'; checkInputs; end; end; end; try A := StrToFloat(Form3.EditNrAsc.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; if Form3.EditNrAsc.Enabled = True then begin Form3.EditNrAsc.SetFocus; end else begin Form3.EditNrAsc.text := '1'; checkInputs; end; end; end; try A := StrToFloat(Form3.EditMinAscCycleTime.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; if Form3.EditMinAscCycleTime.Enabled = True then begin Form3.EditMinAscCycleTime.SetFocus; end else begin Form3.EditMinAscCycleTime.text := '0'; checkInputs; end; end; end; try A := StrToFloat(Form3.EditMaxAscCycleTime.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; if Form3.EditMaxAscCycleTime.Enabled = True then begin Form3.EditMaxAscCycleTime.SetFocus; end else begin Form3.EditMaxAscCycleTime.text := '0'; checkInputs; end; end; end; try A := StrToFloat(Form3.EditAgvLoadtimeAsc.Text); except on Exception : EConvertError do begin noStringConversionErrors:= False; if Form3.EditAgvLoadtimeAsc.Enabled = True then begin

Page 95: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

95

Form3.EditAgvLoadtimeAsc.SetFocus; end else begin Form3.EditAgvLoadtimeAsc.text := '0'; checkInputs; end; end; end; //Catch negative values if noStringConversionErrors = True then begin if StrToFloat(Form3.EditRuntime.Text) <= 0 then begin showmessage('The runtime of the simulation can not be zero or negative.'); Form3.EditRuntime.SetFocus; end else if StrToFloat(Form3.EditStartupTime.Text) < 0 then begin showmessage('The intitial time to start up the simulation can not be negative.'); Form3.EditStartupTime.SetFocus; end else if StrToInt(Form3.EditNrQc.Text) < 1 then begin if Form3.EditNrQc.Enabled = True then begin showmessage('The number of quay cranes can not be zero or negative.'); Form3.EditNrQc.SetFocus; end else begin Form3.EditNrQc.Text := '1'; checkInputs; end; end else if StrToFloat(Form3.EditShipUnloadtimeQc.Text) < 0 then begin if Form3.EditShipUnloadtimeQc.Enabled = True then begin showmessage('The time a quay crane needs to unload a container from a ship can not be negative.'); Form3.EditShipUnloadtimeQc.SetFocus; end else begin Form3.EditShipUnloadtimeQc.Text := '0'; checkInputs; end; end else if StrToFloat(Form3.EditAgvLoadtimeQc.Text) < 0 then begin if Form3.EditAgvLoadtimeQc.Enabled = True then begin showmessage('The time a quay crane needs to load a container on an AGV can not be negative.'); Form3.EditAgvLoadtimeQc.SetFocus; end else begin Form3.EditAgvLoadtimeQc.Text := '0'; checkInputs; end; end else if StrToInt(Form3.EditNrAgv.Text) < 1 then begin if Form3.EditNrAgv.Enabled = True then begin showmessage('The number of AGVs can not be zero or negative.'); Form3.EditNrAgv.SetFocus; end else begin Form3.EditNrAgv.Text := '1'; checkInputs; end; end else if StrToFloat(Form3.EditMinAgvCycleTime.Text) < 0 then begin if Form3.EditMinAgvCycleTime.Enabled = True then begin showmessage('The minimum cycle time of an AGV can not be negative.'); Form3.EditMinAgvCycleTime.SetFocus; end else begin Form3.EditMinAgvCycleTime.Text := '0'; checkInputs; end; end else if StrToFloat(Form3.EditMaxAgvCycleTime.Text) < 0 then begin if Form3.EditMaxAgvCycleTime.Enabled = True then begin showmessage('The maximum cycle time of an AGV can not be negative.'); Form3.EditMaxAgvCycleTime.SetFocus; end else begin Form3.EditMaxAgvCycleTime.Text := '0'; checkInputs; end; end else if StrToInt(Form3.EditNrAsc.Text) < 1 then begin if Form3.EditNrAsc.Enabled = True then begin showmessage('The number of ASCs can not be zero or negative.'); Form3.EditNrAsc.SetFocus; end else begin Form3.EditNrAsc.Text := '1'; checkInputs; end; end else if StrToFloat(Form3.EditMinAscCycleTime.Text) < 0 then begin if Form3.EditMinAscCycleTime.Enabled = True then begin showmessage('The minimum cycle time of an ASC can not be negative.');

Page 96: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

96

Form3.EditMinAscCycleTime.SetFocus; end else begin Form3.EditMinAscCycleTime.Text := '0'; checkInputs; end; end else if StrToFloat(Form3.EditMaxAscCycleTime.Text) < 0 then begin if Form3.EditMaxAscCycleTime.Enabled = True then begin showmessage('The maximum cycle time of an ASC can not be negative.'); Form3.EditMaxAscCycleTime.SetFocus; end else begin Form3.EditMaxAscCycleTime.Text := '0'; checkInputs; end; end else if StrToFloat(Form3.EditAgvLoadtimeAsc.Text) < 0 then begin if Form3.EditAgvLoadtimeAsc.Enabled = True then begin showmessage('The time an ASC needs to unload a container from an AGV can not be negative.'); Form3.EditAgvLoadtimeAsc.SetFocus; end else begin Form3.EditAgvLoadtimeAsc.Text := '0'; checkInputs; end; end else if ((Form3.mainParameter = 1) or (Form3.mainParameter = 4) or (Form3.mainParameter = 6) or (Form3.mpStart1 = 0) and (Form3.mpStart2 = 0)) and (((StrToFloat(Form3.EditShipUnloadtimeQc.Text) = 0) or (Form3.mainParameter = 2)) and ((StrToFloat(Form3.EditAgvLoadtimeQc.Text) = 0) or (Form3.mainParameter = 3)) and ((StrToFloat(Form3.EditMinAgvCycleTime.Text) = 0) or (Form3.mainParameter = 5)) and ((StrToFloat(Form3.EditMaxAgvCycleTime.Text) = 0) or (Form3.mainParameter = 5)) and ((StrToFloat(Form3.EditMinAscCycleTime.Text) = 0) or (Form3.mainParameter = 7)) and ((StrToFloat(Form3.EditMaxAscCycleTime.Text) = 0) or (Form3.mainParameter = 7)) and ((StrToFloat(Form3.EditAgvLoadtimeAsc.Text) = 0) or (Form3.mainParameter = 8))) then begin Form3.LabelShipUnloadtimeQc.enabled := True; Form3.LabelAgvLoadtimeQc.enabled := True; Form3.LabelMinAgvCycleTime.enabled := True; Form3.LabelMaxAgvCycleTime.enabled := True; Form3.LabelMinAscCycleTime.enabled := True; Form3.LabelMaxAscCycleTime.enabled := True; Form3.LabelAgvLoadtimeAsc.enabled := True; Form3.LabelShipUnloadtimeQc.font.color := clMaroon; Form3.LabelAgvLoadtimeQc.font.color := clMaroon; Form3.LabelMinAgvCycleTime.font.color := clMaroon; Form3.LabelMaxAgvCycleTime.font.color := clMaroon; Form3.LabelMinAscCycleTime.font.color := clMaroon; Form3.LabelMaxAscCycleTime.font.color := clMaroon; Form3.LabelAgvLoadtimeAsc.font.color := clMaroon; showmessage('Not all time consuming parameters can be zero at once.'); Form3.LabelShipUnloadtimeQc.font.color := clWindowText; Form3.LabelAgvLoadtimeQc.font.color := clWindowText; Form3.LabelMinAgvCycleTime.font.color := clWindowText; Form3.LabelMaxAgvCycleTime.font.color := clWindowText; Form3.LabelMinAscCycleTime.font.color := clWindowText; Form3.LabelMaxAscCycleTime.font.color := clWindowText; Form3.LabelAgvLoadtimeAsc.font.color := clWindowText; if Form3.LabelShipUnloadtimeQc.enabled = False then Form3. LabelShipUnloadtimeQc.enabled := True; if Form3.LabelAgvLoadtimeQc.enabled = False then Form3. LabelAgvLoadtimeQc.enabled := True; if Form3.LabelMinAgvCycleTime.enabled = False then Form3. LabelMinAgvCycleTime.enabled := True; if Form3.LabelMaxAgvCycleTime.enabled = False then Form3. LabelMaxAgvCycleTime.enabled := True; if Form3.LabelMinAscCycleTime.enabled = False then Form3. LabelMinAscCycleTime.enabled := True; if Form3.LabelMaxAscCycleTime.enabled = False then Form3. LabelMaxAscCycleTime.enabled := True; if Form3.LabelAgvLoadtimeAsc.enabled = False then Form3. LabelAgvLoadtimeAsc.enabled := True; focusSet := False;

Page 97: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

97

if (focusSet = False) and (Form3.EditShipUnloadtimeQc.Visible = True) and

(Form3.EditShipUnloadtimeQc.Enabled = True) then begin Form3.EditShipUnloadtimeQc.SetFocus; focusSet := True; end; if (focusSet = False) and (Form3.EditAgvLoadtimeQc.Visible = True) and (Form3.EditAgvLoadtimeQc.Enabled

= True) then begin Form3.EditAgvLoadtimeQc.SetFocus; focusSet := True; end; if (focusSet = False) and (Form3.EditMinAgvCycleTime.Visible = True) and

(Form3.EditMinAgvCycleTime.Enabled = True) then begin Form3.EditMinAgvCycleTime.SetFocus; focusSet := True; end; if (focusSet = False) and (Form3.EditMaxAgvCycleTime.Visible = True) and

(Form3.EditMaxAgvCycleTime.Enabled = True) then begin Form3.EditMaxAgvCycleTime.SetFocus; focusSet := True; end; if (focusSet = False) and (Form3.EditMinAscCycleTime.Visible = True) and

(Form3.EditMinAscCycleTime.Enabled = True) then begin Form3.EditMinAscCycleTime.SetFocus; focusSet := True; end; if (focusSet = False) and (Form3.EditMaxAscCycleTime.Visible = True) and

(Form3.EditMaxAscCycleTime.Enabled = True) then begin Form3.EditMaxAscCycleTime.SetFocus; focusSet := True; end; if (focusSet = False) and (Form3.EditAgvLoadtimeAsc.Visible = True) and

(Form3.EditAgvLoadtimeAsc.Enabled = True) then begin Form3.EditAgvLoadtimeAsc.SetFocus; end; end else inputOK := True; end; end;

procedure saveParametersSimulationCase ;

//procedure to save the parameters of this simulation(case). var mySimulationCase : SimulationCase; begin if allowSavingAndMemo then begin mySimulationCase := casesQueue.Element(currentCase); mySimulationCase.runtime := StrToFloat(Form3.EditRuntime.Text); mySimulationCase.startupTime := StrToFloat(Form3.EditStartupTime.Text); mySimulationCase.numberOfQcs := StrToInt(Form3.EditNrQc.Text); mySimulationCase.shipUnloadTimeForQc := StrToFloat(Form3.EditShipUnloadtimeQc.Text); mySimulationCase.AGVLoadTimeForQc := StrToFloat(Form3.EditAgvLoadtimeQc.Text); mySimulationCase.numberOfAgvs := StrToInt(Form3.EditNrAgv.Text); mySimulationCase.MinAgvCycleTime := StrToFloat(Form3.EditMinAgvCycleTime.Text); mySimulationCase.MaxAgvCycleTime := StrToFloat(Form3.EditMaxAgvCycleTime.Text); mySimulationCase.numberOfAscs := StrToInt(Form3.EditNrAsc.Text); mySimulationCase.MinAscCycleTime := StrToFloat(Form3.EditMinAscCycleTime.Text); mySimulationCase.MaxAscCycleTime := StrToFloat(Form3.EditMaxAscCycleTime.Text); mySimulationCase.AgvUnloadTimeForAsc := StrToFloat(Form3.EditAgvLoadtimeAsc.Text); if Form3.CheckBoxSelectAsc.Checked = True then mySimulationCase.AscSelectionForAgv := 1 else

mySimulationCase.AscSelectionForAgv := 0; if Form3.RadioButtonAgvsAtQCs1.Checked = True then begin mySimulationCase.QcSelectionForAgv := 1; end else if Form3.RadioButtonAgvsAtQCs2.Checked = True then begin mySimulationCase.QcSelectionForAgv := 2; end else mySimulationCase.QcSelectionForAgv := 3; end; end;

Page 98: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

98

procedure TForm3.ButtonAddCaseClick (Sender: TObject);

//procedure to add a simulation or simulationCase and copies its parameters //from the constants. var mySimulationCase : SimulationCase; myConstants : SimulationCase; begin myConstants := casesQueue.Element(0); currentCase := casesQueue.Length; mySimulationCase := SimulationCase.Create('simulationCase'); mySimulationCase.Name := 'Case ' + IntToStr(currentCase) + ': '; mySimulationCase.explanation := 'Define here the specific parameters for this case. Mark the checkbox

on the left, in order to change the parameter from a constant for all simulations, to a parameter to be defined for each case.';

if mainparameter = -1 then mySimulationCase.Name := 'Simulation ' + IntToStr(currentCase) + ': '; if mainparameter = -1 then mySimulationCase.explanation := 'Define here the specific parameters for this

simulation. Mark the checkbox on the left, in order to change the parameter from a constant for all simulations, to a parameter to be defined for each simulation.';

mySimulationCase.runtime := myConstants.runtime; mySimulationCase.startupTime := myConstants.startupTime; mySimulationCase.numberOfQcs := myConstants.numberOfQcs; mySimulationCase.shipUnloadTimeForQc := myConstants.shipUnloadTimeForQc; mySimulationCase.AGVLoadTimeForQc := myConstants.AGVLoadTimeForQc; mySimulationCase.numberOfAgvs := myConstants.numberOfAgvs; mySimulationCase.MinAgvCycleTime := myConstants.MinAgvCycleTime; mySimulationCase.MaxAgvCycleTime := myConstants.MaxAgvCycleTime; mySimulationCase.numberOfAscs := myConstants.numberOfAscs; mySimulationCase.MinAscCycleTime := myConstants.MinAscCycleTime; mySimulationCase.MaxAscCycleTime := myConstants.MaxAscCycleTime; mySimulationCase.AgvUnloadTimeForAsc := myConstants.AgvUnloadTimeForAsc; mySimulationCase.AscSelectionForAgv := myConstants.AscSelectionForAgv; mySimulationCase.QcSelectionForAgv := myConstants.QcSelectionForAgv; casesQueue.AddToTail(mySimulationCase); setFormVisualization; end;

procedure TForm3.ButtonOKClick (Sender: TObject);

//procedure to create the BAT-file. var myConstants,myCase : SimulationCase; i,j,k,position : Integer; myFile : TextFile; twoParameters : Boolean; cmd,batLine : string; paramArray : Array[1..10] of String; simulArray : Array of String; begin if casesQueue.Length < 2 then begin ButtonAddCaseClick(Form3); end else begin CheckMinMaxCycleTimes; if MinMaxCycleTimesOK = True then begin twoParameters:= False; if Form3.mainParameter = 5 then twoParameters:= True; if Form3.mainParameter = 7 then twoParameters:= True; //set and fill simulation parameters array SetLength(simulArray, Form3.mpNrSteps + 1); for i := 0 to Form3.mpNrSteps do begin simulArray[i] := FloatToStr(Form3.mpstart1+Form3.mpStepsize1*i); if twoParameters = True then simulArray[i]:= simulArray[i] + ' ' + FloatToStr(Form3.mpstart2

+Form3.mpStepsize2*i); end; cmd := CmdLine; AssignFile(myFile, 'Start batch of simulations.bat'); ReWrite(myFile); //set and fill cases parameters array myConstants:= casesQueue.Element(0); for j := 1 to casesQueue.Length - 1 do begin myCase := casesQueue.Element(j); if Form3.CheckBox1.Checked then paramArray[1] := IntToStr(myCase.numberOfQcs) else

paramArray[1] := IntToStr(myConstants.numberOfQcs); if Form3.CheckBox2.Checked then paramArray[2] := FloatToStr(myCase.shipUnloadTimeForQc) else

paramArray[2] := FloatToStr(myConstants.shipUnloadTimeForQc);

Page 99: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

99

if Form3.CheckBox3.Checked then paramArray[3] := FloatToStr(myCase.AGVLoadTimeForQc) else paramArray[3] := FloatToStr(myConstants.AGVLoadTimeForQc);

if Form3.CheckBox4.Checked then paramArray[4] := IntToStr(myCase.numberOfAgvs) else paramArray[4] := IntToStr(myConstants.numberOfAgvs);

if Form3.CheckBox5.Checked then paramArray[5] := FloatToStr(myCase.MinAgvCycleTime) else paramArray[5] := FloatToStr(myConstants.MinAgvCycleTime);

if Form3.CheckBox6.Checked then paramArray[5] := paramArray[5] + ' ' + FloatToStr(myCase.MaxAgvCycleTime) else paramArray[5] := paramArray[5] + ' ' +

FloatToStr(myConstants.MaxAgvCycleTime); if Form3.CheckBox7.Checked then paramArray[6] := IntToStr(myCase.numberOfAscs) else

paramArray[6] := IntToStr(myConstants.numberOfAscs); if Form3.CheckBox8.Checked then paramArray[7] := FloatToStr(myCase.MinAscCycleTime) else

paramArray[7] := FloatToStr(myConstants.MinAscCycleTime); if Form3.CheckBox9.Checked then paramArray[7] := paramArray[7] + ' ' +

FloatToStr(myCase.MaxAscCycleTime) else paramArray[7] := paramArray[7] + ' ' + FloatToStr(myConstants.MaxAscCycleTime);

if Form3.CheckBox10.Checked then paramArray[8] := FloatToStr(myCase.AgvUnloadTimeForAsc) else paramArray[8] := FloatToStr(myConstants.AgvUnloadTimeForAsc);

if Form3.CheckBox11.Checked then paramArray[9] := FloatToStr(myCase.AscSelectionForAgv) else paramArray[9] := FloatToStr(myConstants.AscSelectionForAgv);

if Form3.CheckBox12.Checked then paramArray[10] := FloatToStr(myCase.QcSelectionForAgv) else paramArray[10] := FloatToStr(myConstants.QcSelectionForAgv);

for i := 0 to Form3.mpNrSteps do begin batLine:= cmd + '1' + ' ' + IntToStr(j)+' '+IntToStr(i+1) + ' ' + FloatToStr(myConstants.runtime) + ' '

+ FloatToStr(myConstants.startupTime) + ' '; //change batline in case mainparameter is not defined and the cases should be seen as simulations. if Form3.mainParameter = -1 then batLine:= cmd + '1' + ' ' + IntToStr(1)+' '+IntToStr(j) + ' ' +

FloatToStr(myConstants.runtime) + ' ' + FloatToStr(myConstants.startupTime) + ' '; for k := 1 to 10 do begin if mainParameter <> k then begin batLine:= batLine + paramArray[k] + ' '; end else begin batLine:= batLine + simulArray[i] + ' '; end; end; WriteLn(myFile,batLine); end; end; CloseFile(myFile); WriteContentBatchToFile; //show message what to do to user position := 0; for i := 1 to length(cmd) do begin; if Copy(cmd,i,1) = '\' then position := i; end; if position = 0 then begin ShowMessage( 'A copy of the content of the simulations (as is currently displayed in the listbox),

is saved in the file "Content batch of simulations.txt".' + #13#10 + #13#10 + 'Doubleclick on the file "Start batch of simulations.bat" to start the batch of simulations.' + #13#10 + #13#10 + 'The results will be showed in an excel document and also in the file "Results batch of simulations.txt".')

end else ShowMessage('A copy of the content of the simulations (as is currently displayed in the listbox), is saved in the file "Content batch of simulations.txt".' + #13#10 + #13#10 + 'Doubleclick on the file "Start batch of simulations.bat" to start the batch of simulations.' + #13#10 + #13#10 + 'The results will be showed in an excel document and also in the file "Results batch of simulations.txt".' + #13#10 + #13#10 + 'These files are located in: ' + Copy(cmd,1,position) + '".');

end; end; end;

Page 100: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

100

procedure TForm3.ButtonCancelClick (Sender: TObject);

//procedure to close the form (without closnig the program). begin Form3.quitProgramIndicator := False; Form3.Close; end;

procedure TForm3.ButtonDeleteCaseClick (Sender: TObject);

//procedure to delete a simulation or a simulationCase. var i : Integer; mySimulationCase : SimulationCase; nametype : String; begin mySimulationCase := casesQueue.Element(currentCase); mySimulationCase.LeaveQueue(casesQueue); if mainparameter = -1 then nametype := 'Simulation ' else nametype := 'Case '; for i := 1 to casesQueue.Length - 1 do begin mySimulationCase := casesQueue.Element(i); mySimulationCase.Name:= nametype + IntToStr(i) + ': '; end; if currentCase = casesQueue.Length then currentCase := currentCase - 1; setFormVisualization; end;

procedure TForm3.ButtonNextClick (Sender: TObject);

//procedure to go to the next simulation or simulationCase. begin currentCase:=currentCase+1; setFormVisualization; end;

procedure TForm3.ButtonPrevClick (Sender: TObject);

//procedure to go to the previous simulation or simulationCase. begin currentCase:=currentCase-1; setFormVisualization; end;

procedure initialize ;

//procedure to create the simulationCase for the standards and to permanently //hide and disable editboxes and labels from the main simulation parameter. var myFile : TextFile; mySimulationCase : SimulationCase; inputValue : String; begin //make a Queue and the first case/simulation currentcase:= 0; casesQueue := TomasQueue.create('casesQueue'); mySimulationCase := SimulationCase.Create('simulationCase'); mySimulationCase.name := 'Constants:'; mySimulationCase.explanation := 'Define here the contant parameters for all simulations.';

Page 101: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

101

//read input from a text-file if FileExists('Input1.txt') then begin AssignFile(myFile, 'Input1.txt'); Reset(myFile); ReadLn(myFile,inputValue); Form3.EditRuntime.Text :=inputValue; ReadLn(myFile,inputValue); Form3.EditStartupTime.Text :=inputValue; ReadLn(myFile,inputValue); Form3.EditNrQc.Text :=inputValue; ReadLn(myFile,inputValue); Form3.EditShipUnloadtimeQc.Text :=inputValue; ReadLn(myFile,inputValue); Form3.EditAgvLoadtimeQc.Text :=inputValue; ReadLn(myFile,inputValue); Form3.EditNrAgv.Text :=inputValue; ReadLn(myFile,inputValue); Form3.EditMinAgvCycleTime.Text :=inputValue; ReadLn(myFile,inputValue); Form3.EditMaxAgvCycleTime.Text :=inputValue; ReadLn(myFile,inputValue); Form3.EditNrAsc.Text :=inputValue; ReadLn(myFile,inputValue); Form3.EditMinAscCycleTime.Text :=inputValue; ReadLn(myFile,inputValue); Form3.EditMaxAscCycleTime.Text :=inputValue; ReadLn(myFile,inputValue); Form3.EditAgvLoadtimeAsc.Text :=inputValue; ReadLn(myFile,inputValue); if inputValue = '0' then begin Form3.CheckBoxSelectAsc.Checked := False; end else Form3.CheckBoxSelectAsc.Checked := True; ReadLn(myFile,inputValue); if inputValue = '3' then begin Form3.RadioButtonAgvsAtQCs3.Checked := True; end else if inputValue = '2' then begin Form3.RadioButtonAgvsAtQCs2.Checked := True; end else Form3.RadioButtonAgvsAtQCs1.Checked := True; CloseFile(myFile); end; Form3.CheckBox1.Visible := True; Form3.CheckBox2.Visible := True; Form3.CheckBox3.Visible := True; Form3.CheckBox4.Visible := True; Form3.CheckBox5.Visible := True; Form3.CheckBox6.Visible := True; Form3.CheckBox7.Visible := True; Form3.CheckBox8.Visible := True; Form3.CheckBox9.Visible := True; Form3.CheckBox10.Visible := True; if Form3.mainParameter = 1 then begin Form3.LabelNrQc.Enabled := False; Form3.LabelNrQcUnit.Enabled := False; Form3.EditNrQc.Visible := False; Form3.CheckBox1.Visible := False; end; if Form3.mainParameter = 2 then begin Form3.LabelShipUnloadtimeQc.Enabled := False; Form3.LabelShipUnloadtimeQcUnit.Enabled := False; Form3.EditShipUnloadtimeQc.Visible := False; Form3.CheckBox2.Visible := False; end; if Form3.mainParameter = 3 then begin Form3.LabelAgvLoadtimeQc.Enabled := False; Form3.LabelAgvLoadtimeQcUnit.Enabled := False; Form3.EditAgvLoadtimeQc.Visible := False; Form3.CheckBox3.Visible := False; end; if Form3.mainParameter = 4 then begin Form3.LabelNrAgv.Enabled := False; Form3.LabelNrAgvUnit.Enabled := False; Form3.EditNrAgv.Visible := False; Form3.CheckBox4.Visible := False; end;

Page 102: FACULTY MECHANICAL, MARITIME AND MATERIALS ENGINEERING

102

if Form3.mainParameter = 5 then begin Form3.LabelMinAgvCycleTime.Enabled := False; Form3.LabelMinAgvCycleTimeUnit.Enabled := False; Form3.EditMinAgvCycleTime.Visible := False; Form3.LabelMaxAgvCycleTime.Enabled := False; Form3.LabelMaxAgvCycleTimeUnit.Enabled := False; Form3.EditMaxAgvCycleTime.Visible := False; Form3.CheckBox5.Visible := False; Form3.CheckBox6.Visible := False; end; if Form3.mainParameter = 6 then begin Form3.LabelNrAsc.Enabled := False; Form3.LabelNrAscUnit.Enabled := False; Form3.EditNrAsc.Visible := False; Form3.CheckBox7.Visible := False; end; if Form3.mainParameter = 7 then begin Form3.LabelMinAscCycleTime.Enabled := False; Form3.LabelMinAscCycleTimeUnit.Enabled := False; Form3.EditMinAscCycleTime.Visible := False; Form3.LabelMaxAscCycleTime.Enabled := False; Form3.LabelMaxAscCycleTimeUnit.Enabled := False; Form3.EditMaxAscCycleTime.Visible := False; Form3.CheckBox8.Visible := False; Form3.CheckBox9.Visible := False; end; if Form3.mainParameter = 8 then begin Form3.LabelAgvLoadtimeAsc.Enabled := False; Form3.LabelAgvLoadtimeAscUnit.Enabled := False; Form3.EditAgvLoadtimeAsc.Visible := False; Form3.CheckBox10.Visible := False; end; casesQueue.AddToTail(mySimulationCase); saveParametersSimulationCase; end;

procedure TForm3.FormActivate (Sender: TObject);

//procedure to decide if it should initialize and prepare the form. begin if Form3.batchAlreadyActivatedBefore = False then initialize; Form3.batchAlreadyActivatedBefore:= True; allowSavingAndMemo:= True; if Form3.mainParameter = -1 then begin Form3.ButtonAddCase.Caption := 'Add Simulation'; Form3.ButtonDeleteCase.Caption := 'Delete Simulation'; Form3.Caption:= 'Simulation parameters'; end else begin Form3.ButtonAddCase.Caption := 'Add Case'; Form3.ButtonDeleteCase.Caption := 'Delete Case'; Form3.Caption:= 'Case parameters'; end; setFormVisualization; Form3.quitProgramIndicator := True; if currentcase = 0 then Form3.EditRuntime.SetFocus; end;

procedure TForm3.EditExit (Sender: TObject);

//procedure to check, save en show inputs after they are changed. begin if Form3.batchAlreadyActivatedBefore = True then begin //Do not check the inputs while initilizing the form checkInputs; if inputOK = True then begin if casesQueue.Length > 0 then begin saveParametersSimulationCase; fillmemo; end; end; end; end; end.