Question

The lp problem can be found at Portfolio Optimization Problem. The problem is based on cvar optimization in guy yollins presentation R Tools for Portfolio Optimization.

When I read the lp file in R and execute it, optimal solution is found. Whereas when I do the same via glpsol, it says "LP HAS NO PRIMAL FEASIBLE SOLUTION". I'm using glpsol as pulp internally uses glpsol for solving lp when solver argument is given as pulp.GLPK().

Steps to run the lp in R:

library("Rglpk")
problem <- Rglpk_read_file("path/to/problem.lp", "CPLEX_LP")
solution <- Rglpk_solve_LP(problem$objective, problem$constraints[[1]], problem$constraints[[2]], problem$constraints[[3]], problem$bounds, problem$types, problem$maximum, control=list("verbose" = TRUE))
print(solution$status)
print(solution$solution)

Steps to run the lp in glpsol:

glpsol --cpxlp "path/to/problem.lp" -o output.sol

Any idea why? I tried seeing the code for Rglpk_solve_lp function in R. It seems to be calling the glpk c library's glp_simplex function. I'm guessing glpsol also calls glp_simplex internally.

Environment details:
OS: Ubuntu 12.04
R version: 3.02
Rglpk version: 0.5-1(GLPK version 4.52 is shipped with the source package)
glpsol version: 4.52

Was it helpful?

Solution

Adding options --nopresol, --noscale, --std to glpsol command gave me the same results as Rglpk_solve_lp.

glpsol --cpxlp ~/Downloads/PortfolioOptimization_minReturns_0.190000.lp -o output.sol --nopresol --noscale --std

I had to look into glpsol's code and compare it with Rglpk package's code to figure this out.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top