Open source alternative to MATLAB's fmincon function? [closed]
Is there an open-source alternative to MATLAB's
fmincon function for constrained linear optimization? I'm rewriting a MATLAB program to use Python / NumPy / SciPy and this is the only function I haven't found an equivalent to. A NumPy-based solution would be ideal, but any language will do.
Asked by: Vivian127 | Posted: 01-10-2021
Is your problem convex? Linear? Non-linear? I agree that SciPy.optimize will probably do the job, but fmincon is a sort of bazooka for solving optimization problems, and you'll be better off if you can confine it to one of the categories below (in increasing level of difficulty to solve efficiently)
- Linear Program (LP)
- Quadratic Program (QP)
- Convex Quadratically-Constrained Quadratic Program (QCQP)
- Second Order Cone Program (SOCP)
- Semidefinite Program (SDP)
- Non-Linear Convex Problem
- Non-Convex Problem
There are also combinatoric problems such as Mixed-Integer Linear Programs (MILP), but you didn't mention any sort of integrality constraints, suffice to say that they fall into a different class of problems.
The CVXOpt package will be of great use to you if your problem is convex.
If your problem is not convex, you need to choose between finding a local solution or the global solution. Many convex solvers 'sort of' work in a non-convex domain. Finding a good approximation to the global solution would require some form Simulated Annealing or Genetic Algorithm. Finding the global solution will require an enumeration of all local solutions or a combinatorial strategy such as Branch and Bound.Answered by: Thomas619 | Posted: 02-11-2021
Python optimization software:
OpenOpt http://openopt.org (this one is numpy-based as you wish, with automatic differentiation by FuncDesigner)
The open source Python package,SciPy, has quite a large set of optimization routines including some for multivariable problems with constraints (which is what fmincon does I believe). Once you have SciPy installed type the following at the Python command prompt
The resulting document is extensive and includes the following which I believe might be of use to you.
Answered by: Melanie685 | Posted: 02-11-2021
Constrained Optimizers (multivariate) fmin_l_bfgs_b -- Zhu, Byrd, and Nocedal's L-BFGS-B constrained optimizer (if you use this please quote their papers -- see help) fmin_tnc -- Truncated Newton Code originally written by Stephen Nash and adapted to C by Jean-Sebastien Roy. fmin_cobyla -- Constrained Optimization BY Linear Approximation
GNU Octave is another MATLAB clone that might have what you need.Answered by: Kelvin776 | Posted: 02-11-2021
For numerical optimization in Python you may take a look at OpenOpt solvers:
I don't know if it's in there, but there's a python distribution called Enthought that might have what you're looking for. It was designed specifically for data analysis has over 60 additional libraries.Answered by: Samantha962 | Posted: 02-11-2021
Have a look at http://www.aemdesign.com/downloadfsqp.htm.
There you will find C code which provides the same functionality as
fmincon. (However, using a different algorithm. You can read the manual if you are interested in the details.)
It's open source but not under GPL.Answered by: Oliver988 | Posted: 02-11-2021
There is a program called SciLab that is a MATLAB clone.
I haven't used it at all, but it is open source and might have the function you are looking for.Answered by: Dainton344 | Posted: 02-11-2021
Octave in the latest version implements an equivalent to the Matlab fmincon function into the optimization package.
Scilab has an implementation of fmincon (using IPOpt) which is now regularly updated:
For large-scale optimization it outperforms Matlab's fmincon.Answered by: Max955 | Posted: 02-11-2021
numpy - matlab's "hold on" alternative for python
I have some datasets named group and I want to plot them on a empty figure. I mean when new dataset read by computer, my program will add it to figure. for groups in seconds_list: group = f[(groups)][:] i_data = group['real'] q_data = group['imag'] i_data = np.array(i_data, dtype=float64) q_data = np.array(q_data, dtype=float64) # 10.log(10.(I^2+Q^2)+1) then rotate array w/ np....
Python alternative to MATLAB's semilogy
What is the Python alternative for MATLAB's semilogy plotting function?
user interface - WPF Alternative for python
Is there any alternative for WPF (windows presentation foundation) in python? http://msdn.microsoft.com/en-us/library/aa970268.aspx#Programming_with_WPF
language features - is there an alternative way of calling next on python generators?
I have a generator and I would like to know if I can use it without having to worry about StopIteration , and I would like to use it without the for item in generator . I would like to use it with a while statement for example ( or other constructs ). How could I do that ?
security - Is there an alternative to rexec for Python sandboxing?
Implementing a 'sandbox' environment in Python used to be done with the rexec module (http://docs.python.org/library/rexec.html). Unfortunately, it has been deprecated/removed due to some security vulnerabilities. Is there an alternative? My goal is to have Python code execute semi-trusted Python scripts. In a perfect world, calls to any fu...
Python and MySQL: is there an alternative to MySQLdb?
Is there a module written purely in Python that will allow a script to communicate with a MySQL database? I've already tried MySQLdb without success. It requires too much: GCC, zlib, and openssl. I do not have access to these tools; even if I did, I don't want to waste time getting them to work together. I'm looking for tools that will make my work easier. Can someone point me in the direction of a MySQL Python mod...
Looking for a better alternative to PIL for basic image file I/O and processing in Python?
Closed. This question does not meet Stack Overflow guid...
how to program functions with alternative return value signatures in python? (next() for alternative iterators)
e.g. so that these would both work - is it possible? (val,VAL2) = func(args) val = func(args) Where val is not a tuple For example I'd like these to work for my custom object something for item in something: do_item(item) #where again item - is not a tuple for (item,key) in something: do_more(key,item)
python - Django - alternative to subclassing User?
I am using the standard User model (django.contrib.auth) which comes with Django. I have made some of my own models in a Django application and created a relationship between like this: from django.db import models from django.contrib.auth.models import User class GroupMembership(models.Model): user = models.ForeignKey(User, null = True, blank = True, related_name='memberships') #other irrelevant f...
python - Alternative XML parser for ElementTree to ease UTF-8 woes?
I am parsing some XML with the elementtree.parse() function. It works, except for some utf-8 characters(single byte character above 128). I see that the default parser is XMLTreeBuilder which is based on expat. Is there an alternative parser that I can use that may be less strict and allow utf-8 characters? This is the error I'm getting with the default parser: ExpatError: not well-formed ...
python - Alternative to the `match = re.match(); if match: ...` idiom?
If you want to check if something matches a regex, if so, print the first group, you do.. import re match = re.match("(\d+)g", "123g") if match is not None: print match.group(1) This is completely pedantic, but the intermediate match variable is a bit annoying.. Languages like Perl do this by creating new $1..$9 variables for match groups,...
python - Alternative to cvs2svn for performing cvs to svn migration
I am trying to perform a migration from cvs to svn on my our new XServe server which is running OS X Server. There is a known conflict between the cvs2svn and dbm libraries that come pre-installed with OS X. The error is: ERROR: cvs2svn uses the anydbm package, which depends on lower level dbm libraries. Your system has dbm, with which cvs2svn is known to have problems. To use cvs2svn, you must ins...