Forum Discussion

FICO's avatar
FICO
Community Manager
2 years ago

How to make a variable be of "continuous type" but only allow (positive) integer values as its solution

Hi, I'm a student and currently stuck on a difficult problem. I've tried for many hours to solve this seemingly simple problem and can't find a solution. It would be cool if you could help without looking at my code because this task is being graded and I don't want you to help with my code itself, so that I don't get an unfair advantage.

My problem is that I have several arrays of decision variables in my code that need to be integers but at the same time I need to know their reduced costs. For that, all these variables need to be of the continuous type but if I don't clarify at least one of them to be an integer, then I receive real values for my solutions, though I also receive their reduced costs.

Is there any way to restrict my (arrays of) decision variables to integer values while receiving their fixed costs?

Thanks a lot for your help in advance,

Paul

4 Replies

  • FICO's avatar
    FICO
    Community Manager

    Hi Paul,

    integer variables cannot have a reduced cost, by their nature. In a way the reduced cost measures the change of objective per unit change of the variable, in other words a derivative. That you cannot have for a discrete variable.

    The simplest case is when your problem is guaranteed to have integer optimal solutions (TU matrix). In that case you can just drop the integrality and obtain the reduced costs. In general, you can always try to drop the integrality and hope the solutions turn out to be integer. If so, your problem is solved.

    Another thing that people commonly do is to solve the integer problem to optimality, then fix the integer variables to their optimal values and then resolve the problem. This way you can at least get reduced costs for the other variables, but still not for the integer ones.

    If you want to get a measure similar to a reduced cost for an integer variable you need to perform sensitivity analysis: change the variable by one in each direction and observe how the optimal objective value is changing.

    Without knowing your problem my assumption is that your task involves some sensitivity analysis, for which you learned to use the reduced cost in the continuous case, but your problem is integer. In this case you'll have to do the sensitivity analysis manually.

    In summary, try to focus on why you think you need the reduced costs and what other ways are there to get the same information without reduced costs.

    I hope this helps,

    Imre Polik

    FICO

  • FICO's avatar
    FICO
    Community Manager

    Dear Mr. Polik,

    Thanks for your answer, it really helps me a lot!

    In other excercises, my algorithms always guaranteed integer solutions when they were needed. I will review my current algorithm once again and see if I can change it to only allow integer values by using better constraints. If that doesn't work, I'll do sensitivity analysis as you mentioned. I'm just getting into xpress and I'm happy about your fast and precise response!

    Kind Regards,

    Paul

  • FICO's avatar
    FICO
    Community Manager

    Dear Ms. Heipcke,

    Thanks for that additional information!

    I will be working on my assignment again later today and this will be helpful, especially having such a detailed example with comments is really nice.

    Sincerely,

    Paul