Optimization model where a certain conditions affect objective rather than being a constraint












0












$begingroup$


I have a minimization problem related to packing. I have to distribute a given amount of items from different sets to different packs. Each pack must be either empty or have a certain minimum of items. There is a penalty on each pack so i have to minimize the amount of packs



But there is also a penalty (rather than a constraint) for having items from different sets in the same packs so it is



$$min C_1 sum_{i}^{packs}if(X_{i,any} >0 ) + C_2sum_{j}^{packs}if[exists
X_{ij}>0,X_{kj}>0;kneq i
]$$



when $x_{i,j }$ is number of items from $j$ in pack $i$. Also it's a constraint that $ sum X_{i,j} = text{constant}$



What model can I use to solve that problem?





edit:



My problem is that my objective function is not continuous, and as far as I found out is not good for any linear or non-linear programming solution.



is there a way to either replace it with a function that gives a similar solution to the problem or is there another way to solve it?










share|cite|improve this question











$endgroup$

















    0












    $begingroup$


    I have a minimization problem related to packing. I have to distribute a given amount of items from different sets to different packs. Each pack must be either empty or have a certain minimum of items. There is a penalty on each pack so i have to minimize the amount of packs



    But there is also a penalty (rather than a constraint) for having items from different sets in the same packs so it is



    $$min C_1 sum_{i}^{packs}if(X_{i,any} >0 ) + C_2sum_{j}^{packs}if[exists
    X_{ij}>0,X_{kj}>0;kneq i
    ]$$



    when $x_{i,j }$ is number of items from $j$ in pack $i$. Also it's a constraint that $ sum X_{i,j} = text{constant}$



    What model can I use to solve that problem?





    edit:



    My problem is that my objective function is not continuous, and as far as I found out is not good for any linear or non-linear programming solution.



    is there a way to either replace it with a function that gives a similar solution to the problem or is there another way to solve it?










    share|cite|improve this question











    $endgroup$















      0












      0








      0





      $begingroup$


      I have a minimization problem related to packing. I have to distribute a given amount of items from different sets to different packs. Each pack must be either empty or have a certain minimum of items. There is a penalty on each pack so i have to minimize the amount of packs



      But there is also a penalty (rather than a constraint) for having items from different sets in the same packs so it is



      $$min C_1 sum_{i}^{packs}if(X_{i,any} >0 ) + C_2sum_{j}^{packs}if[exists
      X_{ij}>0,X_{kj}>0;kneq i
      ]$$



      when $x_{i,j }$ is number of items from $j$ in pack $i$. Also it's a constraint that $ sum X_{i,j} = text{constant}$



      What model can I use to solve that problem?





      edit:



      My problem is that my objective function is not continuous, and as far as I found out is not good for any linear or non-linear programming solution.



      is there a way to either replace it with a function that gives a similar solution to the problem or is there another way to solve it?










      share|cite|improve this question











      $endgroup$




      I have a minimization problem related to packing. I have to distribute a given amount of items from different sets to different packs. Each pack must be either empty or have a certain minimum of items. There is a penalty on each pack so i have to minimize the amount of packs



      But there is also a penalty (rather than a constraint) for having items from different sets in the same packs so it is



      $$min C_1 sum_{i}^{packs}if(X_{i,any} >0 ) + C_2sum_{j}^{packs}if[exists
      X_{ij}>0,X_{kj}>0;kneq i
      ]$$



      when $x_{i,j }$ is number of items from $j$ in pack $i$. Also it's a constraint that $ sum X_{i,j} = text{constant}$



      What model can I use to solve that problem?





      edit:



      My problem is that my objective function is not continuous, and as far as I found out is not good for any linear or non-linear programming solution.



      is there a way to either replace it with a function that gives a similar solution to the problem or is there another way to solve it?







      optimization linear-programming nonlinear-optimization






      share|cite|improve this question















      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Jan 31 at 16:27







      Michael Razgoner

















      asked Jan 29 at 21:44









      Michael RazgonerMichael Razgoner

      32




      32






















          1 Answer
          1






          active

          oldest

          votes


















          0












          $begingroup$

          Your math is a little bit difficult to read. I can try to parse the first term. Let's introduce a binary variable $y_i$ indicating if bin $i$ is used. Then we can write:



          $$begin{align} min> & C_1 sum_i y_i\
          &M_i y_i ge x_{i,j} &forall i,j \
          &y_{i} in {0,1}
          end{align}$$



          This is linear. $M_i$ is a large enough constant, to be chosen with care. I think this is what you want to achieve in the first part.



          Sorry, I don't understand what you try to achieve in the second part.



          In your text you indicate you want to model: "Each pack must be either empty or have a certain minimum of items." In other words: if $y_{i} = 1$ then $sum_j x_{i,j}ge L$. This can be modeled as:



          $$sum_j x_{i,j} ge y_i L
          $$






          share|cite|improve this answer











          $endgroup$













          • $begingroup$
            Thank you for your help so far, you are correct and it helped me, what i am trying to do in the second part is some kind of variable that is true when more than one cell is not zero in a row (with the same j), a pack of items that come from mix of sets.
            $endgroup$
            – Michael Razgoner
            Jan 31 at 14:33










          • $begingroup$
            But X(i,j) variables are not binary, how can I create that step function to indicate when X(i,j) is non zero?
            $endgroup$
            – Michael Razgoner
            Jan 31 at 15:13










          • $begingroup$
            Indeed: see the $M_i$ in the first constraint. It is an upper bound on the number of items $j$ in bin $i$.
            $endgroup$
            – Erwin Kalvelagen
            Jan 31 at 15:33












          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',
          autoActivateHeartbeat: false,
          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%2f3092765%2foptimization-model-where-a-certain-conditions-affect-objective-rather-than-being%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0












          $begingroup$

          Your math is a little bit difficult to read. I can try to parse the first term. Let's introduce a binary variable $y_i$ indicating if bin $i$ is used. Then we can write:



          $$begin{align} min> & C_1 sum_i y_i\
          &M_i y_i ge x_{i,j} &forall i,j \
          &y_{i} in {0,1}
          end{align}$$



          This is linear. $M_i$ is a large enough constant, to be chosen with care. I think this is what you want to achieve in the first part.



          Sorry, I don't understand what you try to achieve in the second part.



          In your text you indicate you want to model: "Each pack must be either empty or have a certain minimum of items." In other words: if $y_{i} = 1$ then $sum_j x_{i,j}ge L$. This can be modeled as:



          $$sum_j x_{i,j} ge y_i L
          $$






          share|cite|improve this answer











          $endgroup$













          • $begingroup$
            Thank you for your help so far, you are correct and it helped me, what i am trying to do in the second part is some kind of variable that is true when more than one cell is not zero in a row (with the same j), a pack of items that come from mix of sets.
            $endgroup$
            – Michael Razgoner
            Jan 31 at 14:33










          • $begingroup$
            But X(i,j) variables are not binary, how can I create that step function to indicate when X(i,j) is non zero?
            $endgroup$
            – Michael Razgoner
            Jan 31 at 15:13










          • $begingroup$
            Indeed: see the $M_i$ in the first constraint. It is an upper bound on the number of items $j$ in bin $i$.
            $endgroup$
            – Erwin Kalvelagen
            Jan 31 at 15:33
















          0












          $begingroup$

          Your math is a little bit difficult to read. I can try to parse the first term. Let's introduce a binary variable $y_i$ indicating if bin $i$ is used. Then we can write:



          $$begin{align} min> & C_1 sum_i y_i\
          &M_i y_i ge x_{i,j} &forall i,j \
          &y_{i} in {0,1}
          end{align}$$



          This is linear. $M_i$ is a large enough constant, to be chosen with care. I think this is what you want to achieve in the first part.



          Sorry, I don't understand what you try to achieve in the second part.



          In your text you indicate you want to model: "Each pack must be either empty or have a certain minimum of items." In other words: if $y_{i} = 1$ then $sum_j x_{i,j}ge L$. This can be modeled as:



          $$sum_j x_{i,j} ge y_i L
          $$






          share|cite|improve this answer











          $endgroup$













          • $begingroup$
            Thank you for your help so far, you are correct and it helped me, what i am trying to do in the second part is some kind of variable that is true when more than one cell is not zero in a row (with the same j), a pack of items that come from mix of sets.
            $endgroup$
            – Michael Razgoner
            Jan 31 at 14:33










          • $begingroup$
            But X(i,j) variables are not binary, how can I create that step function to indicate when X(i,j) is non zero?
            $endgroup$
            – Michael Razgoner
            Jan 31 at 15:13










          • $begingroup$
            Indeed: see the $M_i$ in the first constraint. It is an upper bound on the number of items $j$ in bin $i$.
            $endgroup$
            – Erwin Kalvelagen
            Jan 31 at 15:33














          0












          0








          0





          $begingroup$

          Your math is a little bit difficult to read. I can try to parse the first term. Let's introduce a binary variable $y_i$ indicating if bin $i$ is used. Then we can write:



          $$begin{align} min> & C_1 sum_i y_i\
          &M_i y_i ge x_{i,j} &forall i,j \
          &y_{i} in {0,1}
          end{align}$$



          This is linear. $M_i$ is a large enough constant, to be chosen with care. I think this is what you want to achieve in the first part.



          Sorry, I don't understand what you try to achieve in the second part.



          In your text you indicate you want to model: "Each pack must be either empty or have a certain minimum of items." In other words: if $y_{i} = 1$ then $sum_j x_{i,j}ge L$. This can be modeled as:



          $$sum_j x_{i,j} ge y_i L
          $$






          share|cite|improve this answer











          $endgroup$



          Your math is a little bit difficult to read. I can try to parse the first term. Let's introduce a binary variable $y_i$ indicating if bin $i$ is used. Then we can write:



          $$begin{align} min> & C_1 sum_i y_i\
          &M_i y_i ge x_{i,j} &forall i,j \
          &y_{i} in {0,1}
          end{align}$$



          This is linear. $M_i$ is a large enough constant, to be chosen with care. I think this is what you want to achieve in the first part.



          Sorry, I don't understand what you try to achieve in the second part.



          In your text you indicate you want to model: "Each pack must be either empty or have a certain minimum of items." In other words: if $y_{i} = 1$ then $sum_j x_{i,j}ge L$. This can be modeled as:



          $$sum_j x_{i,j} ge y_i L
          $$







          share|cite|improve this answer














          share|cite|improve this answer



          share|cite|improve this answer








          edited Jan 31 at 15:12

























          answered Jan 31 at 11:13









          Erwin KalvelagenErwin Kalvelagen

          3,2542512




          3,2542512












          • $begingroup$
            Thank you for your help so far, you are correct and it helped me, what i am trying to do in the second part is some kind of variable that is true when more than one cell is not zero in a row (with the same j), a pack of items that come from mix of sets.
            $endgroup$
            – Michael Razgoner
            Jan 31 at 14:33










          • $begingroup$
            But X(i,j) variables are not binary, how can I create that step function to indicate when X(i,j) is non zero?
            $endgroup$
            – Michael Razgoner
            Jan 31 at 15:13










          • $begingroup$
            Indeed: see the $M_i$ in the first constraint. It is an upper bound on the number of items $j$ in bin $i$.
            $endgroup$
            – Erwin Kalvelagen
            Jan 31 at 15:33


















          • $begingroup$
            Thank you for your help so far, you are correct and it helped me, what i am trying to do in the second part is some kind of variable that is true when more than one cell is not zero in a row (with the same j), a pack of items that come from mix of sets.
            $endgroup$
            – Michael Razgoner
            Jan 31 at 14:33










          • $begingroup$
            But X(i,j) variables are not binary, how can I create that step function to indicate when X(i,j) is non zero?
            $endgroup$
            – Michael Razgoner
            Jan 31 at 15:13










          • $begingroup$
            Indeed: see the $M_i$ in the first constraint. It is an upper bound on the number of items $j$ in bin $i$.
            $endgroup$
            – Erwin Kalvelagen
            Jan 31 at 15:33
















          $begingroup$
          Thank you for your help so far, you are correct and it helped me, what i am trying to do in the second part is some kind of variable that is true when more than one cell is not zero in a row (with the same j), a pack of items that come from mix of sets.
          $endgroup$
          – Michael Razgoner
          Jan 31 at 14:33




          $begingroup$
          Thank you for your help so far, you are correct and it helped me, what i am trying to do in the second part is some kind of variable that is true when more than one cell is not zero in a row (with the same j), a pack of items that come from mix of sets.
          $endgroup$
          – Michael Razgoner
          Jan 31 at 14:33












          $begingroup$
          But X(i,j) variables are not binary, how can I create that step function to indicate when X(i,j) is non zero?
          $endgroup$
          – Michael Razgoner
          Jan 31 at 15:13




          $begingroup$
          But X(i,j) variables are not binary, how can I create that step function to indicate when X(i,j) is non zero?
          $endgroup$
          – Michael Razgoner
          Jan 31 at 15:13












          $begingroup$
          Indeed: see the $M_i$ in the first constraint. It is an upper bound on the number of items $j$ in bin $i$.
          $endgroup$
          – Erwin Kalvelagen
          Jan 31 at 15:33




          $begingroup$
          Indeed: see the $M_i$ in the first constraint. It is an upper bound on the number of items $j$ in bin $i$.
          $endgroup$
          – Erwin Kalvelagen
          Jan 31 at 15:33


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Mathematics 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%2fmath.stackexchange.com%2fquestions%2f3092765%2foptimization-model-where-a-certain-conditions-affect-objective-rather-than-being%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

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith