evaluation: Evaluate the fitness of a population

View source: R/evaluation.R

evaluationR Documentation

Evaluate the fitness of a population

Description

Internal function of the genetic algorithm that evaluates the fitness (penalized log-likelihood) of a set (population) of permutations. It internally computes the best triangular matrix associated to each permutation of the population.

Usage

evaluation(
  Pop,
  X,
  XtX = NULL,
  lambda,
  grad.control = list(tol.obj = 1e-06, max.ite = 50),
  ncores = 1
)

Arguments

Pop

Population of permutations from [1,p]: matrix with pop.size rows and p columns, each row corresponding to one permutation of the population.

X

Design matrix, with samples (n) in rows and variables (p) in columns.

XtX

(optional) Cross-product of X; computed if not provided.

lambda

Parameter of penalization (>0).

grad.control

A list containing the parameters for controlling the inner optimization, i.e. the gradient descent

tol.obj.inner

tolerance (>0),

max.ite.inner

maximum number of iterations (>0).

ncores

Number of cores (>1, depending on your computer).

Value

A list with the following elements:

Tpop

Matrix with pxp columns, each column corresponding to the best triangular matrix (in a vector form) associated to each permutation of the population.

f

Fitness of the population.

A list with the following elements:

Tpop

Matrix with p rows and pop.size columns, each column corresponding to the best triangular matrix (in a vector form) associated to each permutation of the population.

f

Fitness of the population.

Author(s)

Magali Champion [aut, cre], Victor Picheny [aut], Matthieu Vignes [aut]

See Also

GADAG, GADAG_Run, fitness.

Examples

 #############################################################
 # Loading toy data
 #############################################################
 data(toy_data)
 # toy_data is a list of two matrices corresponding to a "star"
 # DAG (node 1 activates all other nodes):
 # - toy_data$X is a 100x10 design matrix
 # - toy_data$G is the 10x10 adjacency matrix (ground trough)

 ########################################################
 # Creating a population of permutations
 ########################################################
 # first, define the parameters
 p <- ncol(toy_data$G) # number of nodes
 pop.size <- 10 # population size

 # then create your population of permutations
 Pop <- matrix(data = 0, nrow = pop.size, ncol = p)
 for(i in 1:pop.size){
     Pop[i,] = sample(p)
 }

 ########################################################
 # Evaluating the fitness of the population
 ########################################################
 # evaluation of the whole population
 Evaluation <- evaluation(Pop=Pop,X=toy_data$X,lambda=0.1)
 print(Evaluation$f) # here is the fitness of the whole population

 # evaluation of one of the permutation
 Perm <- Pop[1,]
 Evaluation <- evaluation(Pop=Perm,toy_data$X,lambda=0.1)

 # optimal matrix T associated to Perm:
 T <- matrix(Evaluation$Tpop,p,p)

GADAG documentation built on Sept. 10, 2026, 5:07 p.m.