Skip to content
Permalink
Browse files

removed parallelization in example.m

  • Loading branch information...
claesenm committed Oct 26, 2014
1 parent c0d6acd commit d527405a17d0b886cef7169cbc27f1b49bd8b807
Showing with 20 additions and 17 deletions.
  1. 0 .gitignore
  2. 0 LICENSE.txt
  3. 0 MANIFEST.in
  4. 0 README.rst
  5. 0 bin/examples_scikit-learn_svm.py
  6. 0 bin/print_system_path.py
  7. 0 docs/Makefile
  8. 0 docs/api/modules.rst
  9. 0 docs/api/optunity.api.rst
  10. 0 docs/api/optunity.communication.rst
  11. 0 docs/api/optunity.cross_validation.rst
  12. 0 docs/api/optunity.functions.rst
  13. 0 docs/api/optunity.piped.rst
  14. 0 docs/api/optunity.rst
  15. 0 docs/api/optunity.score_functions.rst
  16. 0 docs/api/optunity.solver_registry.rst
  17. 0 docs/api/optunity.solvers.rst
  18. 0 docs/api/optunity.test.functions.rst
  19. 0 docs/api/optunity.test.rst
  20. 0 docs/api/optunity.test.solvers.rst
  21. 0 docs/api/optunity.util.rst
  22. 0 docs/conf.py
  23. 0 docs/dev/index.rst
  24. 0 docs/examples/cross_validation.rst
  25. 0 docs/examples/index.rst
  26. 0 docs/index.rst
  27. 0 docs/make.bat
  28. 0 docs/user/cross_validation.rst
  29. 0 docs/user/index.rst
  30. 0 docs/user/installation.rst
  31. 0 docs/user/solvers.rst
  32. 0 docs/user/solvers/CMA_ES.rst
  33. 0 docs/user/solvers/grid_search.rst
  34. 0 docs/user/solvers/nelder-mead.rst
  35. 0 docs/user/solvers/particle_swarm.rst
  36. 0 docs/user/solvers/random_search.rst
  37. 0 docs/wrappers/R/index.rst
  38. 0 docs/wrappers/R/installation.rst
  39. 0 docs/wrappers/index.rst
  40. 0 docs/wrappers/matlab/index.rst
  41. 0 docs/wrappers/matlab/installation.rst
  42. 0 optunity/__init__.py
  43. 0 optunity/api.py
  44. 0 optunity/communication.py
  45. +10 −1 optunity/cross_validation.py
  46. 0 optunity/functions.py
  47. 0 optunity/parallel.py
  48. 0 optunity/score_functions.py
  49. 0 optunity/solver_registry.py
  50. 0 optunity/solvers.py
  51. 0 optunity/test/__init__.py
  52. 0 optunity/util.py
  53. 0 requirements.txt
  54. 0 setup.py
  55. 0 wrappers/R/.gitignore
  56. 0 wrappers/R/DESCRIPTION
  57. +0 −1 wrappers/R/LICENSE
  58. 0 wrappers/R/NAMESPACE
  59. 0 wrappers/R/R/comm.R
  60. 0 wrappers/R/R/crossvalidation.R
  61. 0 wrappers/R/R/optunity.R
  62. 0 wrappers/R/README.md
  63. 0 wrappers/R/inst/example.R
  64. +0 −1 wrappers/R/inst/optunity
  65. 0 wrappers/R/inst/tests/testthat/test-cv-scores.r
  66. 0 wrappers/R/inst/tests/testthat/test-cv.r
  67. 0 wrappers/R/inst/tests/testthat/test-make_solver.r
  68. 0 wrappers/R/inst/tests/testthat/test-optimization.r
  69. 0 wrappers/matlab/+optunity/+comm/json_decode.m
  70. 0 wrappers/matlab/+optunity/+comm/json_encode.m
  71. 0 wrappers/matlab/+optunity/+comm/launch.m
  72. +1 −5 wrappers/matlab/+optunity/+comm/popen.m
  73. 0 wrappers/matlab/+optunity/+comm/readpipe.m
  74. 0 wrappers/matlab/+optunity/+comm/writepipe.m
  75. 0 wrappers/matlab/+optunity/@Solver/Solver.m
  76. 0 wrappers/matlab/+optunity/generate_folds.m
  77. 0 wrappers/matlab/+optunity/make_solver.m
  78. 0 wrappers/matlab/+optunity/manual.m
  79. 0 wrappers/matlab/+optunity/maximize.m
  80. 0 wrappers/matlab/+optunity/process_varargin.m
  81. +9 −9 wrappers/matlab/example.m
