source: java/main/src/main/java/com/framsticks/parsers/GenotypeLoader.java @ 99

Last change on this file since 99 was 99, checked in by psniegowski, 11 years ago

HIGHLIGTS:

  • complete events implementation
  • add CLI in Java Framsticks server
  • add automatic registration for events in GUI
  • improve objects fetching (object are never overwritten with new instances)
  • properly react for ListChange? events
  • add ListPanel? with table view
    • columns to be shown may be statically specified in configuration
    • currently modyfying data through tables is not available
  • improve maven configuration
    • configuration file may be specified without touching pom.xml

CHANGELOG:
Extract constants from Flags into ParamFlags? and SetStateFlags?.

Extract flags I/O to FlagsUtils? class.

Configured maven to exec given resource configuration.

For example:
mvn exec:exec -Dframsticks.config=/configs/managed-console.xml

Cleanup pom.xml

Rename ObjectTree? to LocalTree? (also make LocalTree? and RemoteTree? final).

Minor change.

Add maximum number of columns in ListPanelProvider?.

Improve ColumnsConfig? interpretation.

Automatically fill FramsClass?.name if trying to construct empty.

Improve identitifer case mangling in XmlLoader?.

Introduce configurable ColumnsConfig?.

Draft working version of ListPanel?.

Table is being shown (although empty).

More improvements to table building.

Move some functionality from Frame to TreeModel?.

Move tree classes in gui to separate package.

Remove old table related classes.

Add draft implementation of TableModel?.

Redirect ParamBuilder?.forAccess to AccessInterface?.

Optimize ParamBuilder?.forAccess()

Do not clear list when loading.

Do not load fetched values directly.

Implement different AccessInterface? copying policy.

Optimize fetching values routine.

Remove Mode enum (work out get semantics).

Some improvements to ListChange? handling.

Improve UniqueListAccess?.

Add reaction for ListChanges? in the TreeNode?.

EventListeners? are being added in the TreeNode?.

Listeners for ListParams? are now very naive (they download
whole list).

Automatially register on events in GUI.

Events are working in RemoteTree? and Server.

Move listeners to the ClientSideManagedConnection?.

Remove old classes responsible for event subscriptions.

Improve event reading.

Improve events handling at server side.

Add register attribute in FramsClassAnnotation?
to automatically also register other classes.

Registering events works.

Setup for remote listeners registration.

More improvements.

Minor changes.

Add rootTree to the ClientAtServer?.

Moving CLI to the ClientAtServer?.

Fix bug: use Void.TYPE instead of Void.class

More development around CLI.

  • Improve Path resolving.

Add synthetic root to ObjectTree?.

It is needed to allow sybling for the original root
that would containg CLI.

Some work with registering events in RemoteTree?.

Draft implementation of listener registering in RemoteTree?.

Support events registration in the ObjectTree?.

Add events support to ReflectionAccess?.

EventParam? is recognized by ParamCandidate?.

Prepare interface for Events across project.

Add EventListener? and API for listeners in Tree.

