Modeling the Round (Nearest Integer) functionWhen to use indicator constraints versus big-M approaches in solving (mixed-)integer programsModeling floor function exactlyIs deciding the presence of mixed-integer points in the relative interior of a polyhedron in NP?How to linearize min function as a constraint?Expressing a chain of boolean ORs using ILPRepresenting an indicator function: binary variables and “indicator constraints”Decoding a Deep Neural Network as an Analytical Expression for Optimization PurposeValid Inequalities and Strong InequalitiesIn the context of LASSO regression, how to introduce a constraint for max number of selected betas?

What is an idiom, phrase or expression for situation such as "throw a pigeon among cats"

What could an alternative human-powered transportation method look like?

Length-terminated sequences

What can players do while waiting for a troll to regenerate?

At what point can you walk out of a restaurant if they make you wait to pay the bill?

How does Berkeley justify existence of other minds?

Fiducial placement

How to handle a player wanting to use the (UA) Remote Access spell on an android player character?

Siginificant speed difference of Integrate between 9.0 and 12.0

Why does hairspray work as an adhesive for ABS?

Is This Constraint Convex?

How can I get something for my shares in a company I used to be employed by?

Why do the Romance languages use definite articles, when Latin doesn't?

Why is Robin Hood French in Shrek?

How can different packages have identical source code?

Functions where the sum of its partial derivatives is zero

Conditions for minima in calculus of variations

How to answer to the "We do not want to create any precedent" argument in salary negotiation?

What's the origin of the trope that dragons used to be common but aren't any more?

A word/phrase means "a small amount" (of a color)

Program to print the multiple occurrence of numbers in a list

How are hillsides farmed?

What would you do? Different results than what is reported

What can I use for input conversion instead of scanf?



Modeling the Round (Nearest Integer) function


When to use indicator constraints versus big-M approaches in solving (mixed-)integer programsModeling floor function exactlyIs deciding the presence of mixed-integer points in the relative interior of a polyhedron in NP?How to linearize min function as a constraint?Expressing a chain of boolean ORs using ILPRepresenting an indicator function: binary variables and “indicator constraints”Decoding a Deep Neural Network as an Analytical Expression for Optimization PurposeValid Inequalities and Strong InequalitiesIn the context of LASSO regression, how to introduce a constraint for max number of selected betas?













8














$begingroup$


Modeling various non-differentiable functions is quite common knowledge including $operatornameabs$, $min$ and $max$ functions. How would one go about modeling the nearest integer function, say in an inequality constraint $lfloorxrceil leq C$?










share|improve this question









New contributor



Josh Allen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$










  • 1




    $begingroup$
    Do you have a specific rounding rule in mind for .5 cases? The Wikipedia page on 'Nearest integer function' (en.wikipedia.org/wiki/Nearest_integer_function) says "On most computer implementations, the selected rule is to round half-integers to the nearest even integer"
    $endgroup$
    – Dipayan Banerjee
    Oct 12 at 20:51










  • $begingroup$
    @DipayanBanerjee Yes, let's assume the nearest even integer rule for this example.
    $endgroup$
    – Josh Allen
    Oct 12 at 20:55











  • $begingroup$
    Pardon the beginner's question of a passer-by, what does "modeling" mean in this context? Is it simply the process of expressing some transformation as an algebraic function?
    $endgroup$
    – Violet Giraffe
    Oct 13 at 19:24
















8














$begingroup$


Modeling various non-differentiable functions is quite common knowledge including $operatornameabs$, $min$ and $max$ functions. How would one go about modeling the nearest integer function, say in an inequality constraint $lfloorxrceil leq C$?










share|improve this question









New contributor



Josh Allen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$










  • 1




    $begingroup$
    Do you have a specific rounding rule in mind for .5 cases? The Wikipedia page on 'Nearest integer function' (en.wikipedia.org/wiki/Nearest_integer_function) says "On most computer implementations, the selected rule is to round half-integers to the nearest even integer"
    $endgroup$
    – Dipayan Banerjee
    Oct 12 at 20:51










  • $begingroup$
    @DipayanBanerjee Yes, let's assume the nearest even integer rule for this example.
    $endgroup$
    – Josh Allen
    Oct 12 at 20:55











  • $begingroup$
    Pardon the beginner's question of a passer-by, what does "modeling" mean in this context? Is it simply the process of expressing some transformation as an algebraic function?
    $endgroup$
    – Violet Giraffe
    Oct 13 at 19:24














