Topic
• 4 replies
• Latest Post - ‏2016-06-06T13:57:01Z by Jacko
prasenjit mandal
21 Posts

Pinned topic Sample Code for a valid inequality generated for mathematical programming

‏2013-10-08T22:29:13Z |

I have developed a valid inequality for my research work.

But, I have no idea how to code it in C++ using cplex-C++ concert technology.

I already  wrote a piece of code in C++ for the original problem.

But I have no idea how to incorporate any generic cut generation to this problem.

If anybody have a sample piece of code, please share it.

• DanielJunglas
243 Posts

Re: Sample Code for a valid inequality generated for mathematical programming

‏2013-10-09T15:43:03Z

Did you look at the many examples in C++ that come with CPLEX?

Do you want to add your valid inequality before calling solve() or do you want to separate it dynamically (depending on the current solution)?

• prasenjit mandal
21 Posts

Re: Sample Code for a valid inequality generated for mathematical programming

‏2013-10-12T21:58:09Z

Did you look at the many examples in C++ that come with CPLEX?

Do you want to add your valid inequality before calling solve() or do you want to separate it dynamically (depending on the current solution)?

How could I find those examples in C++ that come with CPLEX?

Actually, already I developed a code for LP relaxation of my IP problem. That piece of code provides a fractional solution.

Now, I want to introduce a valid inequality to cut those fractional LP solution.

Then, of course, I want to add the valid inequality before calling solve().

Also, I am unaware of how to separate it dynamically! Could you please give me some idea about that.

• DanielJunglas
243 Posts

Re: Sample Code for a valid inequality generated for mathematical programming

‏2013-10-13T16:28:17Z

How could I find those examples in C++ that come with CPLEX?

Actually, already I developed a code for LP relaxation of my IP problem. That piece of code provides a fractional solution.

Now, I want to introduce a valid inequality to cut those fractional LP solution.

Then, of course, I want to add the valid inequality before calling solve().

Also, I am unaware of how to separate it dynamically! Could you please give me some idea about that.

An example that dynamically adds user cuts is cplex/examples/src/cpp/iloadmipex5.cpp. This is also discussed in the user manual here.

You may also want to consult the discussion of the cut callback in the user manual here.

• Jacko
1 Post

Re: Sample Code for a valid inequality generated for mathematical programming

‏2016-06-06T13:57:01Z

How could I find those examples in C++ that come with CPLEX?

Actually, already I developed a code for LP relaxation of my IP problem. That piece of code provides a fractional solution.

Now, I want to introduce a valid inequality to cut those fractional LP solution.

Then, of course, I want to add the valid inequality before calling solve().

Also, I am unaware of how to separate it dynamically! Could you please give me some idea about that.

If you want to dynamically separate your cut you'll have to use a cut callback as you'll be adding the cuts on-the-go at every node of the Branch-and-Bound process. The callbacks are a way of dynamically interacting with node solutions and imposing violated cuts. You could either add them as local or global cuts and the choice of the callback depends on the type of cut you will be adding. Its worth mentioning that callbacks are declared before the .solve() and later (after the .solve()) verified at every node to determine whether one or several cuts are to be added as per your instructions. Notice this is the opposite to adding your valid inequalities a priori!!!!

Note: I considered adding this post, in reply to a two and a half years old question, since it might still be valid to others and this is the type of information I would have liked to have with sommer guidelines on what to search for in the documentation (e.g. callbacks, types of callbacks) rather than trying to decrypt an example or having void answers as pointing to the general User Manual without any actual lead on what to look for.

One is glad to be of service

Y

Updated on 2016-06-06T13:58:51Z at 2016-06-06T13:58:51Z by Jacko