File size: 4.8 KB
Line 
1package com.framsticks.parsers;
2
3import com.framsticks.model.Genotype;
4import com.framsticks.params.*;
5import com.framsticks.params.types.*;
6
7import org.apache.log4j.Logger;
8import static com.framsticks.params.ParamFlags.*;
9
10public class GenotypeLoader extends MultiParamLoader {
11        private Genotype genotypeReturnObject = new Genotype();
12        private static Logger logger = Logger.getLogger(GenotypeLoader.class);
13
14        public GenotypeLoader() throws Exception {
15
16                FramsClass entries = FramsClass.build()
17                        .name("Genotype")
18                        .id("org")
19                        .description("A Genotype with the associated performance information. All but one Genotype objects are placed in Genotype Groups. There is also a single static Genotype object not associated with a group, which is used as a temporary storage by genetic operators and some functions from GenePools.")
20                        .group("Body")
21                        .group("Performance")
22                        .group("Fitness")
23                        .group("Conversions")
24                        .param(Param.build().id("name").group(0).name("Name").type(StringParam.class).min(0).max(40))
25                        .param(Param.build().id("genotype").group(0).name("Genotype").type(StringParam.class).min(1))
26                        .param(Param.build().id("info").group(0).name("Info").type(StringParam.class).min(1).help("Additional information or comments"))
27                        .param(Param.build().id("simi").group(1).flags(READONLY | DONTSAVE).name("Similarity").type(FloatParam.class))
28                        .param(Param.build().id("energ0").group(1).flags(READONLY | DONTSAVE).name("Starting energy").type(FloatParam.class))
29                        .param(Param.build().id("strsiz").group(1).flags(READONLY | DONTSAVE | USERHIDDEN).name("Body parts (deprecated; use numparts)").type(FloatParam.class))
30                        .param(Param.build().id("strjoints").group(1).flags(READONLY | DONTSAVE | USERHIDDEN).name("Body joints (deprecated; use numjoints)").type(FloatParam.class))
31                        .param(Param.build().id("nnsiz").group(1).flags(READONLY | DONTSAVE | USERHIDDEN).name("Brain size (deprecated; use numneurons)").type(FloatParam.class))
32                        .param(Param.build().id("nncon").group(1).flags(READONLY | DONTSAVE | USERHIDDEN).name("Brain connections (deprecated; use numconnections)").type(FloatParam.class))
33                        .param(Param.build().id("numparts").group(1).flags(READONLY | DONTSAVE).name("Body parts").type(FloatParam.class))
34                        .param(Param.build().id("numjoints").group(1).flags(READONLY | DONTSAVE).name("Body joints").type(FloatParam.class))
35                        .param(Param.build().id("numneurons").group(1).flags(READONLY | DONTSAVE).name("Brain size").type(FloatParam.class))
36                        .param(Param.build().id("numconnections").group(1).flags(READONLY | DONTSAVE).name("Brain connections").type(FloatParam.class))
37                        .param(Param.build().id("num").group(2).name("Ordinal number").type(DecimalParam.class))
38                        .param(Param.build().id("gnum").group(2).name("Generation").type(DecimalParam.class))
39                        .param(Param.build().id("popsiz").group(2).flags(USERHIDDEN).name("Deprecated; use entities").type(DecimalParam.class))
40                        .param(Param.build().id("entities").group(2).flags(DONTSAVE).name("Instances").type(DecimalParam.class).help("Copies of this genotype"))
41                        .param(Param.build().id("lifespan").group(2).name("Life span").type(FloatParam.class).help("Average life span"))
42                        .param(Param.build().id("velocity").group(2).name("Velocity").type(FloatParam.class).help("Average velocity"))
43                        .param(Param.build().id("distance").group(2).name("Distance").type(FloatParam.class))
44                        .param(Param.build().id("vertvel").group(2).name("Vertical velocity").type(FloatParam.class))
45                        .param(Param.build().id("vertpos").group(2).name("Vertical position").type(FloatParam.class))
46                        .param(Param.build().id("fit").group(3).flags(READONLY | DONTSAVE).name("Fitness").type(FloatParam.class))
47                        .param(Param.build().id("fit2").group(3).flags(READONLY | DONTSAVE).name("Final fitness").type(FloatParam.class).help("Fitness shifted by (avg-n*stddev)"))
48                        .param(Param.build().id("f0genotype").group(4).flags(READONLY | DONTSAVE).name("f0 genotype").type(StringParam.class).min(1).help("converted to f0 genotype"))
49                        .param(Param.build().id("user1").group(2).name("User field 1").type(UniversalParam.class))
50                        .param(Param.build().id("user2").group(2).name("User field 2").type(UniversalParam.class))
51                        .param(Param.build().id("user3").group(2).name("User field 3").type(UniversalParam.class))
52                        .param(Param.build().id("isValid").group(0).flags(READONLY | DONTSAVE | USERHIDDEN).name("Valid").type(DecimalParam.class).min(0).max(1))
53                        .param(Param.build().id("uid").group(0).flags(READONLY | USERHIDDEN).name("#").type("s").help("Unique identifier"))
54                        .finish();
55
56                AccessInterface reflectionParam = new PropertiesAccess(entries);
57                addAccessInterface(reflectionParam);
58                addBreakCondition(Status.AfterObject);
59        }
60
61        public Genotype loadNextGenotype() throws Exception {
62                logger.info("Loading next genotype");
63                Status result = go();
64
65                if (result == Status.AfterObject) {
66                        return genotypeReturnObject;
67                }
68
69                return null;
70        }
71}
Note: See TracBrowser for help on using the repository browser.