Git Product home page Git Product logo

zoopt's People

Contributors

alexliuyuren avatar eyounx avatar hzhupku avatar nlnjnj avatar nogod1995 avatar paper2019 avatar xionghuichen avatar zewenli98 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zoopt's Issues

Infeasible solution of "High-dimensionality sequential random embedding "

Hello, I encountered the following problem while implementing Zoopt. Please help!
When I try to use SRE, the solved solution from Zoopt is outside of the constrained region of my problem (the unit box (0,1]**dim_size). Some elements in the solution is larger than 1 and some others are negative. In the paper cited in the documentation (https://doi.org/10.1613/jair.4806), it is said that if it is outside the feasible region it should be automatically projected back to this feasible region. Can you please verify?

This is my code where my objective function is to find the smallest eigenvalue of a matrix whose entries are computed via the variables:
_dim_size = 400

Constraints on the variables >0 and <=1

dim = Dimension(dim_size, [[1e-10, 1]] * dim_size, [True] * dim_size )
objective = Objective(smallest_eigen, dim)

low_dim = 100
uniform = list([1/2]*(low_dim+1))
initial = [uniform]
budget =5000
par = Parameter(budget=budget, init_samples = initial, precision = 1e-8, intermediate_result=True, high_dim_handling=True, reducedim=True, num_sre=5, low_dimension=Dimension(low_dim, [[1e-10, 1]] * low_dim, [True] * low_dim))

sol = Opt.min(objective, par)
optimal = sol.get_x()
optval= - sol.get_value()_

zoopt.Objective constraint error

According to sparse_regression the constraint function should return a positive value if the constraint is met and a negative value if the constraint is violated (at least that is how I understand it).

When this is employed the following error is recorded

zoopt\lib\site-packages\zoopt\algos\paretoopt\paretoopt.pyc in opt(self, objective, parameter)
78 continue
79 else:
---> 80 if (fitness[i][0] < offSpringFit[0] and fitness[i][1] >= offSpringFit[1]) or
81 (fitness[i][0] <= offSpringFit[0] and fitness[i][1] > offSpringFit[1]):
82 hasBetter = True

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

RuntimeWarning: invalid value encountered in greater

I got a RuntimeWarning when run the optimizer

lib\site-packages\zoopt-0.3.0-py3.7.egg\zoopt\solution.py:84: RuntimeWarning: invalid value encountered in greater

zoopt\solution.py:84
if sol_value != nan and self.__value != nan:

the sol_value is nan and the self.__value is nan too
but the expression return True in python 3.7

while math.isnan(sol_value) and math.isnan(self.__value) return True in python 3.7

init_samples

Hello,
Can you please specify how to initialize the sample? I follow the Documents but cannot succeed.
Here is a part of my Python code, where do I get it wrong? Thank you very much.

objective = Objective(smallest_eigen, dim)

uniform = list([1]*E)
initial = [Solution(x=uniform)] # Initial as a Uniform Distribution
par = Parameter(budget=5000, intermediate_result=True,init_samples = initial)

sol = Opt.min(objective, par)
print(sol.get_x(), sol.get_value())

The error is

File "C:\Users\qvu\Anaconda\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)

File "C:\Users\qvu\Anaconda\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/qvu/Google Drive/2018 Works/8. AAAI submission/Implementation/Black_box_Explore.py", line 100, in
sol = Opt.min(objective, par)

File "C:\Users\qvu\Anaconda\lib\site-packages\zoopt\opt.py", line 50, in min
result = optimizer.opt(objective, parameter)

File "C:\Users\qvu\Anaconda\lib\site-packages\zoopt\algos\opt_algorithms\racos\racos_optimization.py", line 54, in opt
objective, parameter, strategy, ub)

File "C:\Users\qvu\Anaconda\lib\site-packages\zoopt\algos\opt_algorithms\racos\sracos.py", line 44, in opt
self.init_attribute()

File "C:\Users\qvu\Anaconda\lib\site-packages\zoopt\algos\opt_algorithms\racos\racos_common.py", line 66, in init_attribute
self._objective.eval(x)

File "C:\Users\qvu\Anaconda\lib\site-packages\zoopt\objective.py", line 83, in eval
val = self.__func(solution)

File "C:/Users/qvu/Google Drive/2018 Works/8. AAAI submission/Implementation/Black_box_Explore.py", line 81, in smallest_eigen
H =update_H(w)

File "C:/Users/qvu/Google Drive/2018 Works/8. AAAI submission/Implementation/Black_box_Explore.py", line 61, in update_H
H[i,j] = H[i,j]+ w[edges.index((i,k))]*H[k,j]

TypeError: 'Solution' object does not support indexing

Increasing the budget throws error in discrete search space

Hi, I implemented the following hypothetical minimization objective. The first part of the objective function is just a l1-norm while the second part ensures that the sum of first 3 entries of x equals to 1.

def fn(solution):
    x = solution.get_x() 
    x1 = [0,3,1,0,0]
    val = sum([abs(v-x1[i]) for i,v in enumerate(x)])+ ((np.sum([i for i in x[0:3]])-1.0)**2)
    return val

dim = 5
dimobj = Dimension(dim, regs=[[0,5]]*dim, tys=[False]*dim)
obj = Objective(fn, dimobj)
param = Parameter(budget=50)
solution = Opt.min(obj, param)
print(solution.get_x(), solution.get_value())

The above simple program works fine when the budget is less than 50. When I make it more than 50, it throws the following error:

ValueError: empty range for randrange() (0,0, 0)

Further, this problem occurs only when the search space is discrete.

Any help much appreciated. Thanks!

sparse_regression error

When running the sparse_regression example I get the following error:
AttributeError: 'module' object has no attribute 'ArffDecoder'

