Error with JuMP and Ipopt - julia

I am trying to use JumP and Ipopt under Julia v0.7.0. When I try to construct a model:
julia> m = Model(solver=IpoptSolver())
I get the following error message:
Feasibility problem with:
* 0 linear constraints
* 0 variables
Solver is Error showing value of type Model:
ERROR: BoundsError: attempt to access 1-element Array{SubString{String},1} at index [2]
I am using the following versions of the packages:
Ipopt v0.4.0
JuMP v0.18.2
Any ideas? Thanks!

JuMP v0.18.2 does not support Julia v0.7, see this post.
If you want to use JuMP with Julia v0.7 or Julia v1.0 you should just the in-development version of JuMP that will be released as JuMP v0.19 when it is ready.
EDIT: JuMP v0.18.3 now supports Julia v1.0.

Related

Cannot not find "calc.RL.0" function within "mixstock" package

I am trying to run through a mixed stock analysis in RStudio based on the walkthrough provided by Bolker (https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&doi=043730a02b148396ebd54b2f62e8f6364714b1b2), using the 'mixstock' package and the example 'lahanas98raw' dataset within. However, I am receiving a warning that the 'calc.RL.0' function cannot be found whilst trying to carry out Raftery and Lewis convergence diagnostics (p.14 of Bolker's walkthrough). I am wondering whether one of the packages has not installed properly (i.e., either 'mixstock' or 'coda'), or whether there is another package I can use to run this diagnostic instead.
When I initially tried to install the 'mixstock' package, the following warning came up:
'Warning in install.packages : package ‘mixstock’ is not available for this version of R.'
I tried installing the version of R (2.14.1) described as the 'current version of R' on page 2 of Bolker's walkthrough, but when I then tried to switch to this version of R in RStudio via the options menu, it says that this version of R is not compatible with RStudio. To work around this, I downloaded the 'mixstock' package (version 0.9.5.1) from the CRAN archive (https://cran.r-project.org/src/contrib/Archive/mixstock/) and uploaded it to RStudio this way instead.
This seemed to have worked, as I successfully ran through a significant amount of the code, but a new error arose when I tried to run Raftery and Lewis convergence diagnostics (p.14). When I try to run calc.RL.0(mydata), I receive the following error:
'Error in calc.RL.0(mydata) : could not find function "calc.RL.0"'
However, when I click on 'mixstock' in the package window, everything seems fine and the 'calc.RL.0' function appears, alongside several other 'calc' functions (e.g. 'calc.GR', 'calc.mult.GR', 'calc.mult.RL') that can all be found and run fine. The 'calc.RL.0' function relies on the 'raftery.diag' function within the 'coda' package, so I have also made sure that is installed and called. I have tried a bunch of other methods but nothing seems to be working.
Here is some of my code leading up to the warning message:
## Calculate confidence intervals - i.e., bootstrapping - and plot them
mydata.umlboot = genboot(mydata,"uml")
confint(mydata.umlboot)
plot(mydata.umlboot, ylim=c(0,1))
## Carry out Markov Chain Monte Carlo (MCMC) estimations and plot them
mydata.mcmc = tmcmc(mydata)
mydata.mcmc
confint(mydata.mcmc)
plot(mydata.mcmc, ylim=c(0,1))
## Check that the Markov chains have converged = run Raftery and Lewis diagnostics
library(mixstock)
library(coda)
calc.RL.0(mydata)
'Error in calc.RL.0(mydata) : could not find function "calc.RL.0"'
Could this be something to do with the way the 'mixstock' package was initially installed, or is it likely to be another issue? Is there another way to run Raftery and Lewis diagnostics and still get the outputs I need (diagnostics for the last chain evaluated; the history of how long each suggested chain was)? Any help would be much appreciated - thanks in advance!
The most reliable way to install mixstock, if you have development tools installed on your computer (compilers etc.), is remotes::install_github("bbolker/mixstock") (I don't think I've changed anything/fixed any bugs since the archived version, but if I did the changes would be reflected on GitHub.)
It looks like I forgot to export that function, so
mixstock:::calc.RL.0(mydata)
should work (this is something I can/should fix). Note that the Gelman-Rubin diagnostic (calc.GR(), which is properly exported) is more reliable than Raftery-Lewis anyway ...

How to determine Gurobi or solver version in JuMP

In Python, you can do:
print(gurobipy.gurobi.version())
What is the equivalent for Julia and JuMP?
I tried
using Gurobi
Gurobi.version()
Without success. I am not trying to get Gurobi.jl package version which can be obtained with ] status Gurobi.
There are three integer variables for this you need to combine them to get the full version number:
julia> println("Grurobi version: $(Gurobi.GRB_VERSION_MAJOR).$(Gurobi.GRB_VERSION_MINOR).$(Gurobi.GRB_VERSION_TECHNICAL)")
Grurobi version: 9.5.0
#przemyslaw-szufel's answer is mostly correct, but it can be wrong with the minor version. The constants he refers to are actually the ones we copy from the gurobi.h file, not from the Gurobi library itself, so you might get v9.5.0 returned when the actual library is v9.5.1.
You can get the exact version using:
julia> using Gurobi
julia> const MOI = Gurobi.MOI
MathOptInterface
julia> v = MOI.get(Gurobi.Optimizer(), MOI.SolverVersion())
"9.1.0"
julia> VersionNumber(v)
v"9.1.0"
this is mostly solver-independent, although not all packages support MOI.SolverVersion.

