Skip to content

Relevance Estimation and Value Calibration in C++

Notifications You must be signed in to change notification settings

Stephocke/REVACpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 

Repository files navigation

REVACpp

Relevance Estimation and Value Calibration in C++

#include "Revac.h"
#include <chrono>	// time


// sphere fitness function
double sphere(const ParaVector& paraVector)
{
	double obj = 0;
	for (int i = 0; i < paraVector.k(); i++)
	{
		double xi = paraVector.at(i);
		obj += std::pow(xi, 2);
	}

	return obj;
}

// rosenbrock fitness function
double rosenbrock(const ParaVector& paraVector)
{
	double obj = 0;
	for (int i = 0; i < paraVector.k() - 1; i++)
	{
		double xi = paraVector.at(i);
		double xiplus = paraVector.at(i + 1);

		obj += 100 * std::pow(xiplus - std::pow(xi, 2), 2) + std::pow(1 - xi, 2);
	}
	return obj;
}

int main()
{
	revacGen.seed(std::chrono::high_resolution_clock::now().time_since_epoch().count());

	int p = 50;   // number of parents
	int h = 5;	 // considered neighbors in mutation
	int k = 60;	 // number of parameter
	int s = 100; // pop size
	std::vector<Bound> bounds(k, Bound{ -10, 10 });

	ParaVector solution = REVAC(k, bounds.data(), sphere, 20000, p, h, s, std::cout);

	std::cout << solution;
}

About

Relevance Estimation and Value Calibration in C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages