fitness: Compute the fitness of a potential solution

Description Usage Arguments Value Author(s) See Also Examples

View source: R/fitness.R

Description

Internal function of the genetic algorithm that evaluates the fitness (penalized log-likelihood) of a potential solution, given as a pair of a permutation (P) and a triangular matrix (T).

Usage

1
fitness(P,X,T,lambda)

Arguments

P

A permutation from [1,p] in a matrix form.

X

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

T

A pxp lower-triangular matrix.

lambda

Parameter of penalization (>0).

Value

A numeric value corresponding to the fitness of the potential solution.

Author(s)

Magali Champion, Victor Picheny and Matthieu Vignes

See Also

GADAG, GADAG_Run, evaluation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 #############################################################
 # 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 candidate solution
 ############################################################
 # define parameters
 p <- ncol(toy_data$G)

 # permutation matrix
 Perm <- sample(p) # permutation in a vector form
 P <- matrix(0,p,p)
 P[p*0:(p-1) + Perm] <- 1 # Perm is tranformed into a matrix form

 # lower-triangular matrix
 T <- matrix(rnorm(p),p,p)
 T[upper.tri(T,diag=TRUE)] <- 0

 ########################################################
 # Computing the fitness of the potential solution
 ########################################################
 Fitness <- fitness(P=P, X=toy_data$X, T=T, lambda=0.1)
 print(Fitness) # here is the fitness of the candidate solution (P,T)

GADAG documentation built on May 2, 2019, 3:25 p.m.