kerasR giving error

I am trying to use kerasR for deep learning in R. I am trying to reproduce the examples in the package. Trying the following code produces error:
library(kerasR)
mod <- Sequential()
The error is:
Error in Sequential() : attempt to apply non-function
I'd suggest to look at this issue in KerasR Github repo:
https://github.com/statsmaths/kerasR/issues/1
Basically you should check where is located your version of python and then use reticulate::use_python("PATH_TO_PYTHON") to tell the system where to find Python.
Watch Out!
You can load just one Python interpreter per session and the use_python() function doesn't warn you if there already is a loaded interpreter.
Moreover if you run py_config() it automatically loads the first interpreter that he finds (which, in your case, seems to be the wrong one!), thus you'd better call reticulate::use_python("PATH_TO_PYTHON") before anything else.

Julia: pcaeig(X) yields "UndefVarError: fliplr not defined"

I am trying to get the eigenvector to do pca (principal component analysis). The package, DimensionalityReduction.jl offers a command that should do that very thing, pcaeig(X) where X is some matrix. My code is as follows
using DataFrames
using DimensionalityReduction
data = readtable("Midterm Data.csv")
T=size(data)[1]
n=size(data)[2]
erates = convert(Array,data[1:T,2:n])
eigvec = pcaeig(erates)
I do apologize that the formatting is bad, I don't quite remember how to put the code in a quote. Anyways, when I try to run this code, I get the following error: "UndefVarError: fliplr not defined". Now, to my knowledge, fliplr is a command used to flip a matrix (not a variable). It is also saying that the error is happening in the code for the package (not my code). Does this mean that I am out of luck and cannot use this package until it gets patched? If so, does anyone else know another method to get the eigenvector for pca?
As it says in the README of DimensionalityReduction, the package is deprecated:
The DimensionalityReduction package is deprecated. It is superseded by a new package MultivariateStats.
The package does not work on recent versions of Julia and will not be updated to do so in the future. Use MultivariateStats instead.

Julia studio write() error

I am getting the weirdest error in using the write()function:
julia> write(0.1)
�8
julia>
������?
These are just the commands I'm writing in the console, as you can see. What could be going wrong?
Note: I'm using Julia Studio 0.4.4
From the documentation:
write(stream, x): Write the canonical binary representation of a value to the given stream.
I suspect that you want to use print rather than write.

Resources