How to Setup ASL Solvers in Pyomo - pyomo

I am using Pyomo on Windows. I wanted to use nonlinear solvers such as BONMIN and I noticed that they are available using ASL. How can I use ASL?

Solver installation can be tricky on Windows, but you will want to:
install the relevant ASL solver
add its executable to your system path
call it from Pyomo
Each of these steps should have pre-existing documentation.

Related

C++ 14 Eigen load too slow

I use C++ 14 with Eigen and CodeBlocsks IDE.
How should I integrate/install Eigen correct?
First of all, please see this imagine
Is this the right way to append Eigen to my project? In other topics I observed #include<Eigen/Dense> but this won't work for me.
The main problem is that when I run my project (Build and run) it load too slow, too much time to open the console, this problem come from Eigen? From Eigen I use only linear algebra facilities (Matrix, Vector, methods for determinants, QR decomposition) Can I make something to load only this file instead of all Eigen components? or how should I solve the problem about slow loading?
Do not put Eigen code directly in your project. Instead, install it to another location on your system and connect your project to it - for example, if you're using CMake, use find_package(Eigen).
The easiest way to install libraries is to use a library package manager such as vcpkg.

Using tensorflow in C++ on Windows

I know there are ways of using Tensorflow in C++ they even have a documentation for it but I can seem to be able to get the library for it. I've checked the build from source instructions but it seems to builds a pip package rather than a library I can link to my project. I also found a tutorial but when I tried it out I ran out of memory and my computer crashed. My question is, how can I actually get the C++ library to work on my project? I do have these requirements, I have to work on windows with Visual Studio in C++. What I would love to is if I could get a pre-compiled DLL that I could just link but I haven't found such a thing and I'm open to other alternatives.
I can't comment so I am writing this as an answer.
If you don't mind using Keras, you could use the package frugally deep. I haven't seen a library myself either, but I came across frugally deep and it seemed easy to implement. I am currently trying to use it, so I cannot guarantee it will work.
You could check out neural2D from here:
https://github.com/davidrmiller/neural2d
It is a neural network implementation without any dependent libraries (all written from scratch).
I would say that the best option is to use cppflow, an easy wrapper that I created to use Tensorflow from C++ easily.
You won't need to install anything, just download the TF C API, and place it somewhere in your computer. You can take a look to the docs to see how to do it, and how to use the library.
The answer seems to be that it is hard :-(
Try this to start. You can follow the latest instructions for building from source on Windows up to the point of building the pip package. But don't do that - do this/these instead:
bazel -config=opt //tensorflow:tensorflow.dll
bazel -config=opt //tensorflow:tensorflow.lib
bazel -config=opt tensorflow:install_headers
That much seems to work fine. The problems really start when you try to use Any of the header files - you will probably get compilation errors, at least with TF version >= 2.0. I have tried:
Build the label_image example (instructions in the readme.md file)
It builds and runs fine on Windows, meaning all the headers and source are there somewhere
Try incorporating that source into Windows console executable: runs into compiler errors due to conflicts with std::min & std::max, probably due to Windows SDK.
Include c_api.h in a Windows console application: won't compile.
Include TF-Lite header files: won't compile.
There is little point investing the lengthy compile time in the first two bazel commands if you can't get the headers to compile :-(
You may have time to invest in resolving these errors; I don't. At this stage Tensorflow lacks sufficient support for Windows C++ to rely on it, particularly in a commercial setting. I suggest exploring these options instead:
If TF-Lite is an option, watch this
Windows ML/Direct ML (requires conversion of TF models to ONNX format)
CPPFlow
Frugally Deep
Keras2CPP
UPDATE: having explored the list above, I eventually found the following worked best in my context (real-time continuous item recognition):
convert models to ONNX format (use tf2onnx or keras2onnx
use Microsoft's ONNX runtime
Even though Microsoft recommends using DirectML where milliseconds matter, the performance of ONNX runtime using DirectML as an execution provider means we can run a 224x224 RGB image through our Intel GPU in around 20ms, which is quick enough for us. But it was still hard finding our way to this answer

Integrating functions from other source codes in SCIP

I'm a master student and I'm currently using SCIP for my thesis. The main implementation task of my thesis is to integrate a meta-heuristic already coded in C++ and ready to be used in the SCIP branch-and-bound process to enhance the solution process of my problem.
How can I call the functions from the meta-heuristic files?
I'm not sure if this information can be useful but I'm using Matlab to load my data and then to compile and run SCIP in Visual Studio using MEX functions. I have already set all the necessary headers in SCIP and Matlab.
I suggest you extend your SCIP by a primal heuristic plugin. General instructions about adding a primal heuristic can be found here.
A C++ Example in source code may be the well-documented TSP example.
In there, you can include and use your existing meta-heuristic code package.

Solving MINLP with PYOMO and BONMIN

Is it possible to solve a mixed-interger-non-linear-problem (MINLP) with the help of PYOMO and the BONMIN solver?
Yes. BONMIN can solve convex MINLP problems and Pyomo can interface with BONMIN through the ASL.
Compile BONMIN / CoinBinary with ASL support (before running configure, be sure to go into ThirdParty/ASL and run get.ASL) and then make sure hat the resulting bonmin executable is available through your PATH. Pyomo can then use it by either specifying --solver=bonmin At the pyomo command line or with SolverFactory('bonmin') within a script.
Do remember that BONMIN is a local solver and that if you hand it a nonconvex problem there are no guarantees as to what you will get out.

Calling GLPK from C++ while using Rcpp

I am developing part of my R package in C++ using Rcpp and I need to use a Linear Programming Solver.
After comparing some benchmarks using the solvers implementation into R (lpSolveAPI, Rglpk, Rsymphony and so on) I have decided to use GLPK. However, I have found no good way to use it in my C++ code developing under Windows.
Simply put, there is no simple way to just install GLPK and call it using something like
#include <glpk.h>
and I have found no implementations in R packages so that I can use a shortcut using Rcpp attributes like
// [[Rcpp::depends(package)]]
Any ideas?
I'm sure you are aware of the Rglpk package and its predecessor glpk. Often in these cases, it's helpful to stand on the shoulders of those that came before us. Having said that, we gleam from the package sources the following:
The source of Rglpk requires a pre-existing system install, does not enable linking, and is specific to Linux.
The source of glpk installs the library headers directly in R and it seems to also provide direct wrappers into the library.
Given the current implementations and your requirements, you would basically have to create an RcppGLPK package. This is primarily because no one really has a solution for what you need. I would highly suggest that you look at how RcppGSL is structured.