interaction between two agents, not within the statechart - communication

I have defined a population of agents called "Sellers" and one agent with a population of 1 called "Manufacturer". "AverageSales" is defined in the statistics for the sellers agents. Now I want to let the Manufacturer know different values taken by "AverageSales" of the Sellers. I think for this communication, I should send a message from Sellers in which the values of "AverageSales" be sent to the Manufacturer. The problem is all the examples have defined a message within a statechart. How can I do that? Can you please write me the piece of code for this action and where to add it?
Thank you

Agent communication does not always have to be via messages. (That is just something that fits with a statechart-oriented view of agent behaviour and is stressed in many of AnyLogic's example models.) In many cases (as in yours) it is much simpler just to access the information directly in the other agent (or its population).
In your case, your Manufacturer agents can just access the statistics value directly. Say you have populations manufacturers and sellers in Main, with statistic AverageSales as you said. From within one of your Manufacturer agents, you can just do main.sellers.AverageSales() to access the statistic (i.e., go up to Main via the link-to-upper-level-agent created for you, then into the sellers population and access the statistic value via the provided function).
Look at the help for:
Advanced Modeling with Java --> Java Basics for AnyLogic --> Where am I and how do I get to…?
Release Notes --> What's new in previous releases --> What's new in AnyLogic 7 --> Link to upper level agent
Agent Based Modeling --> Collecting statistics on agents

Related

Unique agents across application instances and BEAM

My requirement is to use named agents. Basically one agent per record with a custom id. Can we query the Agent's name across application instances and BEAM ? I mean that if we have 2 instances of an app on 2 different BEAM machines we need to make sure that we have only one agent per record. Not more. How can I achieve this?
Agent is basically a GenServer. The latter has three options to register it’s name. Both {:global, term} and {:via, module, term} register the name globally.
Of course, all the nodes should be connected for this to work.
To make it easier to address globally registered processes, one might use Registry, although in this particular case {:global, name} should be fine enough.

Where does raw geoip data come from?

This question is a general version of a more specific question asked here. However, those answers were unusable.
Question: What is the raw source for geoIP data?
Many websites will tell me where my IP is, but they all appear to be using databases from fewer than 5 companies (most are using a database from MaxMind). These companies offer limited free versions of their databases, but I'm trying to determine what they're using for their source data?
I've tried using Linux/Unix commands such as ping, traceroute, dig, whois, etc., but they don't provide predictably accurate information.
Preamble: I believe this is actually a very valid question for SO website as understanding how such things work is important to understanding how such datasets can be used in software. However the answer to this question is rather complex and full of historical remarks.
First - it is worth mentioning that there is NO unified raw geoip data. Such thing just does not exist. Second - the data for this comes from multiple resources and often is not reliable and/or outdated.
To understand how that comes to be one need to know how Internet came into existence and spread around the world. Short summary is below:
IANA is a global [non-profit] organization which manages assignment of IP blocks to regional organizations: https://www.iana.org/numbers This happens upon request and regional organization requests specified block size
Regional organizations may assign those IP blocks to either ISP directly or to country level sub-organizations (who would assign that to ISP then).
ISP assigns IP addresses to local branches etc.
From above you can easily see that:
There is no single body which is responsible for IP block assignment to this or that location
Decisions how to (and whether to) release information about which IP belongs to which location are not taken uniformly and instead each organizations decides how to (and whether do it at all) release that information
All of above creates a whole lot of mess. It takes a lot of dedication and long time to obtain, aggregate and sort this data. And this is why most up-to-date and detailed geoip datasets are commercial commodity.
Whoever takes on a challenge of building their own dataset should be able to obtain this information directly from end users (ISPs), because higher level organizations do not know to which location each IP address will be assigned. Higher level organizations only distribute IP blocks among applicants (and keep some reserve for faster processing) and it is a lowest level organizations who decide which location gets which IP address and they are not obligated to release this information publicly.
UPD:
To start building your own dataset you can begin with this list of blocks and how they are assigned

Where do smart contracts reside in blockchain (Ethereum or Hyperledger)

So, let us consider a typical trade finance process flow. Exporter deploys a contract that has conditions of the shipment and a hash is generated once the deployment is finished.
Questions:
1) Where is the contract stored?
2) How other participants such as customs and importer can access this contract?
3) Can we activate participant level access to the contract on the blockchain?
There are several aspects to Ethereum and Hyperledger which make them quite different. Let me give a somewhat simplified answer to not get into too much details and a too long answer.
First of all, Ethereum is primarily a public blockchain that works in a certain intended way. Similarly, the Bitcoin blockchain works in a certain intended way. Hyperledger is not like that, rather it's an umbrella for distributed ledger technologies (in my terminology not the same as blockchain) which all aim to provide a very flexible architecture so that one can build all kinds of ledger-backed systems with pretty much any properties needed. One could compare this to an imaginary Bitcoin umbrella that provides technology to produce own altcoins with pluggable parts for e.g. consensus, blockchain storage, node composition etc. In short, all these aim to solve different problems and one should not think one will fit all.
Coming back to your questions.
1) Where is the contract stored?
Ethereum has contracts (called smart contracts) on the chain, i.e. code is compiled to byte code and the resulting bytes are sent within a transaction to be persisted onto the Ethereum blockchain. This is done once when you deploy the smart contract. After this one can interact with the smart contract with other transactions.
Hyperledger is in theory not defining this, it could be on a ledger or it might not. Take Fabric for instance, it deploys the code into a sandboxed Docker container which then can be interacted with using transactions.
2) How other participants such as customs and importer can access this contract?
Short answer is that they are given access via credentials.
This is in both Ethereum and Hyperledger open for you to decide yourself. We now assume the code in both cases has been deployed as code on the blockchain for Ethereum and as a Docker container in Fabric.
In Ethereum the code is, a bit simplified, publicly accessible/visible which means you need to employ some kind of check to only allow those who should be able to interact with the smart contract to do so. One way is to check the sender (of the transaction) and only allow certain ones. It's similar to traditional systems where one usually needs to authenticate/authorize to be allowed in and see/alter data.
In Hyperledger it would most likely be modelled in a similar manner and e.g. in Fabric there is also the Certificate Authority that hands out certificates that allow access to different parts of the system. E.g. transport, endorsement or transactions.
3) Can we activate participant level access to the contract on the blockchain?
Yes, so each participant in both systems has credentials and the designer of the smart contract can use this to control access.
Also, in Fabric there are channels that partition the ledger which is used for access control.
HTH.
1) The contract resides on the ledger. Whenever a transaction is invoked, the corresponding method in the contract gets executed on all the validating peers.
2) Other participants can access this contract using their pre-defined user credentials, which they can use to enroll themselves and invoke transactions on the contract.
3) Yes, we can activate participant level access to the contract by defining attributes for every user and allowing only those users who possess certain attributes to access specific parts of the contract.

