Skip to content

Instantly share code, notes, and snippets.

@youheiakimoto
youheiakimoto / psacmaes.py
Created July 10, 2023 04:47
PSA-CMA-ES: CMA-ES with Population Size Adaptation [Nishida and Akimoto, GECCO 2018]
# coding:utf-8
import sys
import os
from abc import ABCMeta, abstractmethod, abstractproperty
import time
import pprint
import math
from collections import deque
from functools import partial
@youheiakimoto
youheiakimoto / adversarial_cmaes.py
Last active January 17, 2023 04:28
Adversarial-CMA-ES: derivative-free min-max optimization solver using (1+1)-CMA-ES.
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
"""Adversarial-CMA-ES: derivative-free min-max optimization solver using (1+1)-CMA-ES [1]
It is an extention of Adversarial Evolution Strategy [2]
(https://gist.github.com/youheiakimoto/15212dbf46dc546af20af38b0b48ff17)
Reference
---------
@youheiakimoto
youheiakimoto / adversarial_evolution_strategy.py
Last active April 18, 2022 23:44
Saddle Point Optimization with Approximate Minimization Oracle
import numpy as np
from scipy import stats
from scipy.optimize import minimize
"""Saddle Point Optimization with Approximate Minimization Oracle
Adversarial Evolution Strategy : Zero-order saddle point optimizer
Adversarial SLSQP : First-order saddle point optimizer
Its extended version is available at (https://gist.github.com/youheiakimoto/ab51e88c73baf68effd95b750100aad0).
@youheiakimoto
youheiakimoto / adaptive_simulator_switcher.py
Created March 24, 2019 23:01
Adaptive Switching Strategy proposed by Akimoto et al. in GECCO (2019)
import math
import time
import numpy as np
from scipy.stats import kendalltau # tau-b in scipy v1.1.0
class AdaptiveSimulationSwitcher:
"""Adaptive Switching Strategy
In simulation-basedf optimization we often have access to multiple simulators or surrogate models that approximate a computationally expensive or intractable objective function with different trade-offs between the fidelity and computational time. Such a setting is called multi-fidelity optimization.
This is a python code of the strategy proposed in the following reference to adaptively select which simulator to use during optimization of comparison-based evolutionary algorithms. Our adaptive switching strategy works as a wrapper of multiple simulators: optimization algorithms optimize the wrapper function and the adaptive switching strategy selects a simulator inside the wrapper.
@youheiakimoto
youheiakimoto / ddcma.py
Last active April 19, 2023 08:00
dd-CMA: CMA-ES with diagonal decoding
import warnings
from collections import deque
import math
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
class DdCma:
"""dd-CMA: CMA-ES with diagonal decoding [1]
@youheiakimoto
youheiakimoto / iterative_algorithm_interface.py
Last active June 29, 2017 00:59
Iterative Algorithm Interface: support functionality to write and display the internal state of iterative algorithms, such as optimization algorithms.
from __future__ import absolute_import # use from . import
from __future__ import division # use // for integer division
from __future__ import print_function # use print() instead of print
from __future__ import unicode_literals # all the strings are unicode
"""Iterative Algorithm Interface
This module provides the framework for iterative algorithms. It consists of the following classes
ABCIterativeAlgorithm:
The interface of iterative algorithms equipped with logging and plotting functionality.
@youheiakimoto
youheiakimoto / iterative_algorithm_interface.py
Created June 29, 2017 00:55
# Iterative Algorithm Interface
from __future__ import absolute_import # use from . import
from __future__ import division # use // for integer division
from __future__ import print_function # use print() instead of print
from __future__ import unicode_literals # all the strings are unicode
"""Iterative Algorithm Interface
This module provides the framework for iterative algorithms. It consists of the following classes
ABCIterativeAlgorithm:
The interface of iterative algorithms equipped with logging and plotting functionality.
from __future__ import division # use // for integer division
from __future__ import absolute_import # use from . import
from __future__ import print_function # print function
from __future__ import unicode_literals # all the strings are unicode
__author__ = 'Youhei Akimoto'
import warnings
from math import sqrt, exp, log, ceil, floor
import numpy as np
from __future__ import division # use // for integer division
from __future__ import absolute_import # use from . import
from __future__ import print_function # use print("...")
from __future__ import unicode_literals # all the strings are unicode
__author__ = 'Youhei Akimoto'
import numpy as np
from numpy import sqrt, exp, log
@youheiakimoto
youheiakimoto / effeig.f90
Last active June 7, 2017 00:51
Module for Computationally Efficient Eigen Decomposition of Low Rank Matrix
! Module for Computationally Efficient Eigen Decomposition of Low Rank Matrix
!
! ALGORITHM
! ---------
! This module provides functionarities to compute the eigen decomposition of
! a real-valued matrix of the form
! C = alpha * Q * B * Q' + beta * X * X' + gamma * Y * Y',
! where
! Q: m-by-n with orthonormal columns
! B: n-by-n symmetric matrix