non-convex | contained implementation of non-convex optimization | Math library

 by   yrlu Python Version: Current License: No License

kandi X-RAY | non-convex Summary

kandi X-RAY | non-convex Summary

non-convex is a Python library typically used in Utilities, Math, Example Codes applications. non-convex has no bugs, it has no vulnerabilities and it has high support. However non-convex build file is not available. You can download it from GitHub.

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

            kandi-support Support

              non-convex has a highly active ecosystem.
              It has 54 star(s) with 18 fork(s). There are 3 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 2 open issues and 0 have been closed. On average issues are closed in 804 days. There are no pull requests.
              It has a positive sentiment in the developer community.
              The latest version of non-convex is current.

            kandi-Quality Quality

              non-convex has 0 bugs and 0 code smells.

            kandi-Security Security

              non-convex has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              non-convex code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              non-convex does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              non-convex releases are not available. You will need to build from source code and install.
              non-convex has no build file. You will be need to create the build yourself to build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              non-convex saves you 77 person hours of effort in developing the same functionality from scratch.
              It has 199 lines of code, 14 functions and 1 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed non-convex and discovered the below as its top functions. This is intended to give you an instant insight into non-convex implemented functionality, and help decide if they suit your requirements.
            • 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 .
            Get all kandi verified functions for this library.

            non-convex Key Features

            No Key Features are available at this moment for non-convex.

            non-convex Examples and Code Snippets

            No Code Snippets are available at this moment for non-convex.

            Community Discussions

            QUESTION

            Using GEKKO with Fast Fourier Transform
            Asked 2021-Apr-19 at 20:11

            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:11

            Gekko 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

            Source https://stackoverflow.com/questions/67137596

            QUESTION

            Optimizing battery capacity AND operational schedule with pyomo and pao. Attempts at two-Stage Stochastic Optimization
            Asked 2021-Apr-10 at 13:25

            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:03

            I believe I have solved it using gurobi solver. Had to make changes to the demand_rule and add a binary_charge_constraint

            Source https://stackoverflow.com/questions/67002113

            QUESTION

            Non-convex optimization with linear constraints
            Asked 2021-Jan-18 at 02:30

            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:30

            The 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.

            Source https://stackoverflow.com/questions/65556625

            QUESTION

            Using mystic to solve a parameter-dependent optimization problem
            Asked 2020-Dec-22 at 14:10

            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:10

            Mystic 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:

            Source https://stackoverflow.com/questions/65400290

            QUESTION

            "Model is infeasible or unbounded" in Gurobi -- however, this seems to be incorrect
            Asked 2020-Nov-25 at 23:06

            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.

            Source https://stackoverflow.com/questions/64997329

            QUESTION

            Sweep Line Polygon triangulation: How to find edge left to current vertex?
            Asked 2020-Nov-24 at 13:02

            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:02

            T 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:

            Source https://stackoverflow.com/questions/64908672

            QUESTION

            Can Gurobi (>= 8.1) solve ILP with quadratic equality constraint within R-interface?
            Asked 2020-Mar-24 at 15:08

            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 in model$quadcon[[i]]$sense.

            constraints state

            Quadratic Constraints
            ...
            Quadratic equality constraints are always non-convex; they will give a GRB_ERROR_QCP_EQUALITY_CONSTRAINT error with default settings.
            [...] If you set the NonConvex 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:08

            Like mattmilten already said in the comments, it's necessary to upgrade to version 9.0. Then it should work with

            Source https://stackoverflow.com/questions/60814722

            QUESTION

            How could we calculate the diameter of the largest circle inside a regular polygon?
            Asked 2019-Dec-13 at 21:29

            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:29
            double div = Math.toRadians(180/sides);
            

            Source https://stackoverflow.com/questions/59329871

            QUESTION

            How to "smooth" boundary of scatter in Matlab
            Asked 2019-Oct-31 at 17:07

            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:07

            You 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.

            Source https://stackoverflow.com/questions/58639619

            QUESTION

            Cannot evaluate constraint(s) at starting point
            Asked 2019-Oct-16 at 13:39

            I am using MINLP with NEOS solver, my problem is non-convex and I get this

            ...

            ANSWER

            Answered 2019-Oct-16 at 13:39

            The 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.

            Source https://stackoverflow.com/questions/58414375

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install non-convex

            You can download it from GitHub.
            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

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/yrlu/non-convex.git

          • CLI

            gh repo clone yrlu/non-convex

          • sshUrl

            git@github.com:yrlu/non-convex.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link