How to obtain iterations and runtime of the Feasibility Pump from the Coin-OR Framework - pyomo

I have programmed an algorithm that finds feasible points for mixed-integer convex optimization problems. Now I wish to compare it with the Feasibility Pump for mixed-integer nonlinear programms on a testbed from the MINLPlib library.
I have access to the BONMIN solver from the Coin OR project, where the Feasibility Pump is also implemented, via Pyomo. Here is a list of possible options for this solver.
My questions are
Are the following options correct to test (plain vanilla) feasibility pump?
opt = SolverFactory('bonmin')
opt.options['bonmin.algorithm'] = 'b-ifp' # Iterated Feasibility Pump as solver
opt.options['bonmin.pump_for_minlp'] = 'yes' # Is this needed?
opt.options['bonmin.solution_limit'] = '1' #For terminating after 1st feasible point
If not, any hint how to do it correctly is appreciated.
How do I access the number of iterations (i.e. pumping cycles) of the feasibility pump? I can see iteration information in the print output but it would be very helpful, if it was stored in some variable.

Pyomo calls Bonmin through the ASL (AMPL solver library) interface. Therefore, whatever options would work for AMPL should be the same ones that are appropriate here.
As for the iteration information, there are various ways of capturing the print output and parsing it to retrieve the desired information. The most straightforward way may be to pipe the output to a file and read it as part of a small post-processing script/function.

Related

GNU Radio QT GUI Sink in C++

I'm trying to implement a simple QTGui sink (in my case a complex freq sink) in GNU Radio using C++.
I am having trouble finding any C++ examples. Can someone point me to a simple example of how this might be implemented?
All the graphical sinks you see are part of GNU Radio's source tree, and that is organized so that the QT stuff is in it's own gr-qtgui submodule; you'll find the public headers in include/, and the C++ implementations in lib/.
Now, "complex frequency sink" doesn't make any sense to me; for a complex signal, frequencies can be negative, but just as the time axis, the frequency axis is simply a part of the real numbers (and hence, not complex). So, I presume you don't want to see a Power Spectral Density (PSD) like QT GUI frequency sink displays, but just the Real and Imaginary part of a DFT; well, that's something best implemented directly as flow graph (doesn't matter if it's Python or C++; I used GRC to quickly get a Python flow graph):
The result is something like (FFT->Time sink with real and imaginary part top, Frequency sink bottom):

Generate sequence of realized Cash flows from an IRS under a given scenario using QuantLib

I am new to quantlib, but I have relatively good understanding of C++. To put my question in some sort of context, I can inform you that I am actually trying to implement the portfolio CVA calculation method proposed by Giovanni Cesari (see link below) for a simple portfolio consisting of one interest rate swap (as a starting point).
I working with the Cheyette (quasi-Gaussian) interest rate model. The model has been implemented as a "new" stochastic process class and the simulated paths stored/generated as a multipath class.
However, as Cesari's method is based on LS-Monte Carlo, I need to write a code that can generate the resulting cash flow sequence from an interest rate swap under each scenario. I do not know if there is some efficient way to do this in quantlib, but I have a feeling that there is. I guess one should be able let the scenarios generated, populate Quantlib quotes which are linked to an instance of the quantlib term structures class. Hopefully I can use this together with the swap class in order to obtain the realized cash flows (basically the floating leg, as the fixed leg is deterministic) from the swap.
Any idea of how this can be done will be highly appreciated!
Link to Cesari's presentation (see page 21 to 26): http://sfi.epfl.ch/files/content/sites/sfi/files/shared/Swissquote%20Conference%202010/Cesari_talk.pdf

Plotting progress in cplex optimization

I would like to able to plot the progress of a MIP solved by cplex. Specifically I would like to plot lower and upper bounds as functions of cpu-time. But copying an pasting from the node log does not seem to be a smartest way of proceeding. Is it possible to access these information and to print them out/to file during the optimization?
I am using the concert technology C++ interface.
You can add a "MIP info callback" using the API routine CPXsetinfocallbackfunc or its analogue in Concert.
(Copying-and-pasting the log it dumps to the terminal is perfectly fine for getting a rough idea of what's going on, but be aware that the results can be highly variable.)
Callbacks are what you are looking for. You can find a nice introduction here:
http://eaton.math.rpi.edu/cplex90html/usrcplex/callbacks.html

Creating custom voice commands (GNU/Linux)

I'm looking for advices, for a personal project.
I'm attempting to create a software for creating customized voice commands. The goal is to allow user/me to record some audio data (2/3 secs) for defining commands/macros. Then, when the user will speak (record the same audio data), the command/macro will be executed.
The software must be able to detect a command in less than 1 second of processing time in a low-cost computer (RaspberryPi, for example).
I already searched in two ways :
- Speech Recognition (CMU-Sphinx, Julius, simon) : There is good open-source solutions, but they often need large database files, and speech recognition is not really what I'm attempting to do. Speech Recognition could consume too much power for a small feature.
- Audio Fingerprinting (Chromaprint -> http://acoustid.org/chromaprint) : It seems to be almost what I'm looking for. The principle is to create fingerprint from raw audio data, then compare fingerprints to determine if they can be identical. However, this kind of software/library seems to be designed for song identification (like famous softwares on smartphones) : I'm trying to configure a good "comparator", but I think I'm going in a bad way.
Do you know some dedicated software or parcel of code doing something similar ?
Any suggestion would be appreciated.
I had a more or less similar project in which I intended to send voice commands to a robot. A speech recognition software is too complicated for such a task. I used FFT implementation in C++ to extract Fourier components of the sampled voice, and then I created a histogram of major frequencies (frequencies at which the target voice command has the highest amplitudes). I tried two approaches:
Comparing the similarities between histogram of the given voice command with those saved in the memory to identify the most probable command.
Using Support Vector Machine (SVM) to train a classifier to distinguish voice commands. I used LibSVM and the results are considerably better than the first approach. However, one problem with SVM method is that you need a rather large data set for training. Another problem is that, when an unknown voice is given, the classifier will output a command anyway (which is obviously a wrong command detection). This can be avoided by the first approach where I had a threshold for similarity measure.
I hope this helps you to implement your own voice activated software.
Song fingerprint is not a good idea for that task because command timings can vary and fingerprint expects exact time match. However its very easy to implement matching with DTW algorithm for time series and features extracted with CMUSphinx library Sphinxbase. See Wikipedia entry about DTW for details.
http://en.wikipedia.org/wiki/Dynamic_time_warping
http://cmusphinx.sourceforge.net/wiki/download

Stata Code for the Expectations Maximization Algorithm

Is there a Stata module or code available for the Expectation Maximization (EM) algorithm? I cannot seem to find any, but I thought it was worth checking in.
My interest is in EM for record linkage. See, for example:
http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1479910/
Usual name: expectation-maximization.
There is not a general command or set of commands providing a framework for applications of EM. Rather, the EM algorithm is used within the code for various commands.