simulated_annealing_MI {covalchemy}R Documentation

Simulated Annealing Algorithm with Target Entropy Stopping Condition

Description

This function performs simulated annealing to optimize a given objective (entropy, mutual information, etc.) using a given table modification function. The optimization stops once the target entropy is reached or after a maximum number of iterations.

Usage

simulated_annealing_MI(
  initial_table,
  obj,
  gen_fn,
  target,
  max_n = 5000,
  temp = 10,
  maxim = TRUE,
  readj = FALSE
)

Arguments

initial_table

A contingency table to start the optimization.

obj

An objective function that calculates the value to be optimized (e.g., entropy, mutual information).

gen_fn

A function that generates a new table based on the current table.

target

The target value for the objective function (e.g., target entropy).

max_n

The maximum number of iterations to run the algorithm (default is 5000).

temp

The initial temperature for the simulated annealing process (default is 10).

maxim

Logical: Should the algorithm maximize (TRUE) or minimize (FALSE) the objective function (default is TRUE).

readj

Logical: If TRUE, the algorithm is in a readjusting state (default is FALSE).

Value

A list containing:

Examples

# Example of using simulated annealing for entropy maximization:
initial_table <- matrix(c(5, 3, 4, 2), nrow = 2, ncol = 2)
obj <- entropy_pair  # Example entropy function
gen_fn <- gen_number_max  # Example generation function
target <- 0.5
result <- simulated_annealing_MI(initial_table, obj, gen_fn, target)


[Package covalchemy version 1.0.0 Index]