How to get a printer to report back to in house application

I want a printer to report back to my in house application the accounting code the user typed in. How do I do that?
Note to mods: mods at serverfault sent me here.
The answer is printer manufacturer specific, and you haven't specified what printing infrastructure you have.
Each manufacturer implements this type of accounting in a different way, and most have changed methods over time.
It could come back via LDAP, an API call, or SOAP web service.
It could be that you have to poll the printers to retrieve their per-user or per-department counters for colour, b&w, stapling etc.
It could be that your solution is influenced by the access control solution you use, like swipe cards, tokens or mobile phone proxmity, as these often have integrated job accounting functionality.
There could also be a central management app, that accumulates the data from many printers, like HP's Access Control Job Accounting.
The solution you choose also depends on your scale, ten printers or a thousand.

Restrict service detection in OpenNMS based on "hostname"

I am able to restrict a service detection based on the ipaddress , but suppose if I want to use another parameter like hostname or node_label for service detection , then how do I configure that?
I need to know exact snippet config for hostname in default-foreign-source.xml
P.S : I am using the Discovery demon i.e auto-discovery of nodes
Any help would be appreciated.
The OpenNMS model is as follows:
node --> interface --> service
So OpenNMS has no way of associating a node label with a service. There is a BusinessServiceMonitor in development that will help deal with more complicated models, but it isn't in release code at the moment.
This is why you aren't able to associate as you want.
You might get around this by labeling (ifAlias) interfaces with tags and matching categories to tags to exclude the service.
Also, you should never edit provisioning XML configuration files directly. OpenNMS utilizes caching for those configs for performance purposes and you can break your system (unlikely but possible).
I would also get away from using discovery. It limits the ability for you to separate groups of nodes out as distinct requisitions, which give you the ability to apply different sets of provisioning policies (filters, ability to monitor or not monitor services or data collections) to different groups of nodes. Discovery operates only against the default foreign source policy so you lose that kind of flexibility.

Resources