wrong implementation of Ackley's function

How I found the bug:
I ran an example to test, I changed the func code as

def myfunc(x):
	b=np.array(x)
	y = -20 * np.exp(-0.2 * np.sqrt(((b - 0.2)*(b - 0.2)).mean())) 
	- np.exp((np.cos(2 * math.pi * (b - 0.2))).mean()) + math.e + 20
	return y

and rerun the example in README. It got a different but better result than the original one, and then I found why original code is wrong:

T.dot return a scalar but not a list, so its mean is itself. 

Good luck.

Increasing the budget causes stucking without a progress in discrete space

I tried discrete optimization with Ackley function from example, with dim equals to 2

def ackley(solution):
    x = solution.get_x()
    print(x)
    bias = 0.2
    value = -20 * np.exp(-0.2 * np.sqrt(sum([(i - bias) * (i - bias) for i in x]) / len(x))) - \
            np.exp(sum([np.cos(2.0*np.pi*(i-bias)) for i in x]) / len(x)) + 20.0 + np.e
    return value

with budget=20*dim works fine

dim = 2  # dimension
obj = Objective(ackley, Dimension(dim, [[-10, 10]] * dim, [False] * dim, [True] * dim))
# perform optimization
solution = ExpOpt.min(obj, Parameter(budget=20 * dim))
# print result
solution

this prints

[10, -10]
[-10, -10]
[10, 10]
[-10, 10]
[3, 10]
[-8, 10]
[-7, 10]
[3, -5]
[4, -5]
[3, -2]
[3, 4]
[-4, -2]
[-2, -2]
[-3, -2]
[-1, -2]
[-1, 8]
[-1, 4]
[1, -2]
[7, -2]
[1, 10]
[1, -4]
[1, 1]
[1, -5]
[3, 1]
[1, 0]
[7, 0]
[2, 0]
[4, 0]
[7, 0]
[4, 0]
[-4, 0]
[1, 8]
[4, 0]
[-9, 0]
[-2, 0]
[1, 2]
[1, 8]
[4, 0]
[-6, 0]
[5, 0]
[zoopt] solved solution is:
[zoopt] x: [1, 0]
[zoopt] value: 3.5577131909328554
[zoopt] Best 1 result: 3.5577131909328554 +- 0.0

but with budget=30*dim, I get this and nothing more

[-10, 10]
[10, 10]
[10, -10]
[-10, -10]

Warm start with evaluated samples?

If I already have a set {X,y} of evaluated samples, can I warm start the optimization without having the optimizer re-evaluate all of these points?

Optimization get stuck + "poss" fails + additional arguments

Hi all,
1 - sometimes optimization just get stuck at some point and does not end (with dimension size < 50 - it's always the case). Don't know, maybe it is doing something, but after 10 minutes I just gave up (

2 - Moreover, 'poss' optimization fails with an error "AttributeError: 'NoneType' object has no attribute 'print_solution'" at different places.

3 - is there a way to pass additional arguments to objective function?

Best regards,
Oleg

Warm start with an X0?

Hello,

Just wondering if it's possible to set an initial X0 as the starting point.

Thanks

关于跑示例代码报错

您好,请教一个问题,我对您的zooPT这个无梯度优化非常感兴趣,最近尝试在玩一玩并且想解决一些实际问题,但是我跑了一下示例代码,报错了,报错信息如下:
Traceback (most recent call last):
File "D:\pythonProject\main.py", line 28, in
Traceback (most recent call last):
File "", line 1, in
solution = Opt.min(obj, Parameter(budget=100 * dim_size, parallel=True, server_num=3))
File "D:\pythonProject\venv\lib\site-packages\zoopt\opt.py", line 50, in min
result = optimizer.opt(objective, parameter)
ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'Parameter.init..'

代码是这个:
import numpy as np
from zoopt import Dimension, ValueType, Dimension2, Objective, Parameter, Opt, ExpOpt
def ackley(solution):
x = solution.get_x()
bias = 0.2
value = -20 * np.exp(-0.2 * np.sqrt(sum([(i - bias) * (i - bias) for i in x]) / len(x))) -
np.exp(sum([np.cos(2.0np.pi(i-bias)) for i in x]) / len(x)) + 20.0 + np.e
return value

Press the green button in the gutter to run the script.

if name == 'main':
dim_size = 100 # dimension size
dim = Dimension(dim_size, [[-1, 1]] * dim_size, [True] * dim_size)
# dim = Dimension2([(ValueType.CONTINUOUS, [-1, 1], 1e-6)]*dim_size)
obj = Objective(ackley, dim)
# perform optimization
solution = Opt.min(obj, Parameter(budget=100 * dim_size))
# print the solution
print(solution.get_x(), solution.get_value())
# parallel optimization for time-consuming tasks
solution = Opt.min(obj, Parameter(budget=100 * dim_size, parallel=True, server_num=3))
import matplotlib.pyplot as plt

plt.plot(obj.get_history_bestsofar())
plt.savefig('figure.png')
solution_list = ExpOpt.min(obj, Parameter(budget=100 * dim_size), repeat=3,
                           plot=True, plot_file="progress.png")
for solution in solution_list:
    print(solution.get_x(), solution.get_value())

请问您知道这是怎么回事嘛 谢谢

pip installation

I tried to install using pip. Seems like the pareoopt file is not included in the installation as I keep getting this error:

from paretoopt import ParetoOpt
ModuleNotFoundError: No module named 'paretoopt'

I used the following command: pip install zoopt on Windows 10.

Would ZOOpt support PyTorch?

Hi guys,
I am a learner of PyTorch. So I am wondering whether ZOOpt would support PyTorch.

Any answer and guide will be appreciated!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.