user643469
user643469

Reputation: 187

Can linprog give an integer value of x's?

I have a linprog code that has x1,x2,x3 and x4 in the objective function.

The results I get give me values in the form:

 x = 
6.6667
0.0420
0 
0

Which in the case I am trying to model doesn't make physical sense because the x's represent the number of units of a specific technology, and therefore for example 0.0420 doesn't in fact exist. Is there anyway to "force" linprog to find the optimum integer value of x?

Thank you

Upvotes: 3

Views: 2378

Answers (2)

Martin
Martin

Reputation: 336

You should consider using mixed-integer programming (you would get one when adding "integer constraints" like "x integer" to the linear program in linprog).

Straight forward I would recommend using Scip as it is "free" or Gams which is a commercial product but offers a free trial version for smaller instances.

A more detailed post on mixed integer programming and the correspondign solvers can be found at [scicomp][3]

[3]: https://scicomp.stackexchange.com/questions/2679/objects-in-buckets-assignment-optimization-problem "scicomp".

Upvotes: 1

Chris A.
Chris A.

Reputation: 6887

That's called integer programming and in general is NP-hard. It's not covered by linprog as it's a completely different and much harder problem.

Here's a related question (but not a duplicate) from Stack Overflow about Integer Programming.

Upvotes: 3

Related Questions