Algorithm to find integer combinations satisfying a set of inequalities











up vote
0
down vote

favorite












I have an engineering problem that is reduced to finding a set of positive integer combinations satisfying several inequalities and some other properties.



Specially, let $mathcal{S}$ be the set of all positive integer combinations $(M, K, W, Q)$ satisfying the following $3$ inequalities:
$$
WQ+Kleq N,
$$

$$
Wleq M,
$$

$$
MKgeq F,
$$

where $F$ and $N$ are known positive integers. I need an algorithm to obtain a subset of $mathcal{S}$. The elements of the subset should be obtained according to the following conditions:



1, For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same $(M, Q)$, only keep the $(M, K, W, Q)$ with the largest $W$;



2, For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same $(W, Q)$, only keep the $(M, K, W, Q)$ with the smallest $M$;



3, For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same $(M, W, Q)$, only keep the $(M, K, W, Q)$ with the largest $K$.



Is there an efficient algorithm to achieve this? And is that possible to count the number of combinations in the subset, as a function of $F$ and $N$?










share|cite|improve this question
























  • To clarify: any or all of the values could be negative?
    – Peter Taylor
    14 hours ago










  • All values are positive. Sorry for missing the information.
    – Ye Li
    12 hours ago















up vote
0
down vote

favorite












I have an engineering problem that is reduced to finding a set of positive integer combinations satisfying several inequalities and some other properties.



Specially, let $mathcal{S}$ be the set of all positive integer combinations $(M, K, W, Q)$ satisfying the following $3$ inequalities:
$$
WQ+Kleq N,
$$

$$
Wleq M,
$$

$$
MKgeq F,
$$

where $F$ and $N$ are known positive integers. I need an algorithm to obtain a subset of $mathcal{S}$. The elements of the subset should be obtained according to the following conditions:



1, For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same $(M, Q)$, only keep the $(M, K, W, Q)$ with the largest $W$;



2, For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same $(W, Q)$, only keep the $(M, K, W, Q)$ with the smallest $M$;



3, For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same $(M, W, Q)$, only keep the $(M, K, W, Q)$ with the largest $K$.



Is there an efficient algorithm to achieve this? And is that possible to count the number of combinations in the subset, as a function of $F$ and $N$?










share|cite|improve this question
























  • To clarify: any or all of the values could be negative?
    – Peter Taylor
    14 hours ago










  • All values are positive. Sorry for missing the information.
    – Ye Li
    12 hours ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have an engineering problem that is reduced to finding a set of positive integer combinations satisfying several inequalities and some other properties.



Specially, let $mathcal{S}$ be the set of all positive integer combinations $(M, K, W, Q)$ satisfying the following $3$ inequalities:
$$
WQ+Kleq N,
$$

$$
Wleq M,
$$

$$
MKgeq F,
$$

where $F$ and $N$ are known positive integers. I need an algorithm to obtain a subset of $mathcal{S}$. The elements of the subset should be obtained according to the following conditions:



1, For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same $(M, Q)$, only keep the $(M, K, W, Q)$ with the largest $W$;



2, For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same $(W, Q)$, only keep the $(M, K, W, Q)$ with the smallest $M$;



3, For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same $(M, W, Q)$, only keep the $(M, K, W, Q)$ with the largest $K$.



Is there an efficient algorithm to achieve this? And is that possible to count the number of combinations in the subset, as a function of $F$ and $N$?










share|cite|improve this question















I have an engineering problem that is reduced to finding a set of positive integer combinations satisfying several inequalities and some other properties.



Specially, let $mathcal{S}$ be the set of all positive integer combinations $(M, K, W, Q)$ satisfying the following $3$ inequalities:
$$
WQ+Kleq N,
$$

$$
Wleq M,
$$

$$
MKgeq F,
$$

where $F$ and $N$ are known positive integers. I need an algorithm to obtain a subset of $mathcal{S}$. The elements of the subset should be obtained according to the following conditions:



1, For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same $(M, Q)$, only keep the $(M, K, W, Q)$ with the largest $W$;



2, For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same $(W, Q)$, only keep the $(M, K, W, Q)$ with the smallest $M$;



3, For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same $(M, W, Q)$, only keep the $(M, K, W, Q)$ with the largest $K$.



Is there an efficient algorithm to achieve this? And is that possible to count the number of combinations in the subset, as a function of $F$ and $N$?







combinatorics optimization algorithms combinations integer-programming






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited 12 hours ago

























asked 19 hours ago









Ye Li

