Repast - Exchange information between batch runs - repast-simphony

Batch runs in Repast are independent runs without interactions. However, in my model I have a need to enable such interaction. E.g. run-2 needs to get some data from run-1 in order to run completely.
Is there a way to exchange information between batch runs?

The order in which individual batch runs are executed is not predetermined. For example, if you distribute the runs among several resources two may run at the same time as or 2 even before 1. So, in the general case, I don't think this is possible.
That said, I think you have three options:
If possible, do all the independent runs (e.g. 1 in your example), gather the data, and then do the dependent runs. That won't work well obviously if you are actually talking about a chain of runs 1->2->3...
If all the runs are running on the same resource, you could experiment a bit to find out where run 1 is running. I suspect its probably in "instance_1" and run 2 is in instance_2 etc. By experiment here, I just mean look at the file system manually to see what is where. You could then use Java's various file IO classes (note - not Repast functionality) to get run 2's location and find the location of run 1's data with that. For example, if you know run 2 runs in /x/y/z/instance_2 (maybe by doing a Paths.get("./") or something) and that run 1 is then in /x/z/y/instance_1, you should be able to get the data. I don't know what data from run 1 you want but you'll have to make sure that the data you want has been completely written.
If run 2 really depends on run 1, perhaps it makes sense to update the model to run them as single run.
Nick

Related

How to quickly analyse the impact of a program change?

Lately I need to do an impact analysis on changing a DB column definition of a widely used table (like PRODUCT, USER, etc). I find it is a very time consuming, boring and difficult task. I would like to ask if there is any known methodology to do so?
The question also apply to changes on application, file system, search engine, etc. At first, I thought this kind of functional relationship should be pre-documented or some how keep tracked, but then I realize that everything can have changes, it would be impossible to do so.
I don't even know what should be tagged to this question, please help.
Sorry for my poor English.
Sure. One can technically at least know what code touches the DB column (reads or writes it), by determining program slices.
Methodology: Find all SQL code elements in your sources. Determine which ones touch the column in question. (Careful: SELECT ALL may touch your column, so you need to know the schema). Determine which variables read or write that column. Follow those variables wherever they go, and determine the code and variables they affect; follow all those variables too. (This amounts to computing a forward slice). Likewise, find the sources of the variables used to fill the column; follow them back to their code and sources, and follow those variables too. (This amounts to computing a backward slice).
All the elements of the slice are potentially affecting/affected by a change. There may be conditions in the slice-selected code that are clearly outside the conditions expected by your new use case, and you can eliminate that code from consideration. Everything else in the slices you may have inspect/modify to make your change.
Now, your change may affect some other code (e.g., a new place to use the DB column, or combine the value from the DB column with some other value). You'll want to inspect up and downstream slices on the code you change too.
You can apply this process for any change you might make to the code base, not just DB columns.
Manually this is not easy to do in a big code base, and it certainly isn't quick. There is some automation to do for C and C++ code, but not much for other languages.
You can get a bad approximation by running test cases that involve you desired variable or action, and inspecting the test coverage. (Your approximation gets better if you run test cases you are sure does NOT cover your desired variable or action, and eliminating all the code it covers).
Eventually this task cannot be automated or reduced to an algorithm, otherwise there would be a tool to preview refactored changes. The better you wrote code in the beginning, the easier the task.
Let me explain how to reach the answer: isolation is the key. Mapping everything to object properties can help you automate your review.
I can give you an example. If you can manage to map your specific case to the below, it will save your life.
The OR/M change pattern
Like Hibernate or Entity Framework...
A change to a database column may be simply previewed by analysing what code uses a certain object's property. Since all DB columns are mapped to object properties, and assuming no code uses pure SQL, you are good to go for your estimations
This is a very simple pattern for change management.
In order to reduce a file system/network or data file issue to the above pattern you need other software patterns implemented. I mean, if you can reduce a complex scenario to a change in your objects' properties, you can leverage your IDE to detect the changes for you, including code that needs a slight modification to compile or needs to be rewritten at all.
If you want to manage a change in a remote service when you initially write your software, wrap that service in an interface. So you will only have to modify its implementation
If you want to manage a possible change in a data file format (e.g. length of field change in positional format, column reordering), write a service that maps that file to object (like using BeanIO parser)
If you want to manage a possible change in file system paths, design your application to use more runtime variables
If you want to manage a possible change in cryptography algorithms, wrap them in services (e.g. HashService, CryptoService, SignService)
If you do the above, your manual requirements review will be easier. Because the overall task is manual, but can be aided with automated tools. You can try to change the name of a class's property and see its side effects in the compiler
Worst case
Obviously if you need to change the name, type and length of a specific column in a database in a software with plain SQL hardcoded and shattered in multiple places around the code, and worse many tables present similar column namings, plus without project documentation (did I write worst case, right?) of a total of 10000+ classes, you have no other way than manually exploring your project, using find tools but not relying on them.
And if you don't have a test plan, which is the document from which you can hope to originate a software test suite, it will be time to make one.
Just adding my 2 cents. I'm assuming you're working in a production environment so there's got to be some form of unit tests, integration tests and system tests already written.
If yes, then a good way to validate your changes is to run all these tests again and create any new tests which might be necessary.
And to state the obvious, do not integrate your code changes into the main production code base without running these tests.
Yet again changes which worked fine in a test environment may not work in a production environment.
Have some form of source code configuration management system like Subversion, GitHub, CVS etc.
This enables you to roll back your changes

