# Evolving shapes

<multilang> @en CVS repository:

## Source code

CVS repository RELEASE version [1]

Mark Ebner - Evolutionary design [2]

Kenny Erleben - Multibody dynamics [3]

BREVE Simulator - Breve Documentation [4]

Funes, Pollack - Computer Evolution of Buildable Objects [6]

Piyush Kumar - Triangle++ - Delaunay triangulation code [7]

wikipedia - Delaunay triangulation [8]

## Parallel Computing Section

PVM short description - [9]

ParadisEO is using either MPI (LAM-MPI) or PVM. LAM-MPI is mostly for UNIX platforms - difficult to install on Windows. PVM should run everywhere.
New MPI implementation - OPEN MPI

## Evolutionary algorithms

Genotype - in slovak lang.: reprezentacia subjektu evolucie (jedinca) vo forme vhodnej na operatory krizenia, mutacie, na evaluaciu fitness a na ine ?

Red point = point (1, 0, 0) - along x-axis
Blue point = point (0, 1, 0) - along y-axis
Z-axis goes up

WARNING: use only float (not double) with TriMesh

First version of air particles flying through propeller

Tuned version of particles flying through propeller with source code: source 2

Notes:
• Friction set to 0, dInfinity value is causing unrealistic and strange behaviour
• Density of particles is just approximatelly 4 times smaller than that of propeller
• Size of particles is big (10 times bigger than thickness of blade of propeller)

To be able to use complex rotation for next TriMesh example, a study of Quaternions is inevitable.
Applications of Quaternions

Same example as above but with Triangular Mesh representation - at the moment very simple - source 3

Notes:
• For 2 consecutive simple rotation, 2 conversion from simple rotational matrix to quaternion was used, followed by quaternion multiplication and conversion back to complex rotational matrix
• Geom of blades is represented by 0-thin triangle, but with defined mass (based on the volume of blade with 0.001-thickness
• Blades are visible only from the 'front' - from the side of impacting particles

Rotor with complex TriMesh blades - source 4

Notes:
• Missing lines in Triangular Mesh is just visualization bug

Simulation without graphical output - source 6

Parameters:
• Total number of particles: 1000
• Particle size: 0.000 001
• Tiangle side length (in TriMesh): 0.05
• Density of rotor: 1.0
• Density of particle: 10 000 000.0
• Initial force: 0.000 1
• Time step: 0.01

Running time:

MachineDebug timeOptimized time
1.6GHz Linux13.42s13.02s
2x2.16GHz WinXP43.68s7.77s

Angular velocity of rotor after last step of simulation: 1.20865

IMPORTANT: Particle size >= TimeStep x Particle Velocity, otherwise particle can fly through TriMesh, as it is "jumping" in steps along its trajectory, it is not continuous flight. Therefore it is not feasible to use too tiny particles, as it would require step size too small or velocity too small, or both, in any case the simulation would be terribly slow.

Code for random generator initialization:

```#include <ctime>

time_t tim;
dRandSetSeet ((unsigned long) time (&tim));
```

IMPORTANT: MAX_CONTACTS must be more than 1 -> otherwise Floating exception occurs (see juro8-Big.cpp) - so for example MAX_CONTACTS=2 used

CONSTANTS:

```#define NUM 2000			// max number of objects
#define DENSITY_ROTOR (10.0)		// density of rotor
#define DENSITY_AIR (1.0)	// density of air particle
#define MAX_CONTACTS 2		// maximum number of contact points per body
#define NEW_PER_STEP	10		// must be less then NUM
#define TIMESTEP	0.01
#define MOLECULE_SIZE	0.1
#define INITIAL_VELOCITY_Y 10.0
#define DAMPING_COEF 0.0001
#define PI 3.14159265
```

Example:
surface perpendicular to air flow = cca 50m^2 => in 1 sec (= 100 timesteps) at 10m.s^-1 500kg of air (1kg.m^-3) pushes on surface
average hit rate by air particles in 1 sec (= 100 timesteps) is 1250 => 0.4kg for 1 particle</br> 0.4 per particle with 0.1m radius => 100kg.m^-3 density of particle
density of rotor is 10times more than particle, because normally we take density of rotor 1000kg.m^-3

## Memory bug - segmentation fault (linux) - stack overflow (windows) - fixed (at least looks like that)

```// Use the error-checking memory allocation system.  Because this system uses heap
//  (malloc) instead of stack (alloca), it is slower.  However, it allows you to
//  simulate larger scenes, as well as handle out-of-memory errors in a somewhat
//  graceful manner

#define dUSE_MALLOC_FOR_ALLOCA

#ifdef dUSE_MALLOC_FOR_ALLOCA
enum {
d_MEMORY_OK = 0,		/* no memory errors */
d_MEMORY_OUT_OF_MEMORY	/* malloc failed due to out of memory error */
};

#endif
```

## Distributed evolution - example

Evaluator program
[Windows version]
[Linux script]

@sk Táto stránka je o diplomovom projekte o použití evolučných výpočtov na návrh tvarov trojrozmerných predmetov. Nachádza sa tu zatiaľ iba anglická verzia stránky.

</multilang>

--- --- --- English: Evolving shapes/en Slovensky: Evolving shapes/sk --- --- ---
--- --- --- --- --- RoboWiki: (c) 2006 Robotika.sk --- --- --- --- ---