Comments (4)
Hi @ragonneau, thank you for your fast and detailed answer, you solved all the doubts I had and some additional I did not know I had.
Did you hack the source code of COBYQA? The info "cobyqa terminated: ExitStatus.RADIUS_SUCCESS" should be private and not displayed to the user. I want to confirm that this is not a bug of COBYQA. The variable RADIUS_SUCCESS is internal, and it is not because its value is returned that the optimization procedure necessarily terminated successfully. If you look at the structure returned by minimize, it contains a field success whose value is False.
Yes sorry, I added a print statement on termination, its not a bug.
The bound constraints will always be satisfied, and your general constraint is 0 or 1. Therefore, the constraint violation can be either 0 or 1 but not anything else. Hence, any value in would work for feasibility_tol. The default value being np.sqrt(np.finfo(float).eps), you could leave it as is.
Ok, thanks!
Your problem is a very difficult problem due to two things: one of your constraints is unquantifiable, and your objective function is undefined outside some region. Is it possible to define even when the constraints are not satisfied?
It is possible, but evauating a solution takes 8h of GPU computation, and feasibility checks take less than a second, hence we would rather not evaluate unfeasible solutions. I spoke to the engineer and we will be able to change the constraint to quantifiable, so that should make it much easier to solve. Thanks for the warning.
The bound constraints are assumed to be unrelaxable, and for this reason, COBYQA modifies your initial guess because some properties must be verified by the initial trust region. I tried to run the code below.
Ok! That seems to be working, thanks!
Your problem does not have any theoretical solution. We expect a solver to give an objective function value arbitrarily close to zero. In this sense, COBYQA "converged" numerically.
Understood, we are not looking for the global optimum anyway, just a good enough solution.
The constraint violation is not zero, because the point returned is slightly outside the bound constraints.
Understood.
It takes some time to obtain this result, and this is expected. What is the dimension of your actual problem? COBYQA is designed to solve derivative-free optimization problems of reasonable size (at most a few hundred).
We are still working on the problem, but it will be less than a hundred for sure.
If your bound constraints are unrelaxable, you can try to reduce the value of options["radius_init"]. Let me know if this is the case I can provide more support on this.
Thanks for the tip!
Again, thanks for the detailed answer, you really helped me :) I will close the issue.
from cobyqa.
Hi @EtorArza,
Great to hear. If you use COBYQA in the future to solve your actual problem, I would be glad to have some feedback 😃
Cheers,
Tom.
from cobyqa.
Hi @EtorArza,
First, thanks for using COBYQA; your application sounds very interesting! I have several questions/comments; I list them below.
- Did you hack the source code of COBYQA? The info "cobyqa terminated: ExitStatus.RADIUS_SUCCESS" should be private and not displayed to the user. I want to confirm that this is not a bug of COBYQA. The variable
RADIUS_SUCCESS
is internal, and it is not because its value is returned that the optimization procedure necessarily terminated successfully. If you look at the structure returned byminimize
, it contains a fieldsuccess
whose value isFalse
. - The bound constraints will always be satisfied, and your general constraint is 0 or 1. Therefore, the constraint violation can be either 0 or 1 but not anything else. Hence, any value in
$[0, 1)$ would work forfeasibility_tol
. The default value beingnp.sqrt(np.finfo(float).eps)
, you could leave it as is. - Your problem is a very difficult problem due to two things: one of your constraints is unquantifiable, and your objective function is undefined outside some region. Is it possible to define
$f$ even when the constraints are not satisfied? - The bound constraints are assumed to be unrelaxable, and for this reason, COBYQA modifies your initial guess because some properties must be verified by the initial trust region. I tried to run the code below.
import numpy as np
import numpy.typing
import os
from cobyqa import minimize
from scipy.optimize import LinearConstraint, NonlinearConstraint
def f(x: numpy.typing.ArrayLike):
# If solution not feasible, return np.nan
if not np.all(constraint_check(x)):
return np.nan
return np.linalg.norm(x)
def constraint_check(x: numpy.typing.ArrayLike):
if x[0] > x[1] > x[2] > x[3] > x[4]:
return 1.0
return 0.0
def random_feasible_sol(dim, ):
feasible = False
seed = 2
rs = np.random.RandomState(seed)
while not feasible:
x0 = rs.random(dim)
feasible = constraint_check(x0)
return x0
problem_dim = 50
x0 = random_feasible_sol(problem_dim) # get a random feasible solution to initialize the algorithm.
# bounds = Bounds([0.0 for _ in range(problem_dim)], [1.0 for _ in range(problem_dim)])
constraints = [
LinearConstraint(np.eye(problem_dim), np.zeros(problem_dim), np.ones(problem_dim)),
NonlinearConstraint(lambda x: [constraint_check(x)], 1.0, 1.0),
]
options = {
"disp": True,
}
minimize(f, x0, constraints=constraints, options=options)
This is mathematically equivalent, but since bounds are supplied as linear constraints, COBYQA may visit points outside of the bounds. It gives the result below on my computer.
The lower bound for the trust-region radius has been reached.
Number of function evaluations: 3077.
Number of iterations: 1655.
Least value of f: 0.0006808081667906753.
Maximum constraint violation: 2.0122649008455027e-23.
Corresponding point: [ 3.543e-04 3.156e-04 ... 5.080e-05 1.661e-04].
Several things to note about this result:
- Your problem does not have any theoretical solution. We expect a solver to give an objective function value arbitrarily close to zero. In this sense, COBYQA "converged" numerically.
- The constraint violation is not zero, because the point returned is slightly outside the bound constraints.
- It takes some time to obtain this result, and this is expected. What is the dimension of your actual problem? COBYQA is designed to solve derivative-free optimization problems of reasonable size (at most a few hundred).
If your bound constraints are unrelaxable, you can try to reduce the value of options["radius_init"]
. Let me know if this is the case I can provide more support on this.
Cheers,
Tom.
from cobyqa.
Thanks Tom, I will let you know if I have feedback :)
from cobyqa.
Related Issues (20)
- "trust-region ratio" is not a proper name HOT 1
- How would COBYQA behave on feasiblity problems? HOT 2
- What is the initial value of the penalty parameter?
- COBYQA does not accept linear constraints? HOT 1
- The signature of COBYQA HOT 3
- Tough test, stress test, recursive test, and parallel test
- Improve the website of COBYQA
- The logo of COBYQA should be explainable
- Misc
- Investigate the strategy for switching derivative-free PSB updated Hessian to least Frobenius norm Hessian
- Investigate the strategy of maintaining and updating XBASE
- The definitions of `reduct` and `violation` are problematic
- `linalg` is not a proper name
- How does COBYQA compare with SQPDFO and Py-BOBYQA?
- Check the definition of knew after a trust-region step HOT 3
- Infrastructure (finish this before making any other movements) HOT 1
- Make the expriments reproducible HOT 1
- Change this repository to an organization
- Make a backup of each comparison including the results and information about how to reproduce them
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cobyqa.