/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Flower Constancy algortihm created by Pawel Kopciewicz, February 2018 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% An example usage of Flower Constancy algorithm for given function model %
% fitting (data from distorted Gauss distribution with C, mi, sigma). %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include
#include
#include
#include
using namespace std;
double FCA(int points, double *x, double *y){
int N=250; //Number of algorithm iterations
int n=20; //Number of flowers
int P=points; //Number of points we fit a model to
double pop[50][4]; double pop2[50][4]; //Arrays for flower positions
double cost[n]; double cost2; //Vectors for position evaluations
//Random initial solution:
for(int i=0; i