I have a simple model in IBM ILOG CPLEX.

dvar float x in 1..99;
dvar float y in 1..99;
dvar float z in 1..99;
subject to
{
   x + y - z == 41.3;
}

I need random solutions for x, y and z. However, I always get 41.3, 1, 1.

Am I using the wrong tool? Moreover, I need five random solutions. Not only one. How can I accomplish this?

有帮助吗?

解决方案

For a feasibility problem (no objective function) CPLEX will terminate when it finds a feasible solution. There is no way to obtain all extreme points.

What you could try:

  • set an objective function
  • solve and store solution
  • modify the objective function to find a different solution (which has to be done randomly, if you want random solutions)

You would have to use some API to code the logic. This idea is described in more detail here: http://orinanobworld.blogspot.de/2013/02/finding-multiple-extreme-rays.html

But, this is way to complicated for your problem. I'd simply do the following:

  • set z randomly
  • calculate x + y = z + 41.3
  • select a random r between 0 and 1
  • x = (x+y) * r
  • y = (x+y) * (1-r)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top