Topic
• 6 replies
• Latest Post - ‏2013-11-29T14:56:06Z by DanielJunglas
MACHANI M.
5 Posts

# Pinned topic Problem with piecewise function

‏2013-10-21T16:37:54Z |

Hi,

I have problem with using piecewise fucntion in OPL langage. In fact, i use it to represent water flows in function of teh existing volume within an evacuator. I have three evacuators,and a 4-piece function for each evacuator (4 points to represent the graph). The obejctive of the problem i modelize is to opttimize the flows of water towards a hydroelectricty production  plant. When i run the model for a small planning horizon (100 days), i obtain the optimal solution within about minutes. But when i use a 365 plannign horizon, Cplex is not able to give me the optimal solution and i get a memory-out-of order error within 5 minutes (i need absolutely teh optimal solution)

Is there an additional setup that i should consider to optimize the use of picewise fucntion?

Best regards!

• DanielJunglas
83 Posts

#### Re: Problem with piecewise function

‏2013-11-29T14:56:06Z

Even if i set the parameters you gave to me, it does not solve the problem, as the SOS variables are still used. When i set the nodefiledend parmater to 3, th problem is solved, but it takes more than 20 minutes using piecewise function (using 577 SOS vaiables for a 2 year planning horizon with weekly periods). However, the same problem is solved within 10 seconds when i manually construct a piecewise fucntion using bianry variables.

As i said previsously, the problem is with the piecewise function itself in OPL . the SOS variables used become inefficient when the problem size is big.

I think what you observe is sort of expected. OPL provides a simple way to specify piecewise linear functions and then automatically translates them into something that CPLEX can handle. This is done in a generic way that always works.

It is well possible that for certain models (yours) there are better ways to model the piecewise linear functions. So your best option seems to be to go with your own formulation of PWLs.

• MACHANI M.
5 Posts

#### Re: Problem with piecewise function

‏2013-11-11T20:12:34Z

In fact, it seems that for small problems, the piecewise function is resloved using MIP variables. However, SOS variables are used to resolve the problem fotr larger sizes!

I wonder if there is a switch to implement to use MIP formulation even for large scale problems when using piecewise!

Thanks!

• DanielJunglas
83 Posts

#### Re: Problem with piecewise function

‏2013-11-13T12:37:08Z

Could you show us the engine log for both of the solves?

Also, how many breakpoints do your PWLs have in the small and in the big model?

Updated on 2013-11-13T12:41:10Z at 2013-11-13T12:41:10Z by DanielJunglas
• MACHANI M.
5 Posts

#### Re: Problem with piecewise function

‏2013-11-14T15:17:10Z

Could you show us the engine log for both of the solves?

Also, how many breakpoints do your PWLs have in the small and in the big model?

Here  attached the two engine logs for a small problem (50 periods) and a large problem (577 periods).

The piecewise function has 4 breakpoints for both models.

In fact, for every time period, a SOS variable is created when using a piecewise function. Then, i have 50 SOS variables for my small problem and 577 SOS variables for teh large one, which CPlex has not been able to solve!

Tahnks!

#### Attachments

• DanielJunglas
83 Posts

#### Re: Problem with piecewise function

‏2013-11-24T10:34:10Z

Here  attached the two engine logs for a small problem (50 periods) and a large problem (577 periods).

The piecewise function has 4 breakpoints for both models.

In fact, for every time period, a SOS variable is created when using a piecewise function. Then, i have 50 SOS variables for my small problem and 577 SOS variables for teh large one, which CPlex has not been able to solve!

Tahnks!

OK, so there are no unexpected things in the model itself. The only issue is that CPLEX runs out of memory.

From the log file it looks like your tree is getting very big quickly and that is the reason for running out of memory. To work around this you should use node files, see this section in the user manual that explains how to do that.

In short, you will have to set several parameters:

To change those parameters you will need to add a "Settings" (.ops) file to your project and change the parameters there.

• MACHANI M.
5 Posts

#### Re: Problem with piecewise function

‏2013-11-28T19:31:34Z

OK, so there are no unexpected things in the model itself. The only issue is that CPLEX runs out of memory.

From the log file it looks like your tree is getting very big quickly and that is the reason for running out of memory. To work around this you should use node files, see this section in the user manual that explains how to do that.

In short, you will have to set several parameters:

To change those parameters you will need to add a "Settings" (.ops) file to your project and change the parameters there.

Even if i set the parameters you gave to me, it does not solve the problem, as the SOS variables are still used. When i set the nodefiledend parmater to 3, th problem is solved, but it takes more than 20 minutes using piecewise function (using 577 SOS vaiables for a 2 year planning horizon with weekly periods). However, the same problem is solved within 10 seconds when i manually construct a piecewise fucntion using bianry variables.

As i said previsously, the problem is with the piecewise function itself in OPL . the SOS variables used become inefficient when the problem size is big.

• DanielJunglas
83 Posts

#### Re: Problem with piecewise function

‏2013-11-29T14:56:06Z

Even if i set the parameters you gave to me, it does not solve the problem, as the SOS variables are still used. When i set the nodefiledend parmater to 3, th problem is solved, but it takes more than 20 minutes using piecewise function (using 577 SOS vaiables for a 2 year planning horizon with weekly periods). However, the same problem is solved within 10 seconds when i manually construct a piecewise fucntion using bianry variables.

As i said previsously, the problem is with the piecewise function itself in OPL . the SOS variables used become inefficient when the problem size is big.