486




486












  • To clarify: any or all of the values could be negative?
    – Peter Taylor
    14 hours ago










  • All values are positive. Sorry for missing the information.
    – Ye Li
    12 hours ago


















  • To clarify: any or all of the values could be negative?
    – Peter Taylor
    14 hours ago










  • All values are positive. Sorry for missing the information.
    – Ye Li
    12 hours ago
















To clarify: any or all of the values could be negative?
– Peter Taylor
14 hours ago




To clarify: any or all of the values could be negative?
– Peter Taylor
14 hours ago












All values are positive. Sorry for missing the information.
– Ye Li
12 hours ago




All values are positive. Sorry for missing the information.
– Ye Li
12 hours ago










1 Answer
1






active

oldest

votes

















up vote
0
down vote













Combine the inequalities into two: $$W le M \ frac FM le K le N-WQ$$



Firstly I note that the constraint filters effectively treat $Q$ as a free variable in the same way as $F$ and $N$.



Consider constraint 3:





  1. For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same
    $(M, W, Q)$, only keep the $(M, K, W, Q)$ with the largest $K$.




This implies $K = N - WQ$ and we can eliminate and ignore it.





$$W le M \ F le M(N-WQ)$$





  1. For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same
    $(M, Q)$, only keep the $(M, K, W, Q)$ with the largest $W$;




So maximise $W$ as a function of $M$. We have $W le M$ and $W le frac{N - FM}Q$, so this implies $W = minleft(M, leftlfloorfrac{N - FM}Qrightrfloorright)$.







  1. For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same
    $(W, Q)$, only keep the $(M, K, W, Q)$ with the smallest $M$;




If $M le leftlfloorfrac{N - FM}Qrightrfloor$, we can't reduce $M$ because that would reduce $W$.



If $M > leftlfloorfrac{N - FM}Qrightrfloor$, decreasing $M$ by one cannot violate $W le M$ and it increases the other bound on $W$. Therefore we must decrease $M$ until $M = W$.





So we have the following constraints: $$ W = M \ frac FM le K = N - WQ $$ Substituting the first into the second we have $$F le M(N - MQ)$$ or $$Q M^2 - MN + F le 0$$ Since $Q > 0$, $$frac{N - sqrt{N^2 - 4QF}}{2Q} le M le frac{N + sqrt{N^2 - 4QF}}{2Q}$$



Since we need real roots to have any solutions, $Q$ isn't entirely free: we require $Q le frac{N^2}{4F}$.



Given a value of $Q$, the number of values of $M$ is approximately $frac{sqrt{N^2 - 4QF}}{Q}$, so the total number of solutions is approximately $$int_{1}^{frac{N^2}{4F}} frac{sqrt{N^2 - 4QF}}{Q} dQ$$



Subst $c = frac{N^2}{4F}$ to get $2sqrt{F} int_1^c frac{sqrt{c - Q}}{Q} dQ$, and if I haven't messed up the substitutions and the use of Wolfram Alpha to cheat on the core integral, you get $4sqrt{F} left(sqrt{c-1} - sqrt{c} tanh^{-1}sqrt{1-frac{1}{c}}right)$






