Math-Evol

 view release on metacpan or  search on metacpan

Evol.pm  view on Meta::CPAN

The most robust criterion is the maximum-cpu-time parameter $tm

=head1 LUA

In the C<lua/> subdirectory of the install directory there is
I<Evol.lua>, which is an exact translation of this Perl code into Lua.
The function names and arguments are unchanged,
except that I<text_evol> is not yet implemented.
Brief Synopsis:

 local M = require 'Evol'
 local function minimise(x) -- returns a number to be minimised
    local sum = 1.0
    for k,v in pairs(x) do sum = sum + v * v end
    return sum
 end
 local function constrain(x)
    if x[1] > 1.0 then x[1] = 1.0  -- it's a greyscale value
    elseif x[1] < 0.0 then x[1] = 0.0
    end
    return x

lua/Evol.html  view on Meta::CPAN

<p>
</p>
<hr />
<h2><a name="name">NAME</a></h2>
<p>Evol - Evolution search optimisation</p>
<p>
</p>
<hr />
<h2><a name="synopsis">SYNOPSIS</a></h2>
<pre>
 local EV = require 'Evol'
 xb, sm, fb, lf = evol(xb, sm, function, constrain, tm)
 -- or
 xb, sm = select_evol(xb, sm, choose_best, constrain)</pre>
<pre>
 -- not yet implemented:
 -- new_text = text_evol(text, choose_best_text, nchoices );</pre>
<p>
</p>
<hr />
<h2><a name="description">DESCRIPTION</a></h2>

lua/Evol.lua  view on Meta::CPAN

--                       www.pjb.com.au                           --
--                                                                --
--  This module is free software; you can redistribute it and/or  --
--         modify it under the same terms as Lua5 itself.         --
--------------------------------------------------------------------
local M = {} -- public interface
M.Version = '1.13'
M.VersionDate = '27aug2010'

-- Example usage:
--local MM = require 'Evol'
--MM.bar()

----------------- infrastructure for evol ----------------
local function arr2txt(a) -- neat printing of arrays for debug use
	local txt = {}
	for k,v in ipairs(a) do txt[#txt+1] = string.format('%g',v); end
	return table.concat(txt,' ')
end
local function warn(str)
	io.stderr:write(str,'\n')

lua/Evol.lua  view on Meta::CPAN

--[[

=pod

=head1 NAME

Evol - Evolution search optimisation

=head1 SYNOPSIS

 local EV = require 'Evol'
 xb, sm, fb, lf = evol(xb, sm, function, constrain, tm)
 -- or
 xb, sm = select_evol(xb, sm, choose_best, constrain)

 -- not yet implemented:
 -- new_text = text_evol(text, choose_best_text, nchoices );

=head1 DESCRIPTION

This module implements the evolution search strategy.  Derivatives of

lua/test.lua  view on Meta::CPAN

-- ----------------------------------------------------------------- --
--      This Lua5 script is Copyright (c) 2010, Peter J Billam       --
--                        www.pjb.com.au                             --
--                                                                   --
--   This script is free software; you can redistribute it and/or    --
--          modify it under the same terms as Lua5 itself.           --
-- ----------------------------------------------------------------- --
local Version = '1.0  for Lua5'
local VersionDate  = '25aug2010';
local detailed = false
local M = require 'Evol'

--------------------------- infrastructure ------------------------
local Test = 12 ; local i_test = 0; local Failed = 0;
function ok(b,s)
	i_test = i_test + 1
	if b then
		io.write('ok '..i_test..' - '..s.."\n")
	else
		io.write('not ok '..i_test..' - '..s.."\n")
		Failed = Failed + 1



( run in 0.504 second using v1.01-cache-2.11-cpan-05444aca049 )