8












8








8


1



$begingroup$


Modeling various non-differentiable functions is quite common knowledge including $operatornameabs$, $min$ and $max$ functions. How would one go about modeling the nearest integer function, say in an inequality constraint $lfloorxrceil leq C$?










share|improve this question









New contributor



Josh Allen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




Modeling various non-differentiable functions is quite common knowledge including $operatornameabs$, $min$ and $max$ functions. How would one go about modeling the nearest integer function, say in an inequality constraint $lfloorxrceil leq C$?







mixed-integer-programming modeling






share|improve this question









New contributor



Josh Allen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor



Josh Allen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question








edited Oct 13 at 8:02









TheSimpliFire

2,6997 silver badges39 bronze badges




2,6997 silver badges39 bronze badges






New contributor



Josh Allen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked Oct 12 at 20:38









Josh AllenJosh Allen

2897 bronze badges




2897 bronze badges




New contributor



Josh Allen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




Josh Allen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • 1




    $begingroup$
    Do you have a specific rounding rule in mind for .5 cases? The Wikipedia page on 'Nearest integer function' (en.wikipedia.org/wiki/Nearest_integer_function) says "On most computer implementations, the selected rule is to round half-integers to the nearest even integer"
    $endgroup$
    – Dipayan Banerjee
    Oct 12 at 20:51










  • $begingroup$
    @DipayanBanerjee Yes, let's assume the nearest even integer rule for this example.
    $endgroup$
    – Josh Allen
    Oct 12 at 20:55











  • $begingroup$
    Pardon the beginner's question of a passer-by, what does "modeling" mean in this context? Is it simply the process of expressing some transformation as an algebraic function?
    $endgroup$
    – Violet Giraffe
    Oct 13 at 19:24













  • 1




    $begingroup$
    Do you have a specific rounding rule in mind for .5 cases? The Wikipedia page on 'Nearest integer function' (en.wikipedia.org/wiki/Nearest_integer_function) says "On most computer implementations, the selected rule is to round half-integers to the nearest even integer"
    $endgroup$
    – Dipayan Banerjee
    Oct 12 at 20:51










  • $begingroup$
    @DipayanBanerjee Yes, let's assume the nearest even integer rule for this example.
    $endgroup$
    – Josh Allen
    Oct 12 at 20:55











  • $begingroup$
    Pardon the beginner's question of a passer-by, what does "modeling" mean in this context? Is it simply the process of expressing some transformation as an algebraic function?
    $endgroup$
    – Violet Giraffe
    Oct 13 at 19:24








1




1




$begingroup$
Do you have a specific rounding rule in mind for .5 cases? The Wikipedia page on 'Nearest integer function' (en.wikipedia.org/wiki/Nearest_integer_function) says "On most computer implementations, the selected rule is to round half-integers to the nearest even integer"
$endgroup$
– Dipayan Banerjee
Oct 12 at 20:51




$begingroup$
Do you have a specific rounding rule in mind for .5 cases? The Wikipedia page on 'Nearest integer function' (en.wikipedia.org/wiki/Nearest_integer_function) says "On most computer implementations, the selected rule is to round half-integers to the nearest even integer"
$endgroup$
– Dipayan Banerjee
Oct 12 at 20:51












$begingroup$
@DipayanBanerjee Yes, let's assume the nearest even integer rule for this example.
$endgroup$
– Josh Allen
Oct 12 at 20:55





$begingroup$
@DipayanBanerjee Yes, let's assume the nearest even integer rule for this example.
$endgroup$
– Josh Allen
Oct 12 at 20:55













$begingroup$
Pardon the beginner's question of a passer-by, what does "modeling" mean in this context? Is it simply the process of expressing some transformation as an algebraic function?
$endgroup$
– Violet Giraffe
Oct 13 at 19:24