share|cite|improve this answer





















    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "69"
    };
    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',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2997893%2falgorithm-to-find-integer-combinations-satisfying-a-set-of-inequalities%23new-answer', 'question_page');
    }
    );

    Post as a guest
































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Combine the inequalities into two: $$W le M \ frac FM le K le N-WQ$$



    Firstly I note that the constraint filters effectively treat $Q$ as a free variable in the same way as $F$ and $N$.



    Consider constraint 3:





    1. For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same
      $(M, W, Q)$, only keep the $(M, K, W, Q)$ with the largest $K$.




    This implies $K = N - WQ$ and we can eliminate and ignore it.





    $$W le M \ F le M(N-WQ)$$





    1. For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same
      $(M, Q)$, only keep the $(M, K, W, Q)$ with the largest $W$;




    So maximise $W$ as a function of $M$. We have $W le M$ and $W le frac{N - FM}Q$, so this implies $W = minleft(M, leftlfloorfrac{N - FM}Qrightrfloorright)$.







    1. For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same
      $(W, Q)$, only keep the $(M, K, W, Q)$ with the smallest $M$;




    If $M le leftlfloorfrac{N - FM}Qrightrfloor$, we can't reduce $M$ because that would reduce $W$.



    If $M > leftlfloorfrac{N - FM}Qrightrfloor$, decreasing $M$ by one cannot violate $W le M$ and it increases the other bound on $W$. Therefore we must decrease $M$ until $M = W$.





    So we have the following constraints: $$ W = M \ frac FM le K = N - WQ $$ Substituting the first into the second we have $$F le M(N - MQ)$$ or $$Q M^2 - MN + F le 0$$ Since $Q > 0$, $$frac{N - sqrt{N^2 - 4QF}}{2Q} le M le frac{N + sqrt{N^2 - 4QF}}{2Q}$$



    Since we need real roots to have any solutions, $Q$ isn't entirely free: we require $Q le frac{N^2}{4F}$.



    Given a value of $Q$, the number of values of $M$ is approximately $frac{sqrt{N^2 - 4QF}}{Q}$, so the total number of solutions is approximately $$int_{1}^{frac{N^2}{4F}} frac{sqrt{N^2 - 4QF}}{Q} dQ$$



    Subst $c = frac{N^2}{4F}$ to get $2sqrt{F} int_1^c frac{sqrt{c - Q}}{Q} dQ$, and if I haven't messed up the substitutions and the use of Wolfram Alpha to cheat on the core integral, you get $4sqrt{F} left(sqrt{c-1} - sqrt{c} tanh^{-1}sqrt{1-frac{1}{c}}right)$






    share|cite|improve this answer

























      up vote
      0
      down vote













      Combine the inequalities into two: $$W le M \ frac FM le K le N-WQ$$



      Firstly I note that the constraint filters effectively treat $Q$ as a free variable in the same way as $F$ and $N$.



      Consider constraint 3:





      1. For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same
        $(M, W, Q)$, only keep the $(M, K, W, Q)$ with the largest $K$.




      This implies $K = N - WQ$ and we can eliminate and ignore it.





      $$W le M \ F le M(N-WQ)$$





      1. For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same
        $(M, Q)$, only keep the $(M, K, W, Q)$ with the largest $W$;




      So maximise $W$ as a function of $M$. We have $W le M$ and $W le frac{N - FM}Q$, so this implies $W = minleft(M, leftlfloorfrac{N - FM}Qrightrfloorright)$.







      1. For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same
        $(W, Q)$, only keep the $(M, K, W, Q)$ with the smallest $M$;




      If $M le leftlfloorfrac{N - FM}Qrightrfloor$, we can't reduce $M$ because that would reduce $W$.



      If $M > leftlfloorfrac{N - FM}Qrightrfloor$, decreasing $M$ by one cannot violate $W le M$ and it increases the other bound on $W$. Therefore we must decrease $M$ until $M = W$.





      So we have the following constraints: $$ W = M \ frac FM le K = N - WQ $$ Substituting the first into the second we have $$F le M(N - MQ)$$ or $$Q M^2 - MN + F le 0$$ Since $Q > 0$, $$frac{N - sqrt{N^2 - 4QF}}{2Q} le M le frac{N + sqrt{N^2 - 4QF}}{2Q}$$



      Since we need real roots to have any solutions, $Q$ isn't entirely free: we require $Q le frac{N^2}{4F}$.



      Given a value of $Q$, the number of values of $M$ is approximately $frac{sqrt{N^2 - 4QF}}{Q}$, so the total number of solutions is approximately $$int_{1}^{frac{N^2}{4F}} frac{sqrt{N^2 - 4QF}}{Q} dQ$$



      Subst $c = frac{N^2}{4F}$ to get $2sqrt{F} int_1^c frac{sqrt{c - Q}}{Q} dQ$, and if I haven't messed up the substitutions and the use of Wolfram Alpha to cheat on the core integral, you get $4sqrt{F} left(sqrt{c-1} - sqrt{c} tanh^{-1}sqrt{1-frac{1}{c}}right)$






      share|cite|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Combine the inequalities into two: $$W le M \ frac FM le K le N-WQ$$



        Firstly I note that the constraint filters effectively treat $Q$ as a free variable in the same way as $F$ and $N$.



        Consider constraint 3:





        1. For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same
          $(M, W, Q)$, only keep the $(M, K, W, Q)$ with the largest $K$.




        This implies $K = N - WQ$ and we can eliminate and ignore it.





        $$W le M \ F le M(N-WQ)$$





        1. For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same
          $(M, Q)$, only keep the $(M, K, W, Q)$ with the largest $W$;




        So maximise $W$ as a function of $M$. We have $W le M$ and $W le frac{N - FM}Q$, so this implies $W = minleft(M, leftlfloorfrac{N - FM}Qrightrfloorright)$.







        1. For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same
          $(W, Q)$, only keep the $(M, K, W, Q)$ with the smallest $M$;




        If $M le leftlfloorfrac{N - FM}Qrightrfloor$, we can't reduce $M$ because that would reduce $W$.



        If $M > leftlfloorfrac{N - FM}Qrightrfloor$, decreasing $M$ by one cannot violate $W le M$ and it increases the other bound on $W$. Therefore we must decrease $M$ until $M = W$.





        So we have the following constraints: $$ W = M \ frac FM le K = N - WQ $$ Substituting the first into the second we have $$F le M(N - MQ)$$ or $$Q M^2 - MN + F le 0$$ Since $Q > 0$, $$frac{N - sqrt{N^2 - 4QF}}{2Q} le M le frac{N + sqrt{N^2 - 4QF}}{2Q}$$



        Since we need real roots to have any solutions, $Q$ isn't entirely free: we require $Q le frac{N^2}{4F}$.



        Given a value of $Q$, the number of values of $M$ is approximately $frac{sqrt{N^2 - 4QF}}{Q}$, so the total number of solutions is approximately $$int_{1}^{frac{N^2}{4F}} frac{sqrt{N^2 - 4QF}}{Q} dQ$$



        Subst $c = frac{N^2}{4F}$ to get $2sqrt{F} int_1^c frac{sqrt{c - Q}}{Q} dQ$, and if I haven't messed up the substitutions and the use of Wolfram Alpha to cheat on the core integral, you get $4sqrt{F} left(sqrt{c-1} - sqrt{c} tanh^{-1}sqrt{1-frac{1}{c}}right)$






        share|cite|improve this answer












        Combine the inequalities into two: $$W le M \ frac FM le K le N-WQ$$



        Firstly I note that the constraint filters effectively treat $Q$ as a free variable in the same way as $F$ and $N$.



        Consider constraint 3:





        1. For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same
          $(M, W, Q)$, only keep the $(M, K, W, Q)$ with the largest $K$.




        This implies $K = N - WQ$ and we can eliminate and ignore it.





        $$W le M \ F le M(N-WQ)$$





        1. For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same
          $(M, Q)$, only keep the $(M, K, W, Q)$ with the largest $W$;




        So maximise $W$ as a function of $M$. We have $W le M$ and $W le frac{N - FM}Q$, so this implies $W = minleft(M, leftlfloorfrac{N - FM}Qrightrfloorright)$.







        1. For combinations $(M, K, W, Q)$ of $mathcal{S}$ having the same
          $(W, Q)$, only keep the $(M, K, W, Q)$ with the smallest $M$;




        If $M le leftlfloorfrac{N - FM}Qrightrfloor$, we can't reduce $M$ because that would reduce $W$.



        If $M > leftlfloorfrac{N - FM}Qrightrfloor$, decreasing $M$ by one cannot violate $W le M$ and it increases the other bound on $W$. Therefore we must decrease $M$ until $M = W$.





        So we have the following constraints: $$ W = M \ frac FM le K = N - WQ $$ Substituting the first into the second we have $$F le M(N - MQ)$$ or $$Q M^2 - MN + F le 0$$ Since $Q > 0$, $$frac{N - sqrt{N^2 - 4QF}}{2Q} le M le frac{N + sqrt{N^2 - 4QF}}{2Q}$$



        Since we need real roots to have any solutions, $Q$ isn't entirely free: we require $Q le frac{N^2}{4F}$.



        Given a value of $Q$, the number of values of $M$ is approximately $frac{sqrt{N^2 - 4QF}}{Q}$, so the total number of solutions is approximately $$int_{1}^{frac{N^2}{4F}} frac{sqrt{N^2 - 4QF}}{Q} dQ$$



        Subst $c = frac{N^2}{4F}$ to get $2sqrt{F} int_1^c frac{sqrt{c - Q}}{Q} dQ$, and if I haven't messed up the substitutions and the use of Wolfram Alpha to cheat on the core integral, you get $4sqrt{F} left(sqrt{c-1} - sqrt{c} tanh^{-1}sqrt{1-frac{1}{c}}right)$







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered 8 hours ago









        Peter Taylor

        8,20112240




        8,20112240






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2997893%2falgorithm-to-find-integer-combinations-satisfying-a-set-of-inequalities%23new-answer', 'question_page');
            }
            );

            Post as a guest




















































































            Popular posts from this blog

            Plaza Victoria

            Puebla de Zaragoza

            Musa