diff --git a/Makefile b/Makefile index 7cc2909a..a80e8da7 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,9 @@ lulu: r clean: rm -rf ${BOOK}/*.pdf ${BOOK}/*.aux ${BOOK}/*.log ${BOOK}/*.out ${BOOK}/*.toc \ ${BOOK}/*.idx ${BOOK}/*.ilg ${BOOK}/*.ind ${BOOK}/*.bak ${BOOK}/*.bbl ${BOOK}/*.blg - rm -rf ${WEB}/docs ${WEB}/epub_temp ${WEB}/*.epub + rm -rf ${WEB}/docs ${WEB}/epub_temp + rm -rf *.epub + rm -rf tests.log # View the development PDF on Linux vl: @@ -45,6 +47,41 @@ vm: jl: java -jar /opt/jabref/JabRef-2.7.2.jar 2>1 1>/dev/null & -# create the webpage version -web: web/generate.rb - ruby web/generate.rb +# create the webpage version for CleverAlgorithms.com +web: ${WEB}/generate.rb + ruby ${WEB}/generate.rb + +# create epub version for iphone/ipad and friends +epub: ${WEB}/generate_epub.rb + ruby ${WEB}/generate_epub.rb + +# unit test ruby source code - DRY this up a bit +test: + rm -rf tests.log + echo "testing..." + for file in src/algorithms/evolutionary/tests/* ; do \ + ruby $$file | tee -a tests.log ; \ + done + for file in src/algorithms/immune/tests/* ; do \ + ruby $$file | tee -a tests.log ; \ + done + for file in src/algorithms/neural/tests/* ; do \ + ruby $$file | tee -a tests.log ; \ + done + for file in src/algorithms/physical/tests/* ; do \ + ruby $$file | tee -a tests.log ; \ + done + for file in src/algorithms/probabilistic/tests/* ; do \ + ruby $$file | tee -a tests.log ; \ + done + for file in src/algorithms/stochastic/tests/* ; do \ + ruby $$file | tee -a tests.log ; \ + done + for file in src/algorithms/swarm/tests/* ; do \ + ruby $$file | tee -a tests.log ; \ + done + for file in src/programming_paradigms/tests/* ; do \ + ruby $$file | tee -a tests.log ; \ + done + echo "DONE" + cat tests.log | grep -E ' Error:| Failure:|No such file or directory' \ No newline at end of file diff --git a/README.textile b/README.textile index b189e59c..1052233f 100644 --- a/README.textile +++ b/README.textile @@ -27,6 +27,7 @@ h3. How to Build # @cd CleverAlgorithms@ # @make r@ (creates the file @book/book.pdf@) # @make vl@ (to view the PDF on linux) or @make vm@ (to view the PDF on mac) +# @make epub@ (creates epub versions) h3. Contribute diff --git a/src/algorithms/all_tests.sh b/src/algorithms/all_tests.sh deleted file mode 100755 index f538b49a..00000000 --- a/src/algorithms/all_tests.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/sh - -LOG=all_tests.log - -# evolutionary -function evolutionary { - ruby evolutionary/tests/tc_differential_evolution.rb | tee -a $LOG - ruby evolutionary/tests/tc_evolution_strategies.rb | tee -a $LOG - ruby evolutionary/tests/tc_evolutionary_programming.rb | tee -a $LOG - ruby evolutionary/tests/tc_gene_expression_programming.rb | tee -a $LOG - ruby evolutionary/tests/tc_genetic_algorithm.rb | tee -a $LOG - ruby evolutionary/tests/tc_genetic_algorithm2.rb | tee -a $LOG - ruby evolutionary/tests/tc_genetic_programming.rb | tee -a $LOG - ruby evolutionary/tests/tc_grammatical_evolution.rb | tee -a $LOG - ruby evolutionary/tests/tc_learning_classifier_system.rb | tee -a $LOG - ruby evolutionary/tests/tc_nsgaii.rb | tee -a $LOG - ruby evolutionary/tests/tc_spea2.rb | tee -a $LOG -} - -# immune -function immune { - ruby immune/tests/tc_airs.rb | tee -a $LOG - ruby immune/tests/tc_clonal_selection_algorithm.rb | tee -a $LOG - ruby immune/tests/tc_dendritic_cell_algorithm.rb | tee -a $LOG - ruby immune/tests/tc_negative_selection_algorithm.rb | tee -a $LOG - ruby immune/tests/tc_optainet.rb | tee -a $LOG -} - -# neural -function neural { - ruby neural/tests/tc_backpropagation.rb | tee -a $LOG - ruby neural/tests/tc_hopfield.rb | tee -a $LOG - ruby neural/tests/tc_lvq.rb | tee -a $LOG - ruby neural/tests/tc_perceptron.rb | tee -a $LOG - ruby neural/tests/tc_som.rb | tee -a $LOG -} - -# physical -function physical { - ruby physical/tests/tc_cultural_algorithm.rb | tee -a $LOG - ruby physical/tests/tc_extremal_optimization.rb | tee -a $LOG - ruby physical/tests/tc_harmony_search.rb | tee -a $LOG - ruby physical/tests/tc_memetic_algorithm.rb | tee -a $LOG - ruby physical/tests/tc_simulated_annealing.rb | tee -a $LOG -} - -# probabilistic -function probabilistic { - ruby probabilistic/tests/tc_boa.rb | tee -a $LOG - ruby probabilistic/tests/tc_compact_genetic_algorithm.rb | tee -a $LOG - ruby probabilistic/tests/tc_cross_entropy_method.rb | tee -a $LOG - ruby probabilistic/tests/tc_pbil.rb | tee -a $LOG - ruby probabilistic/tests/tc_umda.rb | tee -a $LOG -} - -# stochastic -function stochastic { - ruby stochastic/tests/tc_adaptive_random_search.rb | tee -a $LOG - ruby stochastic/tests/tc_grasp.rb | tee -a $LOG - ruby stochastic/tests/tc_guided_local_search.rb | tee -a $LOG - ruby stochastic/tests/tc_iterated_local_search.rb | tee -a $LOG - ruby stochastic/tests/tc_random_search.rb | tee -a $LOG - ruby stochastic/tests/tc_reactive_tabu_search.rb | tee -a $LOG - ruby stochastic/tests/tc_scatter_search.rb | tee -a $LOG - ruby stochastic/tests/tc_stochastic_hill_climbing.rb | tee -a $LOG - ruby stochastic/tests/tc_tabu_search.rb | tee -a $LOG - ruby stochastic/tests/tc_variable_neighborhood_search.rb | tee -a $LOG -} - -# swarm -function swarm { - ruby swarm/tests/tc_ant_colony_system.rb | tee -a $LOG - ruby swarm/tests/tc_ant_system.rb | tee -a $LOG - ruby swarm/tests/tc_bees_algorithm.rb | tee -a $LOG - ruby swarm/tests/tc_bfoa.rb | tee -a $LOG - ruby swarm/tests/tc_pso.rb | tee -a $LOG -} - -# paradigms -function paradigms { - ruby ../programming_paradigms/tests/tc_flow.rb | tee -a $LOG - ruby ../programming_paradigms/tests/tc_oop.rb | tee -a $LOG -} - - -# clear the log -date > $LOG - -# execute - -evolutionary -immune -neural -physical -probabilistic -stochastic -swarm -paradigms - -# summary -TESTS=`cat ./all_tests.log | grep Started | wc -l` - -printf "\nSummary of Results: (total tests=%d)\n" $TESTS -echo "------------------------------------------------------------" -cat all_tests.log | grep -E ' Error:| Failure:|No such file or directory' diff --git a/web/generate_epub.rb b/web/generate_epub.rb index f3efbc8f..38c80c04 100644 --- a/web/generate_epub.rb +++ b/web/generate_epub.rb @@ -5,7 +5,7 @@ # This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Australia License. require 'rubygems' -require 'generate' +require File.expand_path(File.dirname(__FILE__)) + '/generate' require 'pp' require 'cgi' require 'digest/sha1' @@ -24,7 +24,7 @@ exit end -OUTPUT_DIR = "epub_temp" +OUTPUT_DIR = "web/epub_temp" # Returns the svg for the latex expression def render_svg(latex) @@ -95,11 +95,11 @@ def epubize_file(filename) def nav_for_topic(topic, label, folder_prefix_letter) item = {:label => label, :content => "#{topic}.html"} - lines = get_all_data_lines("../book/c_#{topic}.tex") + lines = get_all_data_lines("book/c_#{topic}.tex") data = general_process_file(lines) subpages = collect_subpages_for_page(data) item[:nav] = subpages.map do |page| - {:label => get_algorithm_name("../book/#{folder_prefix_letter}_#{topic}/#{page}.tex"), + {:label => get_algorithm_name("book/#{folder_prefix_letter}_#{topic}/#{page}.tex"), :content => "#{page}.html"} end item @@ -207,7 +207,7 @@ def replace_png_links_with_inline_svg identifier 'urn:uuid:978-1-4467-8506-5-x', :scheme => 'ISBN' uid 'http://www.cleveralgorithms.com/' - files Dir.glob("./epub_assets/**")+ordered_html_files+Dir.glob("./#{OUTPUT_DIR}/LaTeX*.png") + files Dir.glob("./web/epub_assets/**")+ordered_html_files+Dir.glob("./#{OUTPUT_DIR}/LaTeX*.png") nav navigation_map end puts "Building epub file with LaTeX in pngs" @@ -223,7 +223,7 @@ def replace_png_links_with_inline_svg identifier 'urn:uuid:978-1-4467-8506-5-x', :scheme => 'ISBN' uid 'http://www.cleveralgorithms.com/' - files Dir.glob("./epub_assets/**")+ordered_html_files+Dir.glob("./#{OUTPUT_DIR}/LaTeX*.svg") + files Dir.glob("./web/epub_assets/**")+ordered_html_files+Dir.glob("./#{OUTPUT_DIR}/LaTeX*.svg") nav navigation_map end puts "Building epub file with LaTeX in svgs"