0

Firstly, I have a basic understanding of linear programming and may not know the correct terminology. I think what I need is a breadth-first solver.

I have two tables of probabilities, which I would like to to use as constraints. My objective function is for all of the parameters to add up to 1.

Using R and lpSolveApi, I find that only some of the parameters I wish to optimise are given any values. I have also tried adding a constraint to say that every parameter should be > 2 or some other value, but this seems wrong.

A minimal example of my code is:

objective_coefficients = c(1,1,1,1,1,1,1,1,1,1,1,1,1) #One for each parameter
lp_model = make.lp(0,13)
lp.control(lp_model, sense="max")
set.objfn(lp_model, objective_coefficients)

#Constraints for probability table 1
add.constraint(lp_model, c(1,0,1,1,1,0,0,0,0,0,0,0,0), "<=", 0.4)
add.constraint(lp_model, c(0,0,0,0,0,0,0,0,0,1,0,0,0), "<=", 0.1)
add.constraint(lp_model, c(0,1,0,0,0,0,0,0,0,0,0,0,0), "<=", 0.2)
add.constraint(lp_model, c(0,0,0,0,0,0,0,0,1,0,0,0,1), "<=", 0.1)
add.constraint(lp_model, c(0,0,0,0,0,1,1,1,0,0,1,1,0), "<=", 0.2)

#Constraints for probability table 2
add.constraint(lp_model, c(1,1,0,0,0,0,0,0,0,0,0,0,0), "<=", 0.2)
add.constraint(lp_model, c(0,0,1,1,1,1,0,0,0,0,0,0,0), "<=", 0.35)
add.constraint(lp_model, c(0,0,0,0,0,0,1,1,0,0,0,0,0), "<=", 0.25)
add.constraint(lp_model, c(0,0,0,0,0,0,0,0,1,1,1,1,0), "<=", 0.17)
add.constraint(lp_model, c(0,0,0,0,0,0,0,0,0,0,0,0,1), "<=", 0.03)

The result is that some parameters have large values attached, and others none at all:

0.05 0.15 0.35 0.00 0.00 0.00 0.20 0.00 0.07 0.10 0.00 0.00 0.03

If I set a minimum for all parameters, I can see it's feasible to have all of them > 0.02.

I have tried:

lp.control(lp_model, basis.crash="mostfeasible", sense="max")
lp.control(lp_model, basis.crash="leastdegenerate", sense="max")
lp.control(lp_model, bb.rule=c("first", "breadthfirst"), sense="max")
lp.control(lp_model, bb.rule=c("gap", "breadthfirst"), sense="max")

These all give the same result.

I think what's happening is the solver is using depthfirst, but I want it to solve breadthfirst, and I can't understand how to do this.

JasTonAChair
  • 1,948
  • 1
  • 19
  • 31
  • Can you elaborate? 1) `I think what I need is a breadth-first solver` If you think you need to tell the solver how to search, you are doing something wrong in 99.9% of all use-cases. 2) `My objective function is for all of the parameters to add up to 1.` this sounds strange. A vector adding up to 1 is usually a *constraint* ("probability simplex") and not an objective. Softening this, it's usually a constraint with a *penalty-variable*. Your objective does fail this completely, even in theory. You are maximizing the sum of all your vars. 3)`bb.rule` sounds like Integer-programming only!Not Lp! – sascha Feb 11 '21 at 12:28
  • 1
    You misunderstand this option. Breadthfirst is purely for performance. You should not expect to get structurally different solutions. – Erwin Kalvelagen Feb 11 '21 at 16:16

0 Answers0