Can I save or fork the current state of Selenium browser?

I have several tests to run and all of them share a certain number x of initial actions (say login, fill form fields, click buttons, etc.), then they diverge.
Is it possible to let the browser execute the first x actions just once, save the current state and then execute all the test separately (in parallel if possible), each one with a separate browser instance?
Thanks
You should try to avoid duplicating effort in your tests. However, you must aim for consistency above all, and maintainability is probably just as important.
What that means is that using the browser in a way a real user wouldn't (I think your state-saving idea counts) is very risky for consistency, and may fail to give you the meaningful results you need.
Another alternative - a 'monolithic' test that attempts to cover multiple scenarios within one user session - is also problematic, because it's slower to run and slower to write and debug.
To be honest I think the idea of "browser state" is one that isn't a good fit for the real web.
My suggestion is to run dedicated, self-contained, clean tests - even if they do duplicate things like login/registration forms. However, if it is important to minimise the length of your test runs, try running them in parallel: ideally on multiple VMs, or via Selenium Grid.

Database objects version control (not schema)

I'm trying to figure out how to implement version control in an environment where we have two DBs: one Testing and one Production.
In Testing. there are an arbitrary number of tasks being tested. These have no constraints in number of objects manipulated and complexity, meaning we can have a 3-day task that changes 2 package bodys and one trigger, and we can have a 3 month task that changes 100 different objects, including ะก source files and binary objects.
My main concern are the text-based objects of the DB. We need to version the Test and Production code, but any task can go from Testing to Production with no defined order whatsoever.
This means right now we have to manually track the changes in the files, selecting inside each file which lines in the code go from Testing to Production. We use a very rudimentary solution, writing in the header a sequence of comments with a file-based version number and adding in the code tags with that sequence to delimit the change.
I'm struggling to implement SVN because I wanted to create Testing as a branch of Production, having branches in Testing to limit each task, but I find that it can lead to many Testing tasks being ported to Production during merges.
This said, my questions are:
Is there a way to resolve this automatically?
Are there any database-specific version control solutions?
How can I "link" both environments if the code base is so different?
I used SVN for source control on DB scripts.
I dont have a technological solution to your problem but i can explain the methodology we used.
We had two sets of scripts - one for incremental changes and another for the complete declaration of database objects and procedures.
During development we updated only the incremental changes in a script that that was eventually used during deployment. during test rounds we updated the script.
Finally, After running the script on production we updated the second set of scripts containing the full declarations. The full scripts were used as reference and to create a db from scratch.

Finding subsets of ClearCase branch types

I'm working on a large project, for which several thousand branch types are defined, and would like to quickly retrieve a list of "my" branch types. This can be achieved either by listing branch types created by me, or by listing branch types whose names start with my username.
As the full list is huge and lstype runs for approximately an hour normally, is there a way to formulate a query that can be answered quickly?
I never found a native command able to return quickly an answer.
When looking at the cleartool lstype command, the technote "LSTYPE performance improvements" does mention that:
The -short, -nostatus and -unsorted options can be used to improve performance of the cleartool lstype command
But as with everything with ClearCase, this doesn't stand the test of the real world, where the number of (here) types quite be really big...
So what I usually do for this kind of request, considering I don't create a brtype every 5 minutes, is to have a batch job running every 2 hours, updating a list of brtype with the informations I need (owner, date, ...).
I can then at any time filter that file (at least the most updated version of that file) in order to extract the list of brtype I need.
There is the risk this list isn't up-to-date, but in practice this works relatively well.

Should I always include test-cases from previous interations?

I recently installed Microsoft Test Manager 2010 and this is my first experience with this style of testing. My usual method of testing is to load up a few different web browsers and run through an application.
The reason I moved to Test Manager was because our application has become quite large and complex and a better way of testing and logging information was needed.
In test manager I chose to use the Agile template where you have a test plan with iterations like so:
[Test Plan]
Iteration 1
Test Cases
Requirements (user Stories)
etc...
Iteration 2
Test Cases
Requirements (user Stories)
etc...
What I don't get is how often do you run through certain test cases? Say for example I am on Iteration 1 and have created a whole bunch of test cases for the application, when I move into Iteration 2 do I copy and paste all the test cases from Iteration 1 into Iteration 2 and rerun them? Do I only run certain ones?
Implementing stories during iteration 2 might impact code (including tests) written during iteration 1. So you definitely want to run all tests to ensure you didn't break anything from Iteration 1 during Iteration 2 (i.e. that you didn't introduce any regression).
I don't use Microsoft Test Manager 2010 so I'm not totally sure but I can imagine that requirements from iteration 2 could change test cases from iteration 1. In that case, I guess you'd have to copy test cases.
As you are following an agile workflow you can run iteration 2 only because iteration 2 have different requirements.
if requirement 2 depends on requirement 1 then you have to run both iterations