non-convex | contained implementation of non-convex optimization | Math library
kandi X-RAY | non-convex Summary
kandi X-RAY | non-convex Summary
Self-contained implementation of non-convex optimization algorithms in python. Steepest Descent, Conjugate Gradient, Newton's Method, Quasi-newton (BFGS), l-BFGS
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Function to minimize the likelihood of a function .
- Run BFGS algorithm
- Calculate the gradient of a function .
- Linear interpolation .
- Steepest descent .
- Perform a Newton iteration .
- Calculate step length .
- Returns whether the gradient of the winde .
- Computes the Wolfe function
- Test if the gold -stein distribution of the gold - Bernstein function .
non-convex Key Features
non-convex Examples and Code Snippets
Community Discussions
Trending Discussions on non-convex
QUESTION
I am actually trying to use the IPOPT Optimisor available on GEKKO in order to optimise a large non-convex and non-linear problem.In order to do that I need to use the Fast Fourrier Transform with scipy.First,lets fix our sample data(for simplicity):
...ANSWER
Answered 2021-Apr-19 at 20:11Gekko requires that expressions are not black box but are able to be expressed with special types of variables (Gekko type) for automatic differentiation and sparsity detection. This may be better solved with a solver such as Scipy.optimize.minimize. Here is a comparison of the two on a simple problem.
Scipy
QUESTION
Update: potential answer added.
I am trying to write a multiobjective pyomo optimization script that optimizes the battery capacity and operational schedule based on minimizing the cost. It is supposed to answer what is the optimal size of a battery that reduces the electricity bill by charging when prices are low and discharging when prices are low, e.g. minimizing grid purchases when prices are high. I have been able to optimize the operational schedule when the capacity of the battery is given. However, I am having issues implementing the capacity optimization. The hourly load profile (electricity consumption) for a building and hourly electricity purchase prices are given (load[i] and price[i]). The cost is a constant with price per kwh for battery capacity.
I am using the ipopt solver.
I have tried different approaches. The first one does provide an optimal schedule and a capacity. However, I am unsure if this is the correct approach for optimal capacity since it is implemented in the same objective function that minimizes cost of battery + cost of purchased electricity - cost of energy discharged from battery.
...ANSWER
Answered 2021-Apr-10 at 13:03I believe I have solved it using gurobi solver. Had to make changes to the demand_rule and add a binary_charge_constraint
QUESTION
I'm trying to solve an optimization question similar to the toy example described below. As noted in the comment, my current implementation with scipy is too slow and doesn't seem to converge. How do I get a decent solution? You can use scipy, mystic, or whatever library as you see fit.
Note that I don't need a global minimum, and the search can stop as soon as loss(X) <= 1
. The real-world objective is mostly written in SQL and thus absurdly slow, so I also want the optimization to terminate when loss
has been evaluated ~200 times. (This is not a hard requirement, you can also terminate after the optimization has been running for say 5 minutes.)
While this question resembles Minimizing non-convex function with linear constraint and bound in mystic, it's definitely not a duplicate. These two questions aren't even treating the same objective.
...ANSWER
Answered 2021-Jan-18 at 02:30The answer is almost the same as the question you referenced... however, there are some constraints that I'd have to think a bit further to demonstrate that. Let me rewrite your code -- just using some shorter names.
QUESTION
I have a non-convex quadratic optimization problem of type
x' * B * x,
where all entries of x are between 0 and 1 and the sum of all entries is identical to 1.
In scipy.optimize I would try to solve this optimization problem via
...ANSWER
Answered 2020-Dec-22 at 14:10Mystic uses lists, by default, so you have to convert to an array in the cost function. There are a lot of other ways to create constraints without using symbolic strings, and in your particular case, there's one that works out of the box. I'd do something like this:
QUESTION
I am new to Gurobi (and solvers in general) and have set up a quadratic non-convex optimization problem by hand in LP file format. The following is a small example that is representative of much larger problems that I will be solving. Gurobi gives "Model is infeasible or unbounded" for this problem. I am setting params.NonConvex = 2 in the model to select the non-convex quadratic solver.
I do understand that having product terms of binary variables is bad form and will be fixing that once I can solve this issue.
...ANSWER
Answered 2020-Nov-25 at 17:21"Model is infeasible or unbounded" is exactly what it sounds like: presolve cannot determine whether the model is infeasible or unbounded. To understand your model better, first set DualReductions=0, then solve it again to determine which case it is:
If it is infeasible, call computeIIS() to solve the IIS, then find the infeasibilities via the IISConstr.
If it is unbounded, then set InfUnbdInfo=1, solve, then retrieve the UnbdRay attribute to find the unbounded ray.
QUESTION
I'm currently writing an y-monotone sweep line algorithm to triangulate non-convex polygons. The first step to achieve this is to make the polygon y-monotone.
Pseudocode of MakeMonotone
from the book "Computation Geometry by Mark de Berg" (https://archive.org/details/computationalgeo00berg):
Now to my question:
In that book and all other websites I found, there is no explanation how to exactly sort the edges in the mentioned "binary search tree T". The only thing mentioned in the referenced book is "The left-to-right order of the leaves of T corresponds to the left-to-right order of the edges". But by what properties/attributes the edges are ordered in that tree? It's also unclear to me, how exactly an edge should be represented in the binary tree (start point? end point? combination of both?).
My most naive approach would be to find out for all edges in T the intersection with the sweep and line and the calculate which of them is closest to the current verex. But given that in every book/university slides, the inner working of T is not explained further, it must be way easier.
The binary search tree should support the following operations:
- insert a new edge
- find edge to the left of the vertex currently on the sweep line
- remove an edge
ANSWER
Answered 2020-Nov-24 at 13:02T
is used to find the edge directly to the left of a query point. So the edges in T
need to be horizontally sorted.
The key query on T
is to find the edge immediately to the left of a point. For any edge in the tree, find the edge's x-position corresponding to the y-coordinate of the point, and compare it to the x-coordinate of the point. (Alternatively, since only left-bounding edges are stored in the tree, you can just directly evaluate the edge's implicit equation on the coordinates of the point and see if the result is negative or positive.)
In that algorithm, an insertion into T is done by performing such a query and then inserting the new edge directly after the query-returned edge.
In contrast to most other usages of binary trees, there's no way to associate a numeric "key" with each node and sort by the key. If you want an immutable function which you can use to sort, you can do something like this:
QUESTION
From the answer to this question here 3 years ago it seems, this is not possible. The Gurobi documentation is not clear ro me:
the model argument state
quadcon (optional)
...
The optional sense string defines the sense of the quadratic constrint. Allowed values are<
,=
or>
. If not present, the default sense is<
. It is stored inmodel$quadcon[[i]]$sense
.
constraints state
Quadratic Constraints
...
Quadratic equality constraints are always non-convex; they will give aGRB_ERROR_QCP_EQUALITY_CONSTRAINT
error with default settings.
[...] If you set theNonConvex
parameter to 2, however, then Gurobi will accept arbitrary quadratic constraints and attempt to solve the resulting model.
But NonConvex
throws an Error 10007: Unknown parameter: 'NonConvex'
in R.
Any help is appreciated, a reproducible example can be found below:
ANSWER
Answered 2020-Mar-24 at 15:08Like mattmilten already said in the comments, it's necessary to upgrade to version 9.0. Then it should work with
QUESTION
I have been training with the following programming exercise: Circles in Polygons. The statement is:
You are the owner of a box making company.
Your company can produce any equal sided polygon box, but plenty of your customers want to transport circular objects in these boxes. Circles are a very common shape in the consumer industry. Tin cans, glasses, tyres and CD's are a few examples of these.
As a result you decide to add this information on your boxes: The largest (diameter) circular object that can fit into a given box.
I have found the following formula:
Taken from: https://www.mathopenref.com/polygonincircle.html
So to calculate the diameter of the largest incircle we have:
sideLength / tan(180/numberOfSides)
I have written the following code:
...ANSWER
Answered 2019-Dec-13 at 21:29double div = Math.toRadians(180/sides);
QUESTION
I have a matrix A
of size nx2
collecting 2D points in Matlab. It is uploaded here (unfortunately, I cannot reproduce it with a simple code).
When I plot them using scatter
I get the following picture, where
The black region is non convex
The boundary of the region is very "unsmooth", the dots of the scatter are quite visible along the boundary.
scatter(A(:,1), A(:,2), 50,'k', 'filled')
xlim([-4 4])
ylim([-4 4])
Question: I would like to know whether there is a way to smooth the boundary of the region. I thought about using patch
, but given that the region is non-convex, I don't know how to get its vertices. I also tried to increase the size of the scatter dots but the result is even worse. Are there some solutions?
ANSWER
Answered 2019-Oct-31 at 17:07You can use boundary
to find the indices of the data point that form the boundary. Next, you will have to select the data points using these indices to get the x
and y
coordinates that enclose your data.
QUESTION
I am using MINLP with NEOS solver, my problem is non-convex and I get this
...ANSWER
Answered 2019-Oct-16 at 13:39The meaning is rather obvious. The functions in your constraints cannot be evaluated at the starting point. If the starting point is zero and you have log(x-0.5)
in the model you may get a message like this.
The fix is to provide better bounds and a better initial point. How to specify this depends on how you created the model and what modeling tools were used.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install non-convex
You can use non-convex like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page