0 .gitignore 100644 → 100755
No changes.
0 LICENSE.txt 100644 → 100755
No changes.
0 MANIFEST.in 100644 → 100755
No changes.
0 README.rst 100644 → 100755
No changes.
0 bin/examples_scikit-learn_svm.py 100644 → 100755
No changes.
0 bin/print_system_path.py 100644 → 100755
No changes.
0 docs/Makefile 100644 → 100755
No changes.
0 docs/api/modules.rst 100644 → 100755
No changes.
0 docs/api/optunity.api.rst 100644 → 100755
No changes.
No changes.
No changes.
0 docs/api/optunity.functions.rst 100644 → 100755
No changes.
0 docs/api/optunity.piped.rst 100644 → 100755
No changes.
0 docs/api/optunity.rst 100644 → 100755
No changes.
No changes.
No changes.
0 docs/api/optunity.solvers.rst 100644 → 100755
No changes.
No changes.
0 docs/api/optunity.test.rst 100644 → 100755
No changes.
No changes.
0 docs/api/optunity.util.rst 100644 → 100755
No changes.
0 docs/conf.py 100644 → 100755
No changes.
0 docs/dev/index.rst 100644 → 100755
No changes.
No changes.
0 docs/examples/index.rst 100644 → 100755
No changes.
0 docs/index.rst 100644 → 100755
No changes.
0 docs/make.bat 100644 → 100755
No changes.
0 docs/user/cross_validation.rst 100644 → 100755
No changes.
0 docs/user/index.rst 100644 → 100755
No changes.
0 docs/user/installation.rst 100644 → 100755
No changes.
0 docs/user/solvers.rst 100644 → 100755
No changes.
0 docs/user/solvers/CMA_ES.rst 100644 → 100755
No changes.
0 docs/user/solvers/grid_search.rst 100644 → 100755
No changes.
0 docs/user/solvers/nelder-mead.rst 100644 → 100755
No changes.
No changes.
No changes.
0 docs/wrappers/R/index.rst 100644 → 100755
No changes.
0 docs/wrappers/R/installation.rst 100644 → 100755
No changes.
0 docs/wrappers/index.rst 100644 → 100755
No changes.
0 docs/wrappers/matlab/index.rst 100644 → 100755
No changes.
No changes.
0 optunity/__init__.py 100644 → 100755
No changes.
0 optunity/api.py 100644 → 100755
No changes.
0 optunity/communication.py 100644 → 100755
No changes.
11 optunity/cross_validation.py 100644 → 100755
@@ -51,14 +51,23 @@
import operator as op
import array

try:
import numpy
numpy_available = True
except ImportError:
numpy_available = False


__all__ = ['select', 'random_permutation', 'map_clusters', 'cross_validated',
'generate_folds', 'strata_by_labels']


def select(collection, indices):
"""Selects the subset specified by indices from collection."""
return [collection[i] for i in indices]
if numpy_available and type(collection) is numpy.ndarray:
return collection[indices, :]
else:
return [collection[i] for i in indices]


# https://docs.python.org/2/library/itertools.html#itertools.permutations
0 optunity/functions.py 100644 → 100755
No changes.
0 optunity/parallel.py 100644 → 100755
No changes.
0 optunity/score_functions.py 100644 → 100755
No changes.
0 optunity/solver_registry.py 100644 → 100755
No changes.
0 optunity/solvers.py 100644 → 100755
No changes.
0 optunity/test/__init__.py 100644 → 100755
No changes.
0 optunity/util.py 100644 → 100755
No changes.
0 requirements.txt 100644 → 100755
No changes.
0 setup.py 100644 → 100755
No changes.
0 wrappers/R/.gitignore 100644 → 100755
No changes.
0 wrappers/R/DESCRIPTION 100644 → 100755
No changes.

This file was deleted.

Oops, something went wrong.
0 wrappers/R/NAMESPACE 100644 → 100755
No changes.
0 wrappers/R/R/comm.R 100644 → 100755
No changes.
0 wrappers/R/R/crossvalidation.R 100644 → 100755
No changes.
0 wrappers/R/R/optunity.R 100644 → 100755
No changes.
0 wrappers/R/README.md 100644 → 100755
No changes.
0 wrappers/R/inst/example.R 100644 → 100755
No changes.

This file was deleted.

Oops, something went wrong.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
@@ -1,6 +1,6 @@
function [ in, out, p, socket ] = popen( cmd, env )
%POPEN Spawns a subprocess p via Java API and enables bidirectional
%communication with its stdin, stdout and stderr.
%communication via sockets.

