AnyLogic Batching agents i.t.o Weight - anylogic

How do I set the batch size i.t.o the weight I want to batch? I am currently simulating a potato plant. And the potatoes(agent) all have their own weight due to the randomness of potatoes, but now I must batch them into 10Kg bags. The weight should just be over 10kg but not smaller, so it is going to be 9.9kg plus one more potato.
The F1 help function suggests to use a customized Queue. But I do not know how to go forward with that option.
Any help would be appreciated

You could use a "Wait" object with infinite capacity. Whenever a potatoe is added, check the total weight and if they are above your threshold, you can use wait.freeAll(). This will send them into a downstream batch object.
Make sure to change the batch size to the number of potatoes in the "wait" object before you the the freeAll() method,so that all freed potatoes are batched together. You can do that dynamically using batch.set_batchSize(x)
cheers

Related

Is there a way to record when (and how often) Transporters get within a certain distance of each other?

I have an AnyLogic simulation model using trucks and forklifts as agents (Transporter type), and among other things would like to identify each time one of them becomes within a certain distance of another one (example within 5 meters). I will record this count as a variable within the main space of the model. I am using path-guided navigation.
I have seen a method "agentsInRange" which will probably be able to do the trick, but am not sure where to call this from. I assume I should be able to use the AL functionality of "Min distance to obstacle" (TransporterFleet) and "Collision detection timeout" (TransporterControl)?
Thanks in advance!
Since there don't seem to be pre-built functions for this, afaik, the easiest way is to:
add an int variable to your transporter agent type counter
add an event to your transporter type checkCollision that triggers every second or so
in the event, loop across the entire population of transporters and count the number that are closer than X meters (use distanceTo(otherTransporter) and write your own custom code)
add that number to counter
Note that this might be very inefficient computationally as it is quite brute-force. But might be good enough :)

Suggestions for optimising FPGA design

I need to figure out optimisations for this FPGA design. I've got a few ideas and I'd like to know if they sound reasonable for my design. I'd also like to ask if anyone has any other ideas to improve my designs efficiency.
The design I have to optimise is an ensemble of neurons, I've included two images below.
My current ideas
Add pipeline registers between each neuron and each adder
'Register the inputs and outputs' by inserting registers in-between each logic block
Convert the adder tree into an adder chain
Use time division multiplexers to share the LUT's between logic blocks
Do my current ideas for improving performance make any sense? I don't know very much about FPGA's at all so I'm not sure if my optimisations will make much of an improvement or if they even make sense.
Any help would be greatly appreciated.
Links to PDFs of my neuron and emsemble (The image quality is higher):
https://francismcnamee.com/pdfs/neuron_ensemble.pdf
https://francismcnamee.com/pdfs/single_neuron.pdf
Ensemble of neurons (Each subsystem is a single neuron, the design of each neuron is shown below)
A single neuron
To start with "less area usage and/or faster speed." forget about and: you can optimise of area or speed. Both will not work.
Use time division multiplexers to share the LUT's between logic blocks"
Multiplexers are also build from LUTs so you loose area before you gain some. Then the TDM needs to have a controller, the interim results need to be stored and retrieved. All and all it is not trivial and I would only do that if you are rather good at logic design. You may gain area, but you will lose speed.
Convert the adder tree into an adder chain.
No, you don't touch the adder tree. The FPGA synthesis tool will select the optimal adder configuration for you. It will balance area against speed and come up with something much better result then you can for yourself.
In fact this applies to every part of the design:let the synthesis tool do its work. You will not be able to outperform it.
Add pipeline registers between each neuron and each adder
Register the inputs and outputs' by inserting registers in-between each logic block
Sorry again but: Nope! Working with registers is not that simple.
You need to balance the registers. Ideally the logic delay between each pipeline stage should be the same.
Lets say you multiply takes** 10nS. The adder takes 3nS. Then you should place a pipeline stages after a set of 3 adders. The delay will be ~20nS. If you placed an pipeline stage after each adder, the total delay would be ~40nS.
Now you get to the core of speeding up a design: do you use 4 pipeline stages so you can run at 200 MHz or 2 pipeline stages and run at 100MHz? In both cases the throughput is the same.
Beware that each register stage also cost you time: you need to meet the set-up time of the register. As such the fastest design is the one with no registers: the data falls through at the maximum speed. But then you may need to wait a long time before you can present the next set of data.
As you may gather: balancing registers is not easy and is rather an art. The best way would be to run the design without any registers through the synthesis tool. Then run a timing analysis on it and look at the worst-case timing path. From that try to figure out where to put the register stages. But again, that is easier said then done. To me reading those timing analysis reports is easy, but for a novice they might seem all abracadabra.
Sorry if I let you hanging here but unfortunately there is no "magic trick" in these cases. Ideally you could let an experienced design play a few hours with your code and see what (s)he can do.
**The numbers I use have been made up

Energy Consumption in Anylogic

I would like to analyse the electrical energy consumed by a furnace in a conveyor system. Is there a method or specific function to do this using Anylogic?
I've found little material surrounding this, so pointing in the right direction would be great.
Simple answer: There is no build-in functionality. But you can easily do this yourself.
If you want very high accuracy, you should check system dynamics (but this slows your model quite a bit).
If you want a simple approach, I can think of this:
create a variable elecConsumptionPerMin in your furnace agent
create an event consumeElec in your furnace that cyclically (every minute) adds to the total furnace consumption (another variable)
on model startup, ideally set myFurnace.consumeElec.suspend()
when the furnace starts producing, call ´myFurnace.consumeElec.resume()` to start consuming enegery
Obviously, you can refine this to the nth degree and you might also want to experiment with state charts. But this is the simple approach

Space between agents in discrete-event simulation

I have a question about space between agents. In my model I have agents generated from a source and then they enter a delay, after the delay the agents go into a a queue with a capacity of 1 but I have a preemption option. The agents that go into the preemption are supposed to move along a circled path (I used a delay block for this) but there should always be a certain space between the agents, e.g. 100 meters. How can I incorporate this in my model to make sure my agents are not too close to each other?
One way you can control the distance between your agents is to move them on a path using a dummy transporter instead of the moveTo block. Transporters allow you to define a minimum distance to obstacle that prevents the agents from getting too close to each other.
Two options if you mean the static queue with agents actually waiting:
1) if your queue size is 500 meters, define the maximum amount of agents allowed in that queue to 6 (so you have 100 meters of distance between each agent)
2) Use the PML settings block from the PML palette and define an initial capacity of animation location equal to 6 (if your queues are 500 meters)... but this applies to all the model, so maybe it won't be good enough.
If you want them to have 100 meters space while they are moving towards their objective through the path that represents the queue, then the answer depends heavily on your model and it cannot be answered with the info provided... you need in this case to control the agent movements adding some logic... but I don't know what logic is suitable for you.

Set NetLogo Display rate Constant

I have a NetLogo model where the number of agents changes/reduces with time. I notice the model runs faster as the agents are less(ticks increment quickly).
How can keep it constant, probably set to upperlimit.
There are two ways of doing that. One is to lower the speed using the speed slider at the top of model view. This essentially sets an upper limit.
Another, programmatic, way is to use the every (click for link) keyword. That gives you more exact control over how your model executes, but keep in mind there is a CPU overhead using that.