$begingroup$
Pardon the beginner's question of a passer-by, what does "modeling" mean in this context? Is it simply the process of expressing some transformation as an algebraic function?
$endgroup$
– Violet Giraffe
Oct 13 at 19:24











4 Answers
4






active

oldest

votes


















6
















$begingroup$

This is a hack of Robert Schwarz's answer, to accommodate the "round .5 to even" rule. We introduce integer variable $y$ and binary variable $z$, along with the constraints $$2y+z le x le 2y + z + 1$$ and $$x + z - 0.5 le C.$$ If $x$ is noninteger, the first constraint finds the nearest integers on either side. If the floor of $x$ is even (meaning a fraction of one half would round down), $z=0$ and we require that $x - 0.5 le C$. If the floor of $x$ is odd (meaning a fraction of one half would round up), $z=1$ and we require that $x + 0.5 le C$.



There is an ambiguity when $x$ is integer. For instance, if $x = 3$, both $(y,z)=(1,1)$ and $(y,z)=(1,0)$ satisfy the constraint. Fortunately, the solver will bail us out: if it "wants" to have $x=3$ be feasible (and if $C=3$), it will choose $(y,z)=(1,0)$, so that $x=3=C$ satisfies the second constraint.






share|improve this answer










$endgroup$






















    5
















    $begingroup$

    Assuming finite bounds on $x$, this could be modeled with disjunctions on the many cases to which $x$ can be rounded.



    For example, if $x in [ 0, 2 ]$, we would have:
    $$
    begincases
    x le 0.5, & 0 le C \
    0.5 le x le 1.5, & 1 le C \
    1.5 le x , & 2 le C
    endcases
    $$



    The disjunction itself could be modeled with auxiliary binary variables and big-$M$ constraints, for example.



    Note that rounding in this context has some ambiguity, as a value of $0.5$ may be rounded either to $0$ or $1$, because strict inequalities can usually not be enforced by MIP solvers.






    share|improve this answer










    $endgroup$






















      2
















      $begingroup$

      As an alternative solution, I propose to add an auxiliary integral variable $y in mathbbZ$ that should play the role of the rounded $x$.



      For your example of the inequality, I would add:
      $$
      beginarrayrll
      y &le& C \
      x - 0.5&le& y
      endarray
      $$






      share|improve this answer










      $endgroup$










      • 3




        $begingroup$
        This is close, but trips over the "round-to-even" rule. We can assume that $C$ is integer. Suppose that $C=3$. $x=3.5$, $y=3$ satisfies both inequalities, but $leftlceil xrightrfloor =4$.
        $endgroup$
        – prubin
        Oct 12 at 22:35


















      1
















      $begingroup$

      Assuming that the value $C + 0.5$ is valid, you could model this by simply adding the constraint



      $$x leq C + 0.5$$



      Otherwise, you define a constant say $epsilon = 10^-7$ and do



      $$x leq C + 0.5 - epsilon$$






      share|improve this answer












      $endgroup$
















        Your Answer








        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "700"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );







        Josh Allen is a new contributor. Be nice, and check out our Code of Conduct.









        draft saved

        draft discarded
















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2for.stackexchange.com%2fquestions%2f2790%2fmodeling-the-round-nearest-integer-function%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown


























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        6
















        $begingroup$

        This is a hack of Robert Schwarz's answer, to accommodate the "round .5 to even" rule. We introduce integer variable $y$ and binary variable $z$, along with the constraints $$2y+z le x le 2y + z + 1$$ and $$x + z - 0.5 le C.$$ If $x$ is noninteger, the first constraint finds the nearest integers on either side. If the floor of $x$ is even (meaning a fraction of one half would round down), $z=0$ and we require that $x - 0.5 le C$. If the floor of $x$ is odd (meaning a fraction of one half would round up), $z=1$ and we require that $x + 0.5 le C$.



        There is an ambiguity when $x$ is integer. For instance, if $x = 3$, both $(y,z)=(1,1)$ and $(y,z)=(1,0)$ satisfy the constraint. Fortunately, the solver will bail us out: if it "wants" to have $x=3$ be feasible (and if $C=3$), it will choose $(y,z)=(1,0)$, so that $x=3=C$ satisfies the second constraint.






        share|improve this answer










        $endgroup$



















          6
















          $begingroup$

          This is a hack of Robert Schwarz's answer, to accommodate the "round .5 to even" rule. We introduce integer variable $y$ and binary variable $z$, along with the constraints $$2y+z le x le 2y + z + 1$$ and $$x + z - 0.5 le C.$$ If $x$ is noninteger, the first constraint finds the nearest integers on either side. If the floor of $x$ is even (meaning a fraction of one half would round down), $z=0$ and we require that $x - 0.5 le C$. If the floor of $x$ is odd (meaning a fraction of one half would round up), $z=1$ and we require that $x + 0.5 le C$.



          There is an ambiguity when $x$ is integer. For instance, if $x = 3$, both $(y,z)=(1,1)$ and $(y,z)=(1,0)$ satisfy the constraint. Fortunately, the solver will bail us out: if it "wants" to have $x=3$ be feasible (and if $C=3$), it will choose $(y,z)=(1,0)$, so that $x=3=C$ satisfies the second constraint.






          share|improve this answer










          $endgroup$

















            6














            6










            6







            $begingroup$

            This is a hack of Robert Schwarz's answer, to accommodate the "round .5 to even" rule. We introduce integer variable $y$ and binary variable $z$, along with the constraints $$2y+z le x le 2y + z + 1$$ and $$x + z - 0.5 le C.$$ If $x$ is noninteger, the first constraint finds the nearest integers on either side. If the floor of $x$ is even (meaning a fraction of one half would round down), $z=0$ and we require that $x - 0.5 le C$. If the floor of $x$ is odd (meaning a fraction of one half would round up), $z=1$ and we require that $x + 0.5 le C$.



            There is an ambiguity when $x$ is integer. For instance, if $x = 3$, both $(y,z)=(1,1)$ and $(y,z)=(1,0)$ satisfy the constraint. Fortunately, the solver will bail us out: if it "wants" to have $x=3$ be feasible (and if $C=3$), it will choose $(y,z)=(1,0)$, so that $x=3=C$ satisfies the second constraint.






            share|improve this answer










            $endgroup$



            This is a hack of Robert Schwarz's answer, to accommodate the "round .5 to even" rule. We introduce integer variable $y$ and binary variable $z$, along with the constraints $$2y+z le x le 2y + z + 1$$ and $$x + z - 0.5 le C.$$ If $x$ is noninteger, the first constraint finds the nearest integers on either side. If the floor of $x$ is even (meaning a fraction of one half would round down), $z=0$ and we require that $x - 0.5 le C$. If the floor of $x$ is odd (meaning a fraction of one half would round up), $z=1$ and we require that $x + 0.5 le C$.



            There is an ambiguity when $x$ is integer. For instance, if $x = 3$, both $(y,z)=(1,1)$ and $(y,z)=(1,0)$ satisfy the constraint. Fortunately, the solver will bail us out: if it "wants" to have $x=3$ be feasible (and if $C=3$), it will choose $(y,z)=(1,0)$, so that $x=3=C$ satisfies the second constraint.







            share|improve this answer













            share|improve this answer




            share|improve this answer










            answered Oct 12 at 23:06









            prubinprubin

            5,5119 silver badges34 bronze badges




            5,5119 silver badges34 bronze badges
























                5
















                $begingroup$

                Assuming finite bounds on $x$, this could be modeled with disjunctions on the many cases to which $x$ can be rounded.



                For example, if $x in [ 0, 2 ]$, we would have:
                $$
                begincases
                x le 0.5, & 0 le C \
                0.5 le x le 1.5, & 1 le C \
                1.5 le x , & 2 le C
                endcases
                $$



                The disjunction itself could be modeled with auxiliary binary variables and big-$M$ constraints, for example.



                Note that rounding in this context has some ambiguity, as a value of $0.5$ may be rounded either to $0$ or $1$, because strict inequalities can usually not be enforced by MIP solvers.






                share|improve this answer










                $endgroup$



















                  5
















                  $begingroup$

                  Assuming finite bounds on $x$, this could be modeled with disjunctions on the many cases to which $x$ can be rounded.



                  For example, if $x in [ 0, 2 ]$, we would have:
                  $$
                  begincases
                  x le 0.5, & 0 le C \
                  0.5 le x le 1.5, & 1 le C \
                  1.5 le x , & 2 le C
                  endcases
                  $$



                  The disjunction itself could be modeled with auxiliary binary variables and big-$M$ constraints, for example.



                  Note that rounding in this context has some ambiguity, as a value of $0.5$ may be rounded either to $0$ or $1$, because strict inequalities can usually not be enforced by MIP solvers.






                  share|improve this answer










                  $endgroup$

















                    5














                    5










                    5







                    $begingroup$

                    Assuming finite bounds on $x$, this could be modeled with disjunctions on the many cases to which $x$ can be rounded.



                    For example, if $x in [ 0, 2 ]$, we would have:
                    $$
                    begincases
                    x le 0.5, & 0 le C \
                    0.5 le x le 1.5, & 1 le C \
                    1.5 le x , & 2 le C
                    endcases
                    $$



                    The disjunction itself could be modeled with auxiliary binary variables and big-$M$ constraints, for example.



                    Note that rounding in this context has some ambiguity, as a value of $0.5$ may be rounded either to $0$ or $1$, because strict inequalities can usually not be enforced by MIP solvers.






                    share|improve this answer










                    $endgroup$



                    Assuming finite bounds on $x$, this could be modeled with disjunctions on the many cases to which $x$ can be rounded.



                    For example, if $x in [ 0, 2 ]$, we would have:
                    $$
                    begincases
                    x le 0.5, & 0 le C \
                    0.5 le x le 1.5, & 1 le C \
                    1.5 le x , & 2 le C
                    endcases
                    $$



                    The disjunction itself could be modeled with auxiliary binary variables and big-$M$ constraints, for example.



                    Note that rounding in this context has some ambiguity, as a value of $0.5$ may be rounded either to $0$ or $1$, because strict inequalities can usually not be enforced by MIP solvers.







                    share|improve this answer













                    share|improve this answer




                    share|improve this answer










                    answered Oct 12 at 20:55









                    Robert SchwarzRobert Schwarz

                    1,1753 silver badges15 bronze badges




                    1,1753 silver badges15 bronze badges
























                        2
















                        $begingroup$

                        As an alternative solution, I propose to add an auxiliary integral variable $y in mathbbZ$ that should play the role of the rounded $x$.



                        For your example of the inequality, I would add:
                        $$
                        beginarrayrll
                        y &le& C \
                        x - 0.5&le& y
                        endarray
                        $$






                        share|improve this answer










                        $endgroup$










                        • 3




                          $begingroup$
                          This is close, but trips over the "round-to-even" rule. We can assume that $C$ is integer. Suppose that $C=3$. $x=3.5$, $y=3$ satisfies both inequalities, but $leftlceil xrightrfloor =4$.
                          $endgroup$
                          – prubin
                          Oct 12 at 22:35















                        2
















                        $begingroup$

                        As an alternative solution, I propose to add an auxiliary integral variable $y in mathbbZ$ that should play the role of the rounded $x$.



                        For your example of the inequality, I would add:
                        $$
                        beginarrayrll
                        y &le& C \
                        x - 0.5&le& y
                        endarray
                        $$






                        share|improve this answer










                        $endgroup$










                        • 3




                          $begingroup$
                          This is close, but trips over the "round-to-even" rule. We can assume that $C$ is integer. Suppose that $C=3$. $x=3.5$, $y=3$ satisfies both inequalities, but $leftlceil xrightrfloor =4$.
                          $endgroup$
                          – prubin
                          Oct 12 at 22:35













                        2














                        2










                        2







                        $begingroup$

                        As an alternative solution, I propose to add an auxiliary integral variable $y in mathbbZ$ that should play the role of the rounded $x$.



                        For your example of the inequality, I would add:
                        $$
                        beginarrayrll
                        y &le& C \
                        x - 0.5&le& y
                        endarray
                        $$






                        share|improve this answer










                        $endgroup$



                        As an alternative solution, I propose to add an auxiliary integral variable $y in mathbbZ$ that should play the role of the rounded $x$.



                        For your example of the inequality, I would add:
                        $$
                        beginarrayrll
                        y &le& C \
                        x - 0.5&le& y
                        endarray
                        $$







                        share|improve this answer













                        share|improve this answer




                        share|improve this answer










                        answered Oct 12 at 20:59









                        Robert SchwarzRobert Schwarz

                        1,1753 silver badges15 bronze badges




                        1,1753 silver badges15 bronze badges










                        • 3




                          $begingroup$
                          This is close, but trips over the "round-to-even" rule. We can assume that $C$ is integer. Suppose that $C=3$. $x=3.5$, $y=3$ satisfies both inequalities, but $leftlceil xrightrfloor =4$.
                          $endgroup$
                          – prubin
                          Oct 12 at 22:35












                        • 3




                          $begingroup$
                          This is close, but trips over the "round-to-even" rule. We can assume that $C$ is integer. Suppose that $C=3$. $x=3.5$, $y=3$ satisfies both inequalities, but $leftlceil xrightrfloor =4$.
                          $endgroup$
                          – prubin
                          Oct 12 at 22:35







                        3




                        3




                        $begingroup$
                        This is close, but trips over the "round-to-even" rule. We can assume that $C$ is integer. Suppose that $C=3$. $x=3.5$, $y=3$ satisfies both inequalities, but $leftlceil xrightrfloor =4$.
                        $endgroup$
                        – prubin
                        Oct 12 at 22:35




                        $begingroup$
                        This is close, but trips over the "round-to-even" rule. We can assume that $C$ is integer. Suppose that $C=3$. $x=3.5$, $y=3$ satisfies both inequalities, but $leftlceil xrightrfloor =4$.
                        $endgroup$
                        – prubin
                        Oct 12 at 22:35











                        1
















                        $begingroup$

                        Assuming that the value $C + 0.5$ is valid, you could model this by simply adding the constraint



                        $$x leq C + 0.5$$



                        Otherwise, you define a constant say $epsilon = 10^-7$ and do



                        $$x leq C + 0.5 - epsilon$$






                        share|improve this answer












                        $endgroup$



















                          1
















                          $begingroup$

                          Assuming that the value $C + 0.5$ is valid, you could model this by simply adding the constraint



                          $$x leq C + 0.5$$



                          Otherwise, you define a constant say $epsilon = 10^-7$ and do



                          $$x leq C + 0.5 - epsilon$$






                          share|improve this answer












                          $endgroup$

















                            1














                            1










                            1







                            $begingroup$

                            Assuming that the value $C + 0.5$ is valid, you could model this by simply adding the constraint



                            $$x leq C + 0.5$$



                            Otherwise, you define a constant say $epsilon = 10^-7$ and do



                            $$x leq C + 0.5 - epsilon$$






                            share|improve this answer












                            $endgroup$



                            Assuming that the value $C + 0.5$ is valid, you could model this by simply adding the constraint



                            $$x leq C + 0.5$$



                            Otherwise, you define a constant say $epsilon = 10^-7$ and do



                            $$x leq C + 0.5 - epsilon$$







                            share|improve this answer















                            share|improve this answer




                            share|improve this answer








                            edited Oct 12 at 22:19

























                            answered Oct 12 at 22:12









                            Claudio ContardoClaudio Contardo

                            8362 silver badges9 bronze badges




                            8362 silver badges9 bronze badges
























                                Josh Allen is a new contributor. Be nice, and check out our Code of Conduct.









                                draft saved

                                draft discarded

















                                Josh Allen is a new contributor. Be nice, and check out our Code of Conduct.












                                Josh Allen is a new contributor. Be nice, and check out our Code of Conduct.











                                Josh Allen is a new contributor. Be nice, and check out our Code of Conduct.














                                Thanks for contributing an answer to Operations Research Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                Use MathJax to format equations. MathJax reference.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2for.stackexchange.com%2fquestions%2f2790%2fmodeling-the-round-nearest-integer-function%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown









                                Popular posts from this blog

                                Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                                Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                                199年 目錄 大件事 到箇年出世嗰人 到箇年死嗰人 節慶、風俗習慣 導覽選單