%% create server socket
serverSocket = java.net.ServerSocket(0);
@@ -32,8 +32,4 @@
in = java.io.PrintWriter(socket.getOutputStream(), true);
out = java.io.BufferedReader(java.io.InputStreamReader(socket.getInputStream()));

% stderr = java.io.BufferedReader(java.io.InputStreamReader(p.getErrorStream()));
% stdout = java.io.BufferedReader(java.io.InputStreamReader(p.getInputStream()));
% stdin = java.io.PrintWriter(p.getOutputStream());

end
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
18 wrappers/matlab/example.m 100644 → 100755
@@ -12,17 +12,17 @@

%% optimize using grid-search
grid_solver = optunity.make_solver('grid search','x', -5:0.5:5, 'y', -5:0.5:5);
[grid_solution, grid_details] = optunity.optimize(grid_solver, f);
[grid_solution, grid_details] = optunity.optimize(grid_solver, f, 'parallelize', false);

%% simple API
% maximization
[max_solution, max_details, max_solver] = optunity.maximize(f, 200, 'solver_name', 'random search', 'x', [-5, 5], 'y', [-5, 5]);
[max_solution, max_details, max_solver] = optunity.maximize(f, 200, 'solver_name', 'random search', 'x', [-5, 5], 'y', [-5, 5], 'parallelize', false);
% minimization
[min_solution, min_details, min_solver] = optunity.minimize(f, 200, 'x', [-5, 5], 'y', [-5, 5]);
[min_solution, min_details, min_solver] = optunity.minimize(f, 200, 'x', [-5, 5], 'y', [-5, 5], 'parallelize', false);

%% optimize using random-search
rnd_solver = optunity.make_solver('random search', 'x', [-5, 5], 'y', [-5, 5], 'num_evals', 400);
[rnd_solution, rnd_details] = optunity.optimize(rnd_solver, f);
[rnd_solution, rnd_details] = optunity.optimize(rnd_solver, f, 'parallelize', false);

%% check if the nelder-mead solver is available in the list of solvers
solvers = optunity.manual(); % obtain a list of available solvers
@@ -31,23 +31,23 @@
%% optimize using nelder-mead if it is available
if nm_available
nm_solver = optunity.make_solver('nelder-mead', 'x', 4,'y', -4, 'ftol', 1e-7);
[nm_solution, nm_details] = optunity.optimize(nm_solver, f);
[nm_solution, nm_details] = optunity.optimize(nm_solver, f, 'parallelize', false);
end

%% check if PSO is available
pso_available = any(arrayfun(@(x) strcmp(x, 'particle swarm'), solvers));
if pso_available
pso_solver = optunity.make_solver('particle swarm', 'num_particles', 5, 'num_generations', 30, ...
'x', [-5, 5], 'y', [-5, 5], 'max_speed', 0.03);
[pso_solution, pso_details] = optunity.optimize(pso_solver, f);
[pso_solution, pso_details] = optunity.optimize(pso_solver, f, 'parallelize', false);
end

%% check if CMA-ES is available
cma_available = any(arrayfun(@(x) strcmp(x, 'cma-es'), solvers));
if cma_available
cma_solver = optunity.make_solver('cma-es', 'num_generations', 25, ...
'sigma', 5, 'x', 2, 'y', 4);
[cma_solution, cma_details] = optunity.optimize(cma_solver, f);
[cma_solution, cma_details] = optunity.optimize(cma_solver, f, 'parallelize', false);
end


@@ -122,12 +122,12 @@
s_oo1 = optunity.make_solver('grid search', 'x', -5:0.5:5, 'y', -5:0.5:5);
constraints = struct('ub_o', struct('x', 3));
[constr_solution, constr_details] = s_oo1.optimize(f, ...
'constraints', constraints, 'default', -100);
'constraints', constraints, 'default', -100, 'parallelize', false);

%% grid-search with warm start: already evaluated grid -> warm_nevals = 0
s_oo2 = optunity.make_solver('grid search', 'x', [1, 2], 'y', [1, 2]);
call_log = struct('args',struct('x',[1 1 2 2], 'y', [1 2 1 2]), ...
'values',[1 2 3 4]);
[warm_solution, warm_details] = ...
s_oo2.optimize(f, ...
'call_log', call_log);
'call_log', call_log, 'parallelize', false);

0 comments on commit d527405

Please sign in to comment.
You can’t perform that action at this time.